Skip to content

Instantly share code, notes, and snippets.

@mohclips
Created March 18, 2018 16:18
Show Gist options
  • Save mohclips/1379300636d577f7b3f423b13a230ee1 to your computer and use it in GitHub Desktop.
Save mohclips/1379300636d577f7b3f423b13a230ee1 to your computer and use it in GitHub Desktop.
Search for Amazon Dash Button presses...
#!/usr/bin/python2.7
from scapy.all import *
FILTER='ether dst ff:ff:ff:ff:ff:ff'
def go_cat_go():
print "Go Cat dash button pressed"
def boldly_go():
print "Bold dash button pressed"
def parse(pkt):
# define our button macs and functions to run
# must define them after the actual function defs
dash_buttons = {
'fc:65:de:ed:36:91': go_cat_go,
'fe:65:de:ed:36:91': boldly_go,
}
if isinstance(pkt.payload, LLC):
# bit of debug if you want
#pkt.show()
###[ 802.3 ]###
# dst= ff:ff:ff:ff:ff:ff <<<< broadcast
# src= fc:65:de:ed:36:91 <<<< our button
# len= 6
###[ LLC ]###
# dsap= 0x0
# ssap= 0x1
# ctrl= 175
###[ Raw ]###
# load= '\x81\x01\x02' <<<< interesting stuff
# one packet == one push
if pkt.payload.dsap == 0 \
and pkt.payload.ssap == 1 \
and pkt.payload.ctrl == 175 \
and pkt.dst == 'ff:ff:ff:ff:ff:ff' \
and pkt.getlayer(Raw).load == '\x81\x01\x02': # this is the fancy Amazon packet!
this_button = pkt.src
func = dash_buttons.get(this_button, lambda: "nothing")
# Execute the function
return func()
if os.geteuid() != 0:
print("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'. Exiting.")
exit(1)
print "Running... CTRL+C to quit"
# set count=0 to run for ever
print sniff(prn=parse, filter=FILTER, store=0, count=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment