Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # note that this script requires tcpdump to be installed
- # additionally, it requires root privs to run.
- import sys
- import logging
- logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
- if len(sys.argv) != 2:
- print "Usage: pingarp \n eg: pingarp 192.168.1.0/24"
- sys.exit(1)
- filename = '/usr/share/nmap/nmap-mac-prefixes' # '/usr/local/share/nmap/nmap-mac-prefixes'
- vals = {}
- with open(filename) as myFile:
- for line in myFile.readlines():
- vals[line[:6]] = line[7:-1]
- from scapy.all import srp,Ether,ARP,conf, Dot11Elt
- conf.verb=0
- ans,unans=srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=sys.argv[1]),
- timeout=2)
- for snd,rcv in ans:
- val = rcv.sprintf(r"%Ether.src%").replace(":", "")[:6].upper()
- print rcv.sprintf(r"%Ether.src%, %ARP.psrc%"), "(%s)" % vals[val] if val in vals else '(Not found)'
Advertisement
Add Comment
Please, Sign In to add comment