Hacking Spanning Tree with Python, Scapy and Kali Linux (Ep 2) // STP Root Bridge attack! ๐Ÿ˜€

David Bombal ยท Beginner ยท๐Ÿ” Cybersecurity ยท4y ago

Key Takeaways

Hacks a spanning tree network using Python, Scapy, and Kali Linux

Full Transcript

this video is part of my series showing you how to hack networks using python i'm going to show you how easy it is to hack a network using a simple python script now if you enjoy these types of ethical hacking videos if you enjoy python if you enjoy ethical hacking if you enjoy networking please consider subscribing to my youtube channel please like this video and click on the bell to get notifications that really does help me with the youtube robots i'm uploading a lot of networking and hacking content to my youtube channel as well as programming content hopefully you enjoy this type of thing if you do please consider subscribing to my youtube channel once again okay let's get started [Music] this script will change the spanning tree root in a switched network in this demonstration i've got three cisco switches and some pcs that are part of my topology so in this example i've got a 3560 cx switch that's the bottom switch in this topology i've got a cisco 1000 series switch and a cisco 2960. in this example the cisco switch is the root switch i'm going to tell the switches that my kali virtual machine or kali virtual machine if you prefer is the route by sending bpdus or bridge protocol data units into the network we're basically going to capture bpdus off the network and we're going to forge them or change them to make the switches believe that we are the root in the spanning tree topology again this is a very simple script we're using scapy in this example have a look at my previous videos where i discuss escapee in more detail in this video i'm simply showing you how i can manipulate the spanning tree root using scapy and a few lines of python code so what we're going to do initially is capture the spanning tree frames of the wire we are looking for traffic going to this well-known mac address which is the mac address of spanning tree we are then going to change the source mac address the root id and the root mac to this we're setting the bridge id to this and the bridge mac to this basically i'm sending a frame back into the network saying that i am the root spanning tree elects the root bridge really important in networks it elects the root bridge based on the lowest priority and lowest mac address currently in my network if i look at the 3560 cx switch the root bridge has this priority and this mac address this switch is not the root its root port is out of gigabit zero two in other words it's pointing to the 2960. on the 2960 switch show spanning tree this switch is the root switch once again has this priority has this mac address so what i'm going to do is i'm going to announce that i have the lowest priority lowest mac address so i'll run the script just to show you what happens to do that i'm going to use kali or kali linux i'm running this in a virtual machine just makes it easier for people to follow me and makes it easier to record so let's hack the spanning tree root i'll paste the script in again it's only a few lines of code it's literally one two three four five six seven eight nine lines of code very basic script i'm gonna use sudo to give me admin privileges stp root hack dot py that's the script that i'm going to run put in my password so previously the root in the network was this now the root has a priority of zero mac address of this and the root port on the 3560 has changed from gigabit zero two to gigabit zero five looking at my topology that's the kali the virtual machine the kali pc or virtual machine has become the root of my spanning tree network it's as simple as that to change the route in a network you don't want this to happen you want to implement security mechanisms to stop this so you want to implement root guard as an example to stop this kind of nonsense happening now in this example i'm using my own equipment i'm using my own equipment here i'm not hacking someone else's network you need to learn python you need to learn networking if you want to become an ethical hacker or a network engineer this kind of stuff gives you a lot of power but only use it for good only do ethical hacking don't get into trouble okay so i had a show option here and you can see that that's what the spanning tree message looks like after i manipulated it now what i will do here is run wireshark on windows so that you can see the original messages and the forged messages so what i'll do is capture spanning tree so we can see as an example that at this point the root switch has this root identifier path cost is that type show spanning tree now notice priority is 32769 because we're adding the root identifier or root priority plus the vlan number to give us that that is the root bridge mac address but again i could simply change that in this example i'm sending one packet into the network so one packet has been sent shows spanning tree notice root has changed and if i look at wireshark you can see that here i forged the source mac address so mac address was forged i forged the root identifier and bridge identifier i basically manipulated the frame that i received off the network i received a frame changed some values and sent it back into the network to make myself the spanning tree root now in this example i'm not using a loop but i could simply use a loop here to send multiple frames into the network so i could do something like that what i'll do is add a sleep timer and i'm simply copying some code from another script this is the thing about code don't reinvent it just reuse code so what i'll do is ls nano stp root hack and what i'll do is paste that code in here and i'll remove that line so what this will do now i'll clear the screen is send bpdus into the network every second to make sure that i remain the root so on the switch show spanning tree notice the route is my kali virtual machine and the root port is pointing to cali now what you could do is send some bpd's wait a bit of time like 30 seconds so that it goes back to the original route and send some more bpds and that can really mess up networks you don't want this to happen so what we should be doing on any port that we don't trust we should type spanning tree and we have a few options here but i'll do god root and what should happen is notice root card is enabled it should protect us from these bpd's so if i type show spanning tree spanning tree election has gone back to the proper switch if i run the script what will happen is root guard will block those bpdus so if i type show spanning tree again notice the port has been blocked we are still using the proper root switch or root bridge in our topology spanning tree's been around for many years so we talk about a bridge rather than a switch so the root bridge is still the 2960 in my topology rather than cali we have stopped this nonsense you could also filter bpdus or do other things to protect your network now in ccna courses they often tell you about this but i want you to see how easy it is to use python to hack networks a few lines of code here and you could break a network okay so hopefully you learned something i've shown you now how to use a simple python script to hack networks you need to enable security on your networks but you should learn python because it gives you a lot of power now once again if you enjoyed this video please like it please subscribe to my youtube channel and click on the bell to get notifications i'm david bomble want to wish you all the very best [Music] oh

Original Description

It's just too easy to hack badly configured networks. You need to learn to code! Learn Python. Learn Networking. You are going to be very powerful and very scary if you combine knowledge of networking with Python scripting! But, do good. In this video I'll show you why you need to configure networks properly to avoid spanning tree and other protocol manipulation using simple Python scripts. Learn to code. Learn Linux. Learn Kali Linux. Menu: You need to learn Python! 0:00 Network Topology: 0:50 Scapy: 1:35 Python Script overview: 1:51 Spanning Tree Root Election: 2:14 Current Spanning Tree network: 2:30 Script demo: 3:01 Results of attack: 3:53 You want to implement root guard: 4:21 Wireshark captures: 4:53 Use a Python loop: 6:27 Nasty, nasty thing to do: 7:24 How to protect the network: 7:37 Result of spanning tree root guard: 8:17 CCNA courses often don't show this: 8:50 ====== Scripts: ====== All scapy scripts here: https://davidbombal.wiki/githubscapy Scapy Spanning Tree Root attack: https://davidbombal.wiki/scapystproot Playlist: https://davidbombal.wiki/scapy ============== Scapy Resources: ============== Website: https://scapy.net/ Documentation: https://scapy.readthedocs.io/en/latest/ ================ Connect with me: ================ Discord: https://discord.com/invite/usKSyzb Twitter: https://www.twitter.com/davidbombal Instagram: https://www.instagram.com/davidbombal LinkedIn: https://www.linkedin.com/in/davidbombal Facebook: https://www.facebook.com/davidbombal.co TikTok: http://tiktok.com/@davidbombal YouTube: https://www.youtube.com/davidbombal python scapy ccna ccnp python scapy spanning tree spanning tree root stp root stp root guard spanning tree root guard ccna 200-301 root guard spanning tree python scripts kali linux linux kali cisco kali linux 2021.2 kali linux 2021 vmware vmware kali kali linux install oscp ceh security+ pentest+ Please note that links listed may be affiliate links and provide me with a small percentage/kickback s
Watch on YouTube โ†— (saves to browser)
Sign in to unlock AI tutor explanation ยท โšก30

Playlist

Uploads from David Bombal ยท David Bombal ยท 0 of 60

โ† Previous Next โ†’
1 RYU SDN Controller Part 4: Graphical User Interface (GUI): Practical GNS3 SDN and OpenFlow
RYU SDN Controller Part 4: Graphical User Interface (GUI): Practical GNS3 SDN and OpenFlow
David Bombal
2 HPE Network Protector SDN Application Part 1 - Introduction
HPE Network Protector SDN Application Part 1 - Introduction
David Bombal
3 HPE Network Protector SDN Application Part 2 : DNS Interception using OpenFlow
HPE Network Protector SDN Application Part 2 : DNS Interception using OpenFlow
David Bombal
4 HPE Network Protector SDN Application Part 3 - Lab Setup using Physical Switches
HPE Network Protector SDN Application Part 3 - Lab Setup using Physical Switches
David Bombal
5 HPE Network Protector SDN Application Part 4 - Demo of malicious websites blocked
HPE Network Protector SDN Application Part 4 - Demo of malicious websites blocked
David Bombal
6 HPE Network Protector SDN Application Part 5 - Demo OpenFlow table interception flows
HPE Network Protector SDN Application Part 5 - Demo OpenFlow table interception flows
David Bombal
7 HPE Network Protector SDN Application Part 6 - Demo of Physical Switch configuration
HPE Network Protector SDN Application Part 6 - Demo of Physical Switch configuration
David Bombal
8 HPE Network Protector SDN Application Part 7 - Demo Service Insertion Tunnel / GRE Tunnel
HPE Network Protector SDN Application Part 7 - Demo Service Insertion Tunnel / GRE Tunnel
David Bombal
9 HPE Network Protector SDN Application Part 8 - Demo SDN OpenFlow Reporting
HPE Network Protector SDN Application Part 8 - Demo SDN OpenFlow Reporting
David Bombal
10 HPE Network Protector SDN Application Part 9 - Demo switches interception of DNS traffic
HPE Network Protector SDN Application Part 9 - Demo switches interception of DNS traffic
David Bombal
11 GNS3 Talks: GNS3 version 1.5.X Appliance Tips
GNS3 Talks: GNS3 version 1.5.X Appliance Tips
David Bombal
12 CCNA 200-125 Exam: AAA demo: TACACS+ with GNS3
CCNA 200-125 Exam: AAA demo: TACACS+ with GNS3
David Bombal
13 GNS3 2.0.0 beta 2 install
GNS3 2.0.0 beta 2 install
David Bombal
14 CCNA #012: Learn SNMP with GNS3, Wireshark and Solarwinds NPM - CCNA 200-125 exam
CCNA #012: Learn SNMP with GNS3, Wireshark and Solarwinds NPM - CCNA 200-125 exam
David Bombal
15 CCNA #013: Spanning Tree CCNA Exam Questions: Know the answer? CCNA 200-125 exam
CCNA #013: Spanning Tree CCNA Exam Questions: Know the answer? CCNA 200-125 exam
David Bombal
16 GNS3 2.0.0 beta : GNS3 VM integration with GNS3 GUI
GNS3 2.0.0 beta : GNS3 VM integration with GNS3 GUI
David Bombal
17 CCNA #018: Routing exam questions: Who wins? OSPF, EIGRP or RIP? Sure? CCNA 200-125 exam
CCNA #018: Routing exam questions: Who wins? OSPF, EIGRP or RIP? Sure? CCNA 200-125 exam
David Bombal
18 CCNA #019: Spanning Tree CCNA Exam Questions: Root Bridge, Root Port and more: CCNA 200-125 exam
CCNA #019: Spanning Tree CCNA Exam Questions: Root Bridge, Root Port and more: CCNA 200-125 exam
David Bombal
19 GNS3 Download, installation and configuration - GNS3 1.5.3 and Windows 10
GNS3 Download, installation and configuration - GNS3 1.5.3 and Windows 10
David Bombal
20 CCNA #023 EIGRP Neighbor Troubleshooting (DUAL Issues) for the CCNA 200-125 Exam
CCNA #023 EIGRP Neighbor Troubleshooting (DUAL Issues) for the CCNA 200-125 Exam
David Bombal
21 GNS3 2.0 Architecture and schema Part 1: What is the GNS3 Controller?
GNS3 2.0 Architecture and schema Part 1: What is the GNS3 Controller?
David Bombal
22 GNS3 2.0 Architecture and schema Part 2: Emulators and virtualization
GNS3 2.0 Architecture and schema Part 2: Emulators and virtualization
David Bombal
23 CCNA #028 VTP Troubleshooting for the CCNA 200-125 Exam
CCNA #028 VTP Troubleshooting for the CCNA 200-125 Exam
David Bombal
24 CCNA #029 VTP & DTP Troubleshooting for the CCNA 200-125 Exam
CCNA #029 VTP & DTP Troubleshooting for the CCNA 200-125 Exam
David Bombal
25 CCNA #030 VTP Troubleshooting for the CCNA 200-125 Exam
CCNA #030 VTP Troubleshooting for the CCNA 200-125 Exam
David Bombal
26 GNS3 : How to download Cisco IOS images and VIRL images. Which is the best? How do you get them?
GNS3 : How to download Cisco IOS images and VIRL images. Which is the best? How do you get them?
David Bombal
27 GNS3 ASA setup: Import and configure Cisco ASAv with GNS3
GNS3 ASA setup: Import and configure Cisco ASAv with GNS3
David Bombal
28 GNS3 switching setup and options: Cisco and other switching options in GNS3
GNS3 switching setup and options: Cisco and other switching options in GNS3
David Bombal
29 GNS3 switching setup and options Part 2: GNS3 unmanaged built-in switch
GNS3 switching setup and options Part 2: GNS3 unmanaged built-in switch
David Bombal
30 GNS3 switching setup and options Part 3: Router on a sick with GNS3 unmanaged built-in switch
GNS3 switching setup and options Part 3: Router on a sick with GNS3 unmanaged built-in switch
David Bombal
31 GNS3 switching setup and options Part 4: Etherswitch Router for Cisco Dynamips Part 1
GNS3 switching setup and options Part 4: Etherswitch Router for Cisco Dynamips Part 1
David Bombal
32 GNS3 switching setup and options Part 5: Etherswitch Router for Cisco Dynamips Part 2
GNS3 switching setup and options Part 5: Etherswitch Router for Cisco Dynamips Part 2
David Bombal
33 GNS3 switching setup and options Part 6: Etherswitch, Wireshark, 802.1Q, InterVLAN routing
GNS3 switching setup and options Part 6: Etherswitch, Wireshark, 802.1Q, InterVLAN routing
David Bombal
34 GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 1: GNS3 Switching Part 7
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 1: GNS3 Switching Part 7
David Bombal
35 GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 2: GNS3 Switching Part 8
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 2: GNS3 Switching Part 8
David Bombal
36 GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 3: GNS3 Switching Part 9
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 3: GNS3 Switching Part 9
David Bombal
37 GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 4: GNS3 Switching Part 10
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 4: GNS3 Switching Part 10
David Bombal
38 GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 5: GNS3 Switching Part 11
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 5: GNS3 Switching Part 11
David Bombal
39 GNS3 Nexus (NX-OSv) switch setup and configuration Part 1: GNS3 switching options Part 12
GNS3 Nexus (NX-OSv) switch setup and configuration Part 1: GNS3 switching options Part 12
David Bombal
40 GNS3 Nexus (NX-OSv) switch setup and configuration Part 2: GNS3 switching options Part 13
GNS3 Nexus (NX-OSv) switch setup and configuration Part 2: GNS3 switching options Part 13
David Bombal
41 GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 6: GNS3 Switching Part 14
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 6: GNS3 Switching Part 14
David Bombal
42 GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 7: GNS3 Switching Part 15
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 7: GNS3 Switching Part 15
David Bombal
43 GNS3 Cisco CSR 1000v setup and configuration Part 1: GNS3 NFV
GNS3 Cisco CSR 1000v setup and configuration Part 1: GNS3 NFV
David Bombal
44 GNS3 Cisco CSR 1000v setup and configuration Part 2: GNS3 NFV
GNS3 Cisco CSR 1000v setup and configuration Part 2: GNS3 NFV
David Bombal
45 GNS3 Talks: Use the NAT node to connect GNS3 to the Internet easily!
GNS3 Talks: Use the NAT node to connect GNS3 to the Internet easily!
David Bombal
46 GNS3 Talks: GNS3 2.0 RC1 is now available
GNS3 Talks: GNS3 2.0 RC1 is now available
David Bombal
47 GNS3 Talks: GNS3 2.0 Portable Projects - easily export and import GNS3 projects
GNS3 Talks: GNS3 2.0 Portable Projects - easily export and import GNS3 projects
David Bombal
48 GNS3 Talks: Multiple clients sharing projects in real time, plus console session shadowing!
GNS3 Talks: Multiple clients sharing projects in real time, plus console session shadowing!
David Bombal
49 CCNA #035 NAT Troubleshooting Scenario 1 - Can you find the issue? CCNA Exam 200-125 troubleshooting
CCNA #035 NAT Troubleshooting Scenario 1 - Can you find the issue? CCNA Exam 200-125 troubleshooting
David Bombal
50 CCNA #036 NAT Troubleshooting Scenario 2 - Can you find the issue? CCNA Exam 200-125 troubleshooting
CCNA #036 NAT Troubleshooting Scenario 2 - Can you find the issue? CCNA Exam 200-125 troubleshooting
David Bombal
51 GNS3 Talks: ESXi, GNS3 VM and KVM support Part 1: leverage servers and the cloud
GNS3 Talks: ESXi, GNS3 VM and KVM support Part 1: leverage servers and the cloud
David Bombal
52 CCNA #037 OSPF Troubleshooting - can you find the issue? CCNA Exam 200-125 troubleshooting
CCNA #037 OSPF Troubleshooting - can you find the issue? CCNA Exam 200-125 troubleshooting
David Bombal
53 GNS3 Talks: ESXi, GNS3 VM and KVM support Part 2:  leverage servers and the cloud
GNS3 Talks: ESXi, GNS3 VM and KVM support Part 2: leverage servers and the cloud
David Bombal
54 CCNA #038 NAT Troubleshooting Scenario 3 - Can you find the issue? CCNA Exam 200-125 troubleshooting
CCNA #038 NAT Troubleshooting Scenario 3 - Can you find the issue? CCNA Exam 200-125 troubleshooting
David Bombal
55 CCNA #039 - OSPF DR, BR and DROTHER Election - do you know the answers?
CCNA #039 - OSPF DR, BR and DROTHER Election - do you know the answers?
David Bombal
56 CCNA #040 NAT Troubleshooting Scenario 4 - Can you find the issue? CCNA Exam 200-125 troubleshooting
CCNA #040 NAT Troubleshooting Scenario 4 - Can you find the issue? CCNA Exam 200-125 troubleshooting
David Bombal
57 GNS3 Talks: Arista vEOS GNS3 import and configuration Part 1
GNS3 Talks: Arista vEOS GNS3 import and configuration Part 1
David Bombal
58 CCNA #041 - OSPF DR, BR and DROTHER Election - do you know the answers?
CCNA #041 - OSPF DR, BR and DROTHER Election - do you know the answers?
David Bombal
59 GNS3 Talks: Arista vEOS GNS3 import and configuration Part 2
GNS3 Talks: Arista vEOS GNS3 import and configuration Part 2
David Bombal
60 GNS3 Talks: ipterm: Linux, Docker, Python, SDN and more! Part 1
GNS3 Talks: ipterm: Linux, Docker, Python, SDN and more! Part 1
David Bombal

Related Reads

๐Ÿ“ฐ
Secured MCP Complete Guide: OWASP Top 10, Best Practices, Security Guardrails, and Compliance
Secure your MCP with OWASP Top 10, best practices, and compliance using a practical reference architecture
Medium ยท AI
๐Ÿ“ฐ
Whose ASN Goes on Your Leased IPv4 Prefix?
Learn how to handle ASN for leased IPv4 prefixes in BGP routing
Dev.to ยท Artem Kohanevich
๐Ÿ“ฐ
Blank Identifier: Idiomatic Go or Vulnerability Trap?
Learn how blank identifiers in Go can be either idiomatic code or a vulnerability trap and why it matters for cybersecurity
Medium ยท Cybersecurity
๐Ÿ“ฐ
Kinetix Browser Review: The Ultimate Solution for Fast, Secure, and Private Web Surfing
Discover how Kinetix Browser provides fast, secure, and private web surfing using machine learning, and why it matters for online security
Medium ยท Machine Learning
Up next
OpenAI GPT 5 5 Cyber Just Got an Upgrade โ€“ Is it BETTER Than Mythos 5 ?
MaxonShire
Watch โ†’