What I had to do to get the Amazon Dash Hack to work on Windows

A few weeks back Ted Benson published a great article on hacking the Amazon Dash button to track baby events. Like many other developers and tinkerers, I joyfully purchased an Amazon Dash button, two in-fact, so that I could also partake in the pleasure of subverting this cool WiFi button for my own random musings.

Scapy was not meant for Windows

I followed along with Ted, copying and pasting his example code into Sublime, and getting a copy of scapy so that it would work. When I ran it, it failed to run because it required a package named dnet. The dnet package is not easy to install. It’s best to build it from source, which means that I downloaded and installed the WinPcap library, and the WinPcap Devleopment Pack. Then to actually build it I had to get the right version of the visual studio developer tools to build the packages for my version of Python. Don’t forget to run the build from the newly installed visual c++ 2008 command prompt.

Throw in some more dependencies, build errors and frustrations. Argh!!!

“F#@$% you Jobu, I do it myself”

(Major League — video)

I will not back down

When things aren’t going your way, look for another path. I haven’t worked on socket-level code since 2011, so I was a bit rusty with things, but I did manage to get it going.

  1. Download this very excellent winpcapy project from github and place it in a folder named AmazonDash/winpcapy
  2. Copy and paste the following gist into AmazonDash/dash.py
  3. Profit

Run the following command: python dash.py. That’s it. When you press the button on your dash, you’ll get a printout of its mac address with the text “unknown device”. Once you know the mac address, update the dash_macs dictionary at the top of the file to include yours (you can also replace/remove the example Tide button’s mac address).

We did it!

Now that the script knows how to find your dash button, you can update the dash_button_press() function to do something cool with it. Since we use Mercurial for source control at my workplace, I’m constantly pushing code up to the server. I always hear this song in my head when I do so… try it :)

Comments and Attributions

You do need to install WinPcap, but not the dev tools, for this to work. This is how winpcapy is able to talk to the network drivers in Windows.

To exit the script hit ctrl + break.

This post by Dillon Buchanan helped me understand how to read the incoming network packets with python. The ARP Wiki page was instrumental in understanding the ARP structure. The winpcapy module by Or Weis, based on Massimo Ciani’s WinPcapy is doing most of the work here, and of course, thank you Ted Benson for showing us how get started with this nifty device!