Skip to content

Instantly share code, notes, and snippets.

@sillasgonzaga
Forked from ChuckWoodraska/dash_runner.py
Created March 15, 2016 23:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sillasgonzaga/ea3fdb948a825f7867b9 to your computer and use it in GitHub Desktop.
Save sillasgonzaga/ea3fdb948a825f7867b9 to your computer and use it in GitHub Desktop.
Used to sniff traffic for Amazon dash button and play a song through my chromecast.
import time
import sys
import logging
import pychromecast
from scapy.all import *
mac_address = '00:00:00:00:00:00'
def arp_display(pkt):
if pkt[ARP].op == 1:
if pkt[ARP].hwsrc == mac_address:
if '--show-debug' in sys.argv:
logging.basicConfig(level=logging.DEBUG)
cast = pychromecast.get_chromecast(friendly_name="CHROMECAST_NAME")
while cast == None:
cast = pychromecast.get_chromecast(friendly_name="CHROMECAST_NAME")
try:
if not cast.is_idle:
print("Killing current running app")
cast.quit_app()
time.sleep(5)
except:
pass
print("Playing media")
cast.play_media(("url"), "audio/mp3")
while(True):
sniff(prn=arp_display, filter="arp", store=0, count=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment