> 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/de/writeups-ctf/hackthebox/linux-easy/cap-hackthebox-writeup.md).

# Cap HackTheBox Writeup

Writeup zur HackTheBox-Easy-Linux-Maschine Cap mit Abdeckung von unsicherer Directory-Object-Reference (IDOR), Informationsleck, Missbrauch von Fähigkeiten (Python3.8) (Privilegieneskalation), mit praktischer Enumeration,

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

{% hint style="warning" %}
Fähigkeiten:

* Unsichere Verzeichnisobjekt-Referenz (IDOR)
* Informationsleck
* Ausnutzen von Capabilities (Python3.8) (Privilegieneskalation)
  {% endhint %}

## Aufklärung

**Arbeitsbereich einrichten:**

Richte den Arbeitsbereich ein, indem du drei Ordner erstellst, um wichtige Inhalte, Exploits und Nmap-Aufklärungsergebnisse zu speichern.

<figure><img src="https://2955439919-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-Verbindungsprüfung**

Überprüfe die VPN-Verbindung, um eine stabile Kommunikation mit dem Zielrechner sicherzustellen.

<figure><img src="https://2955439919-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>

**Offene Ports mit Nmap erkennen:**

Enumeriere die offenen Ports und exportiere die Ergebnisse in die Datei "allPorts" im Nmap-Verzeichnis:

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

<figure><img src="https://2955439919-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>

**Analyse offener Ports mit extractPorts:**

Verwende die Funktion extractPorts, um offene Ports in einem knappen Format anzuzeigen und sie in die Zwischenablage zu kopieren (21,22,80)

<figure><img src="https://2955439919-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-Versionsscan mit Nmap:

Verwende Nmap, um die Dienstversionen zu scannen und die Ausgabe in der Datei "targeted" zu speichern:

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

<figure><img src="https://2955439919-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://2955439919-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>

Wir greifen auf den HTTP-Dienst zu und entdecken einen Abschnitt namens **Sicherheits-Snapshot**. Dieser Abschnitt ermöglicht es, **pcap** Dateien mit Systemprotokollen zu erstellen und herunterzuladen.

<figure><img src="https://2955439919-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>

## IDOR-Schwachstelle

**Erste Beobachtung**

Nach der Analyse der **pcap** Dateien mit Wireshark wurde kein direkt nutzbarer Inhalt gefunden.

<figure><img src="https://2955439919-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>

Allerdings stellen wir fest, dass jedes Mal, wenn eine Datei heruntergeladen wird, ein **Snapshot** erstellt wird. Die entsprechende URL enthält einen Parameter, der die Snapshot-ID angibt, zum Beispiel: `snapshot_data=2`.

<figure><img src="https://2955439919-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>

Durch das manuelle Ändern des URL-Parameters, um auf Snapshot 0 zuzugreifen, erhalten wir eine Datei mit sensiblen Informationen.

### **Analyse mit Wireshark**

Durch das Untersuchen der Frames in der **pcap** Datei identifizieren wir die Anmeldedaten eines Benutzers:

* Benutzername: `nathan`
* Passwort: `Buck3tH4TF0RM3!`

<figure><img src="https://2955439919-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>

#### Verwendung der Anmeldedaten

**FTP-Zugriff**

Wir verwenden die Anmeldedaten, um eine Verbindung zum FTP-Dienst herzustellen:

Verbindung erfolgreich. Wir erhalten die **user.txt** Datei, die die erste Flagge enthält.

<figure><img src="https://2955439919-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-Zugriff**

Durch das Testen derselben Anmeldedaten für eine SSH-Verbindung erhalten wir vollen Zugriff:

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

<figure><img src="https://2955439919-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>

## Privilegieneskalation

### Schwachstelle Capabilities Python3.8

#### Filterung **Capabilities**:

Wenn wir nach Capabilities filtern, erscheint Python 3.8:

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

<figure><img src="https://2955439919-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>

Verwenden Sie [GTFOBins](https://gtfobins.github.io/) als Referenz.

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

<figure><img src="https://2955439919-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>

### root.txt-Flagge :)

<figure><img src="https://2955439919-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://2955439919-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/de/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.
