🟒 HackTheBox Easy 🐧 Linux

CAP Writeup

A web app with an IDOR vulnerability leaks FTP credentials via a PCAP download β€” leading to a shell as Nathan and a quick Linux capability exploit to root.

πŸ“ Category: Web Β· Network Β· Linux Privesc πŸ”‘ User Flag: βœ… πŸ’€ Root Flag: βœ…
πŸ”

Recon β€” Poking Around the Web App

OK, let's take a look through the website that has been spun up.

Website overview

So, it's some sort of security dashboard. Let's look at network status on the left to see if it gives us any clues.

Network status panel

The 10.10.14.14 is our IP address β€” ports 36710 and 51702 seem interesting. Let's see what that is.

Port details More port info

I get bored with Minecraft after about 30 minutes (sorry if that offends you.) Nothing really that gives us any hint here… but let's keep this top of mind. There's DNS (port 53) pointed at itself established to 127.0.0.53 β€” perhaps this is a DNS server?

I clicked "Nathan" in the top right β€” Hey Nathan, you should log out. Please practice better OPSEC.

Nathan profile

None of these menus do anything…

Let's check the menus on the left as well just to cover bases.

Left sidebar menus

"Security Snapshot…" takes us to a place where we can download PCAP analysis. IP config β€” let's screenshot this if we need it later.

Security Snapshot / PCAP download page

Let's see if there is anything obvious β€” let's look at the view source.

Page source

Don't see anything really offhand here. But sir, please get back to Ratul β€” he's probably still eagerly waiting.

πŸ“‘

Port Scanning β€” NMAP

Next step β€” enumerate ports with NMAP.

NMAP scan NMAP results

Hmm β€” we've got FTP and SSH ports open!

Can I FTP anonymously into this?

Anonymous FTP attempt

Nope. Hm. Let's take another look at that SSH port.

SSH port inspection

It would appear that we need a public key, then we can SSH into this.

πŸ•΅οΈ

Directory Busting & IDOR Discovery

Let's try brute-forcing directories β€” let's run gobuster just to see if this allows us to see anything interesting.

Gobuster run
πŸ’‘ Key find: /capture redirects to /data/7 β€” meaning the PCAP download IDs are sequential integers. Classic IDOR setup.

Woah! /capture redirects to /data/7!

Let's try some other ones and see what we see. Here's 1:

data/1 PCAP

There's packets here! Let's download the .pcap and analyze in Wireshark.

Nothing really worth noticing β€” they're just our own HTTP traffic. Nothing exposed related to FTP.

Wireshark - own traffic

Recall my VPN is 10.10.14.14.

Hm… 1, 2, 3, 4, 5, 6, and 7 all contain my probing packets (web) β€” no screenshots but just take my word for it.

8 redirects me back to the dashboard.

How about 10.129.67.231/data/0?

data/0 PCAP

Hmm… let's download this one and look at it in Wireshark…

Oh, Nathan. You made an uh oh.

Wireshark - FTP credentials exposed
⚠️ IDOR: The /data/0 endpoint β€” accessible without authentication β€” contains a PCAP of a previous FTP session. FTP sends credentials in plaintext. GG Nathan.
🚩

User Flag β€” We Are Nathan Now

Well, now that we have this, let's go ahead and FTP in and see what Nathan sees. Please call us Nathan from now on.

FTP login as Nathan FTP contents
🚩 User flag captured. Gotcha.
πŸ’€

Privilege Escalation β€” Linux Capabilities

Now let's pwn root. Let's poke around as Nathan.

Enumeration as Nathan

Nothing really interesting here.

Linux capabilities check
πŸ’‘ Linux Capabilities: cap_setuid on the Python binary means we can call os.setuid(0) to become root β€” no sudo, no SUID bit required.

cap_setuid tells us we should be able to set our ID to 0 (root) β€” can we do that?

cap_setuid exploit

Sigh. That was a little too easy.

Root shell
πŸ’€ Root flag captured. And there we go. The box is pwned.

🎯 Takeaways

So "Cap" β€” the name β€” is for packet capture, which is exactly how we ended up pwning this box. The IDOR on /data/0 exposed a PCAP containing Nathan's FTP credentials in plaintext. FTP is unencrypted, so once that traffic is captured, it's game over. From there, a misconfigured Linux capability (cap_setuid on Python) handed us root in one line. Clean box. Great fundamentals lesson. Woo hoo! πŸŽ‰