Skip to content
RCE Write-up Beginner

Root in 11 Minutes: What an Old Linux Box Taught Me About Thinking Like an Operator

An old Samba service on a deliberately vulnerable Linux box was running as root and contained a known buffer overflow (trans2open). An attacker could exploit this to gain a root shell without any prior access.

Jesse Ridley Follow

Published on medium.com

Kioptrix Level 1, start to finish, and the four fixes that would have stopped me cold

Jesse Ridley, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Kioptrix Level 1 is a free, deliberately vulnerable virtual machine built for practice. The target is an old Red Hat 7.2 server from 2001, left unpatched on purpose so that beginners can walk a full attack chain from zero access to root. The write-up below is a walkthrough of that chain, recorded unedited in a home lab on an isolated network, and it took eleven minutes from first contact to a root shell.

From the original on medium.com

The point of the exercise is not the commands. Anyone can copy commands. The point is knowing why each one is run and what its output is telling you. Everything here happened on the author's own isolated network; only test what you own or have written permission to test.

Setup

The lab consists of the Kioptrix Level 1 VM on an isolated network, reached from an attacker host. The tools used are a ping for host discovery, a full TCP port scan, a service and version scan, searchsploit against a local copy of the public Exploit Database, and Metasploit with its Samba trans2open module. No credentials were available at the start; the goal was to begin with zero access and end with root.

Finding it

The first question an operator asks is what is listening. After a quick ping to confirm the host was up, a full port scan across all 65,535 TCP ports came back in about 15 seconds with six open services: SSH, a web server on 80 and 443, RPC, and Samba on port 139.

Six open ports means six possible ways in. The temptation for beginners is to stop here and throw exploits at port 80, because web hacking is what most training videos show. The better move is to write down everything found and ask the next question: what exactly is running on each one?

A second, deeper scan pulled version banners off each service:

  • Apache 1.3.20
  • mod_ssl 2.8.4
  • OpenSSH 2.9
  • Samba, with the version hidden behind the banner, though the era was obvious

Every one of those is decades old. A version number is a shopping list: old software has known, documented vulnerabilities, and the research has already been done publicly. The job at this stage is to read the list.

Exploitation

Step 1: Enumerate every door

A ping confirmed the host was alive, then a full TCP scan covered all 65,535 ports. The result was six open services in roughly 15 seconds: SSH, HTTP on 80, HTTPS on 443, RPC, and Samba on 139. Each one is a candidate path, and each one needs its own version question answered before anything is fired at it.

Step 2: Read the version banners

The deeper scan returned Apache 1.3.20, mod_ssl 2.8.4, OpenSSH 2.9, and Samba with its version hidden but its age apparent. These banners are the shopping list: they map directly to publicly documented vulnerabilities.

Step 3: Look up the receipt

The next step was to run searchsploit against Samba 2.2, which searches a local copy of the public Exploit Database:

Dozens of results came back, and one name kept repeating: trans2open. That is a buffer overflow in how old Samba handled a specific type of request. It was disclosed and patched in 2003 as CVE-2003-0201, fixed in Samba 2.2.8a. The fix for this machine has existed for over twenty years.

There was no genius move at this stage. The vulnerability was public, the fix was public, and the only thing missing was someone doing maintenance.

Step 4: Fire the exploit

Metasploit already ships a module for trans2open. The module was loaded, pointed at the target, and the default reverse payload was swapped for a bind shell before running it. The exploit works by trying memory addresses one after another until one lands. In the recording you can watch line after line of "Trying return address..." and then, about a minute later, a shell opens.

Step 5: Confirm root

In the new session, id was run:

It returned uid=0(root). No privilege escalation was needed. Samba was running as root, so breaking Samba meant owning the whole machine on the first hit. From that shell the author could read /etc/shadow, the file that holds password hashes; it was blurred in the video, a habit worth building even on lab boxes.

Start to finish: eleven minutes.

Root cause

The mistake is maintenance, not clever exploitation. The Samba service was an unpatched version carrying the trans2open buffer overflow, a flaw disclosed and fixed in 2003 (CVE-2003-0201, fixed in Samba 2.2.8a). The host is a Red Hat 7.2 system from 2001, left unpatched on purpose. On top of that, Samba was running as root, so a single successful overflow yielded the whole machine rather than a limited foothold. The attack succeeded because the Samba service was unpatched, reachable from the network, and running as root.

Impact

An attacker with network access to the Samba service can obtain a root shell on the host. In this run the shell could read /etc/shadow, and root meant full control of the machine, achieved in eleven minutes with no password guessing and no zero-day. The conditions are the ones above: an unpatched Samba with the trans2open flaw, reachable over the network, running as root. The author's framing is that this is what happens when maintenance gets skipped, and that the same chain applies on a training VM or a real engagement.

Fix

Four fixes would have stopped the attack cold, and each maps to a step above:

  1. Patch on a schedule. The trans2open flaw was fixed in 2003; a patch cycle kills the entire attack.
  2. Close the door. File sharing on ports 139 and 445 should never face an untrusted network. If it does not need to be exposed, do not expose it.
  3. Retire end-of-life systems. An OS that no longer gets updates is a liability: upgrade it, isolate it, or unplug it.
  4. Least privilege. Services should not run as root. Had Samba run as a limited user, the shell would have been a foothold, not the whole house.

None of these require a big security budget. They require attention.

Variants to test

  • Other Samba versions in the same era. Run searchsploit against the Samba version you find and look for repeated module names. A positive result is a public exploit that matches the banner, as trans2open did here.
  • Other services with old banners. Pull version strings for every open port and check each against the Exploit Database. A positive result is a version with a documented, patched vulnerability.
  • Service privilege level. After any foothold, run id. A positive result is uid=0(root), meaning the service itself runs with full privileges and no escalation is needed.
  • Exposed file sharing. Check whether ports 139 and 445 are reachable from an untrusted network. A positive result is a Samba service answering from outside the trusted segment.
  • End-of-life operating systems. Identify hosts running OS versions that no longer receive updates. A positive result is a system whose vendor has stopped shipping patches.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

A security researcher set up a deliberately broken computer in his own home lab, attacked it, and got complete control of it in eleven minutes. It was broken because it was running unpatched software from 2001, and because one of its services ran as root.

The point of the exercise is not the commands. Anyone can copy commands. The point is knowing why each one is run and what its output is telling you. Everything here happened on the author's own isolated network; only test what you own or have written permission to test.

This walkthrough explains every step from zero, including the words that security people use without explaining them.

From the original on medium.com

The target and the lab

Kioptrix Level 1 is a free, deliberately vulnerable virtual machine built for practice. A virtual machine (VM) is a whole computer simulated inside a file, so you can break it and rebuild it without touching your real computer. Kioptrix is an old Red Hat 7.2 server from 2001, left unpatched on purpose so that beginners can walk a full attack chain from zero access to root.

Some words you will meet constantly:

  • Server: a computer that offers services to other computers over a network.
  • Service: a program on the server that listens for connections, such as a web server or a file-sharing service.
  • Port: a numbered door on a computer. One machine can have thousands of doors, each belonging to a different service. Web traffic normally uses port 80, encrypted web traffic port 443, and file sharing ports 139 and 445.
  • Root: the all-powerful account on a Linux machine. Root can read, change or delete anything. Getting root is the goal of most attacks.
  • Attack chain: the sequence of steps from first contact to full control.
  • Patch: an update that fixes a known flaw. Software that is not patched keeps the flaw.

The lab consists of the Kioptrix Level 1 VM on an isolated network, reached from an attacker host. An isolated network is one cut off from the internet and from everything else, so nothing done inside it can reach the outside world. The tools used are a ping for host discovery, a full TCP port scan, a service and version scan, searchsploit against a local copy of the public Exploit Database, and Metasploit with its Samba trans2open module. No credentials were available at the start; the goal was to begin with zero access and end with root.

Finding it

The first question an operator asks is what is listening. An operator, in this context, is someone who works methodically rather than randomly: look, understand, then act. After a quick ping to confirm the host was up, a full port scan across all 65,535 TCP ports came back in about 15 seconds with six open services: SSH, a web server on 80 and 443, RPC, and Samba on port 139.

What those pieces are:

  • Ping: a tiny message that asks "are you there?" and gets a reply if the machine is alive.
  • Port scan: trying every door on a machine to see which ones answer. TCP is the set of rules most network conversations follow, and a machine has 65,535 TCP ports in total.
  • SSH: a service for logging into a machine remotely with a username and password or key.
  • Web server: the program that serves web pages, on port 80 for normal traffic and 443 for encrypted traffic.
  • RPC: a service that lets programs on different machines call each other.
  • Samba: a file-sharing service that lets other computers read and write files on this one. It is the Linux equivalent of the Windows file-sharing feature.

Six open ports means six possible ways in. The temptation for beginners is to stop here and throw exploits at port 80, because web hacking is what most training videos show. An exploit is a piece of software that abuses a flaw to do something the attacker should not be able to do. The better move is to write down everything found and ask the next question: what exactly is running on each one?

A second, deeper scan pulled version banners off each service. A banner is the greeting a service sends when you connect, and it often names the software and its version:

  • Apache 1.3.20
  • mod_ssl 2.8.4
  • OpenSSH 2.9
  • Samba, with the version hidden behind the banner, though the era was obvious

Apache is the web server software, mod_ssl is the add-on that handles encrypted web traffic, and OpenSSH is the SSH software. Every one of those is decades old. A version number is a shopping list: old software has known, documented vulnerabilities, and the research has already been done publicly. A vulnerability is a flaw that can be abused. The job at this stage is to read the list.

Exploitation

Step 1: Enumerate every door

To enumerate means to list things one by one, completely. A ping confirmed the host was alive, then a full TCP scan covered all 65,535 ports. The result was six open services in roughly 15 seconds: SSH, HTTP on 80, HTTPS on 443, RPC, and Samba on 139. HTTP is the language of normal web traffic and HTTPS is the same language encrypted. Each open service is a candidate path, and each one needs its own version question answered before anything is fired at it.

Step 2: Read the version banners

The deeper scan returned Apache 1.3.20, mod_ssl 2.8.4, OpenSSH 2.9, and Samba with its version hidden but its age apparent. These banners are the shopping list: they map directly to publicly documented vulnerabilities. In other words, for each old version there is a public record of what is wrong with it, and often ready-made code that abuses it.

Step 3: Look up the receipt

The next step was to run searchsploit against Samba 2.2, which searches a local copy of the public Exploit Database:

Line by line: searchsploit is a command-line tool that searches a copy of the Exploit Database, a public catalogue of known exploits, stored on your own machine. samba is the name of the software to look for, and 2.2 narrows the search to that version. The command prints every catalogue entry that matches, so you can read what is already known about this software.

Dozens of results came back, and one name kept repeating: trans2open. That is a buffer overflow in how old Samba handled a specific type of request. A buffer overflow is a flaw where a program is given more data than it reserved space for, so the extra data spills into neighbouring memory and can change how the program behaves. It was disclosed and patched in 2003 as CVE-2003-0201, fixed in Samba 2.2.8a. A CVE is a public identifier for a known vulnerability, so people can refer to the same flaw unambiguously. The fix for this machine has existed for over twenty years.

There was no genius move at this stage. The vulnerability was public, the fix was public, and the only thing missing was someone doing maintenance.

Step 4: Fire the exploit

Metasploit is a free framework that collects exploits and makes them easier to run. It already ships a module for trans2open. A module is one packaged exploit inside the framework. The module was loaded, pointed at the target, and the default reverse payload was swapped for a bind shell before running it.

Two more terms:

  • Payload: the small piece of code the exploit delivers once it succeeds. Here the payload is a shell, a remote command prompt on the target.
  • Reverse shell versus bind shell: a reverse shell makes the target connect back to the attacker, while a bind shell makes the target open a port and wait for the attacker to connect to it. The author switched from the default reverse shell to a bind shell.

The exploit works by trying memory addresses one after another until one lands. In the recording you can watch line after line of "Trying return address..." and then, about a minute later, a shell opens.

Step 5: Confirm root

In the new session, id was run:

Line by line: id is a standard Linux command that prints who the current user is, including the user name and the numeric user identifier. Running it in the new shell answers the question "what am I on this machine?"

It returned uid=0(root). The number 0 is the identifier reserved for root, so this output means the shell is already the most powerful account on the machine. No privilege escalation was needed. Privilege escalation is the extra step of going from a limited account to a more powerful one; here it was unnecessary. Samba was running as root, so breaking Samba meant owning the whole machine on the first hit. From that shell the author could read /etc/shadow, the file that holds password hashes; it was blurred in the video, a habit worth building even on lab boxes. A password hash is a scrambled form of a password, and /etc/shadow is the protected file where Linux keeps those scrambled passwords.

Start to finish: eleven minutes.

Root cause

The mistake is maintenance, not clever exploitation. The Samba service was an unpatched version carrying the trans2open buffer overflow, a flaw disclosed and fixed in 2003 (CVE-2003-0201, fixed in Samba 2.2.8a). The host is a Red Hat 7.2 system from 2001, left unpatched on purpose. On top of that, Samba was running as root, so a single successful overflow yielded the whole machine rather than a limited foothold. A foothold is a small amount of access that an attacker can build on. The attack succeeded because the Samba service was unpatched, reachable from the network, and running as root. End-of-life means the maker has stopped producing updates for it.

Impact

An attacker with network access to the Samba service can obtain a root shell on the host. In this run the shell could read /etc/shadow, and root meant full control of the machine, achieved in eleven minutes with no password guessing and no zero-day. A zero-day is a flaw that is not yet publicly known or fixed. The conditions are the ones above: an unpatched Samba with the trans2open flaw, reachable over the network, running as root. The author's framing is that this is what happens when maintenance gets skipped, and that the same chain applies on a training VM or a real engagement.

Fix

Four fixes would have stopped the attack cold, and each maps to a step above:

  1. Patch on a schedule. The trans2open flaw was fixed in 2003; a patch cycle kills the entire attack. A patch cycle means updates are applied regularly, not only when something breaks.
  2. Close the door. File sharing on ports 139 and 445 should never face an untrusted network. If it does not need to be exposed, do not expose it. An untrusted network is any network you do not control, such as the internet or a public Wi-Fi.
  3. Retire end-of-life systems. An OS that no longer gets updates is a liability: upgrade it, isolate it, or unplug it. OS stands for operating system, the core software such as Linux or Windows.
  4. Least privilege. Services should not run as root. Least privilege means giving every program and person only the permissions they actually need. Had Samba run as a limited user, the shell would have been a foothold, not the whole house.

None of these require a big security budget. They require attention.

Variants to test

These are the same ideas applied to other machines you are allowed to test:

  • Other Samba versions in the same era. Run searchsploit against the Samba version you find and look for repeated module names. A positive result is a public exploit that matches the banner, as trans2open did here.
  • Other services with old banners. Pull version strings for every open port and check each against the Exploit Database. A positive result is a version with a documented, patched vulnerability.
  • Service privilege level. After any foothold, run id. A positive result is uid=0(root), meaning the service itself runs with full privileges and no escalation is needed.
  • Exposed file sharing. Check whether ports 139 and 445 are reachable from an untrusted network. A positive result is a Samba service answering from outside the trusted segment.
  • End-of-life operating systems. Identify hosts running OS versions that no longer receive updates. A positive result is a system whose vendor has stopped shipping patches.

Glossary

  • Apache: the web server software that serves web pages.
  • Attack chain: the sequence of steps from first contact to full control of a machine.
  • Banner: the greeting a service sends when you connect, often naming the software and its version.
  • Bind shell: a shell where the target opens a port and waits for the attacker to connect to it.
  • Buffer overflow: a flaw where a program receives more data than it reserved space for, so the extra data spills into neighbouring memory.
  • CVE: a public identifier for a known vulnerability, so people can refer to the same flaw unambiguously.
  • End-of-life: software whose maker has stopped producing updates for it.
  • Enumerate: to list things one by one, completely.
  • Exploit: a piece of software that abuses a flaw to do something the attacker should not be able to do.
  • Exploit Database: a public catalogue of known exploits.
  • Foothold: a small amount of access that an attacker can build on.
  • Hash: a scrambled form of a password, stored instead of the password itself.
  • HTTP: the language of normal web traffic.
  • HTTPS: the same language as HTTP, encrypted.
  • Isolated network: a network cut off from the internet and everything else.
  • Least privilege: giving every program and person only the permissions they actually need.
  • Metasploit: a free framework that collects exploits and makes them easier to run.
  • mod_ssl: the add-on that handles encrypted web traffic for Apache.
  • Module: one packaged exploit inside a framework such as Metasploit.
  • OpenSSH: the software that provides the SSH service.
  • Operating system (OS): the core software of a computer, such as Linux or Windows.
  • Operator: someone who works methodically: look, understand, then act.
  • Patch: an update that fixes a known flaw.
  • Payload: the small piece of code an exploit delivers once it succeeds.
  • Port: a numbered door on a computer, each belonging to a different service.
  • Privilege escalation: the extra step of going from a limited account to a more powerful one.
  • Reverse shell: a shell where the target connects back to the attacker.
  • Samba: a file-sharing service that lets other computers read and write files on a Linux machine.
  • searchsploit: a command-line tool that searches a local copy of the Exploit Database.
  • Service: a program on a server that listens for connections.
  • Shell: a remote command prompt on a machine.
  • SSH: a service for logging into a machine remotely.
  • TCP: the set of rules most network conversations follow; a machine has 65,535 TCP ports.
  • trans2open: the name of the Samba buffer overflow used here.
  • Untrusted network: any network you do not control, such as the internet or public Wi-Fi.
  • Virtual machine (VM): a whole computer simulated inside a file.
  • Vulnerability: a flaw that can be abused.
  • Web server: the program that serves web pages.
  • Zero-day: a flaw that is not yet publicly known or fixed.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.