> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/writeups-ctf/hackthebox/linux-easy/cap-hackthebox-writeup.md).

# Cap HackTheBox Writeup

Cap HackTheBox Easy Linux machine writeup covering Insecure Directory Object Reference (IDOR), Information Leakage, Abusing Capabilities (Python3.8) (Privilege Escalation), with practical enumeration,

{% embed url="<https://app.hackthebox.com/machines/Cap>" %}

{% hint style="warning" %}
Skills:

* Insecure Directory Object Reference (IDOR)
* Information Leakage
* Abusing Capabilities (Python3.8) (Privilege Escalation)
  {% endhint %}

## Reconnaissance

**Workspace Setup:**

Set up the workspace by creating three folders to store important content, exploits, and Nmap reconnaissance results.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a81481797c9cbfb49c64290bc93ab8fedf2eceb1%2Fimage%20(2635).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**VPN Connectivity Check**

Check VPN connectivity to ensure stable communication with the target machine.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-30fc5efd2317beac0cfc470d6e18975a3d27f37c%2Fimage%20(2636).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Open Port Discovery with Nmap:**

Enumerate open ports and export the results to the "allPorts" file in the Nmap directory:

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 10.10.10.245 -oG allPorts
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-79e3352513d33ba3c2a142182fe15ba7fd346f4a%2Fimage%20(2638).png?alt=media" alt=""><figcaption></figcaption></figure>

**Open Port Analysis with extractPorts:**

Use the extractPorts function to display open ports in a concise format and copy them to the clipboard (21,22,80)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-248bf1b07e402920b8325d1ce2692ecdabba5b9f%2Fimage%20(2639).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Port version scan with Nmap:

Use Nmap to scan service versions and save the output in the "targeted" file:

```bash
nmap -sCV -p21,22,80 10.10.10.245 -oN targeted
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-950bd7105fe6918ac95f9dac366bd9ec40d0743d%2Fimage%20(2640).png?alt=media" alt=""><figcaption></figcaption></figure>

### Port 80 - HTTP

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b687bf80aff374dd5d30c0736240f95d1267c1e1%2Fimage%20(2641).png?alt=media" alt=""><figcaption></figcaption></figure>

We access the HTTP service and discover a section called **Security Snapshot**. This section allows you to create and download **pcap** files containing system logs.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-538cb659cef2515765883ad88ae6557815f78b1f%2Fimage%20(2642).png?alt=media" alt=""><figcaption></figcaption></figure>

## Vulnerability IDOR

**Observation initiale**

After analyzing the **pcap** files with Wireshark, no directly usable content was found.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-366857723403f9653b98241ebd2c2c942f1dd336%2Fimage%20(2643).png?alt=media" alt=""><figcaption></figcaption></figure>

However, we notice that each time a file is downloaded, a **snapshot** is created. The corresponding URL contains a parameter indicating the snapshot identifier, for example: `snapshot_data=2`.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-277543f6f9ca2539096e794fd9d5e7ab52854cdd%2Fimage%20(2644).png?alt=media" alt=""><figcaption></figcaption></figure>

By manually changing the URL parameter to access snapshot 0, we obtain a file containing sensitive information.

### **Analysis with Wireshark**

By examining the frames in the **pcap** file, we identify a user's credentials:

* username: `nathan`
* password: `Buck3tH4TF0RM3!`

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b4320d63bef95cbbcd57fac04cb2412e101b40db%2Fimage%20(2645).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Use of credentials

**FTP access**

We use credentials to connect to the FTP service:

Connection successful. We retrieve the **user.txt** file containing the first flag.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d46cb04e7cbead8649d5bc757c1130b8da1756d9%2Fimage%20(2646).png?alt=media" alt=""><figcaption></figcaption></figure>

**SSH access**

By testing the same credentials for an SSH connection, we obtain full access:

```bash
ssh nathan@10.10.10.245
Buck3tH4TF0RM3!
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df05d0c320ff6033f8a0dab9102721ae5953ceb3%2Fimage%20(2647).png?alt=media" alt=""><figcaption></figcaption></figure>

## Privilege Escalation

### Vulnerability Capabilites Python3.8

#### Filtering **capabilities**:

If we filter by capabilities, Python 3.8 appears:

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

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bad265b20ed751399b0407a02b119c26920f019a%2Fimage%20(890).png?alt=media" alt="" width="554"><figcaption></figcaption></figure>

Use [GTFOBins](https://gtfobins.github.io/) as a reference.

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

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-634dcad12e29296cc5b5e81aa1a1c440ce70709e%2Fimage%20(891).png?alt=media" alt=""><figcaption></figcaption></figure>

### Flag root.txt :)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-aa4e8bc4f48dc5657804fd3bbeeb59fe60e7526d%2Fimage%20(892).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ecc4d94682f76c14c22c6861e1e64a264a784df7%2Fimage%20(893).png?alt=media" alt="" width="482"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/writeups-ctf/hackthebox/linux-easy/cap-hackthebox-writeup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
