Created
March 16, 2019 22:41
-
-
Save rostegg/8efb20896aa67f47dea10a0ca7b074a1 to your computer and use it in GitHub Desktop.
Simple detecting of ARP spoofing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scapy.all import sniff, ARP | |
| import sys | |
| arp_table = {} | |
| def watch_arp(packet): | |
| if packet[ARP].op == 2: | |
| if arp_table.get(packet[ARP].psrc) == None: | |
| print ("Register new device %s:%s"%(packet[ARP].hwsrc,packet[ARP].psrc)) | |
| arp_table[packet[ARP].psrc] = packet[ARP].hwsrc | |
| elif arp_table.get(packet[ARP].psrc) and arp_table[packet[ARP].psrc] != packet[ARP].hwsrc: | |
| print("Detected spoofing, %s change his IP from %s to %s"%(packet[ARP].hwsrc, arp_table[packet[ARP].psrc],packet[ARP].psrc)) | |
| arp_table[packet[ARP].psrc] = packet[ARP].hwsrc | |
| print("Starting monitor..") | |
| # for choosing interface to sniff set: iface="iface_name" | |
| sniff(prn=watch_arp,filter="arp",store=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment