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

# Compte rendu HackTheBox de Cap

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

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

* Référence directe à un objet de répertoire non sécurisée (IDOR)
* Fuite d'informations
* Exploitation des capacités (Python3.8) (é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="/files/dd8781f9acdd334633bbe1982a6a17966ee650ef" 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/dc1b552d903d1f1a22229e244fd9912cdddcc38b" alt="" width="563"><figcaption></figcaption></figure>

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

Énumérez les ports ouverts et exportez les résultats dans le fichier "allPorts" du répertoire Nmap :

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

<figure><img src="/files/40e05750dfccd0209e1f2120a39ded257c0ee2ec" alt=""><figcaption></figcaption></figure>

**Analyse des ports ouverts avec extractPorts :**

Utilisez la fonction extractPorts pour afficher les ports ouverts dans un format concis et les copier dans le presse-papiers (21,22,80)

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

#### Analyse des versions des ports avec Nmap :

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

```bash
nmap -sCV -p21,22,80 10.10.10.245 -oN targeted
```

<figure><img src="/files/0d3d646760401c80f56eefd0adc02566f09406de" alt=""><figcaption></figcaption></figure>

### Port 80 - HTTP

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

Nous accédons au service HTTP et découvrons une section appelée **Instantané de sécurité**. Cette section permet de créer et de télécharger **pcap** des fichiers contenant les journaux système.

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

## Vulnérabilité IDOR

**Observation initiale**

Après avoir analysé les **pcap** fichiers avec Wireshark, aucun contenu directement exploitable n'a été trouvé.

<figure><img src="/files/202f2a7e465719dca339e62231c65497a3e7a7af" alt=""><figcaption></figcaption></figure>

Cependant, nous remarquons que chaque fois qu'un fichier est téléchargé, un **instantané** est créé. L'URL correspondante contient un paramètre indiquant l'identifiant de l'instantané, par exemple : `snapshot_data=2`.

<figure><img src="/files/89865dba3f9eae338315dc28c8a84b614b20e06f" alt=""><figcaption></figcaption></figure>

En modifiant manuellement le paramètre de l'URL pour accéder à l'instantané 0, nous obtenons un fichier contenant des informations sensibles.

### **Analyse avec Wireshark**

En examinant les trames dans le **pcap** fichier, nous identifions les identifiants d'un utilisateur :

* nom d'utilisateur : `nathan`
* mot de passe : `Buck3tH4TF0RM3!`

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

#### Utilisation des identifiants

**Accès FTP**

Nous utilisons les identifiants pour nous connecter au service FTP :

Connexion réussie. Nous récupérons le **user.txt** fichier contenant le premier drapeau.

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

**Accès SSH**

En testant les mêmes identifiants pour une connexion SSH, nous obtenons un accès complet :

```bash
ssh nathan@10.10.10.245
Buck3tH4TF0RM3!
```

<figure><img src="/files/0696745415fee962b2f2f53f89ae56d50701bc81" alt=""><figcaption></figcaption></figure>

## Élévation de privilèges

### Vulnérabilité des capacités Python3.8

#### Filtrage **capacités**:

Si nous filtrons par les capacités, Python 3.8 apparaît :

```bash
getcap -r / 2>/dev/null
```

<figure><img src="/files/9fd3a3d785229da17bf2c249fffad9a84fc973a0" alt="" width="554"><figcaption></figcaption></figure>

Utilisez [GTFOBins](https://gtfobins.github.io/) comme référence.

```bash
python3.8 -c 'import os; os.setuid(0); os.system("/bin/sh")'
```

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

### Drapeau root.txt :)

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

<figure><img src="/files/177328f073133a523850aacae835a8e25358872d" alt="" width="482"><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-easy/cap-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.
