Created
January 8, 2016 17:43
-
-
Save ujj-nuvo/9fb8e25d00aa58a8cedf 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
import pcapy | |
from impacket.ImpactDecoder import * | |
from impacket.ImpactPacket import * | |
# callback for received packets | |
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 dest_ip == '0.0.0.0' and op_code == 1 and src_mac == "your dash mac here": | |
print "Hey !, It's me your Dash Button !" | |
if __name__ == "__main__": | |
max_bytes = 1024 | |
promiscuous = 0 # every data packet transmitted can be received and read by a network adapter to which its connected | |
read_timeout = 100 # in milliseconds | |
pc = pcapy.open_live("en0", max_bytes, promiscuous, read_timeout) | |
packet_limit = 10 | |
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