arp sniff.py

From Noah.org
Revision as of 04:23, 20 February 2016 by Root (Talk | contribs) (Created page with 'Category: Engineering <pre> #!/usr/bin/env python # See rfc5227 from scapy.all import * import scapy.all def arp_dump(pkt): # print pkt.summary() if pkt[ARP].hwdst…')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


#!/usr/bin/env python

# See rfc5227

from scapy.all import *
import scapy.all

def arp_dump(pkt):
#    print pkt.summary()
    if pkt[ARP].hwdst='ff:ff:ff:ff:ff:ff' and pkt[ARP].psrc == pkt[ARP].pdst:
        print('gratuitous ARP')
        return

    if pkt[ARP].op==1: # opcode: request
        if pkt[ARP].psrc=='0.0.0.0':  # source IP used for ARP Probe
            print('ARP Probe from: ' + pkt[ARP].hwsrc)
        

# Look for ARP packets (type 0x0806)
#print(scapy.all.sniff(iface='en0', filter="arp", prn=arp_dump, , store=0, count=10))
print (scapy.all.sniff(iface='en0', filter="arp", prn=arp_dump))