Created
January 8, 2016 17:24
-
-
Save ujj-nuvo/bb7e040ab8cabc29541d to your computer and use it in GitHub Desktop.
This file contains 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
def recv_pkts(hdr, data): | |
packet = EthDecoder().decode(data) | |
ip_hdr = packet.child() | |
op_code = ip_hdr.get_ar_op() | |
src_mac = ip_hdr.as_hrd(ip_hdr.get_ar_sha()) | |
dest_ip = ip_hdr.as_pro(ip_hdr.get_ar_spa()) | |
print "ARP Request from Device : " + str(src_mac) | |
if __name__ == "__main__": | |
max_bytes = 1024 # number of bytes to capture per packet | |
promiscuous = False # When a data packet is transmitted in non-promiscuous mode, all the LAN devices "listen to" the data to determine if the network address included in the data packet is theirs | |
read_timeout = 100 # in milliseconds | |
pc = pcapy.open_live("en0", max_bytes, promiscuous, read_timeout) | |
packet_limit = 100 | |
pc.setfilter("arp") | |
try: | |
pc.loop(packet_limit, recv_pkts) # capture packets | |
except KeyboardInterrupt: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment