Hack the Amazon Dash Button (JK29LP) on macOS Sierra
I recently purchased the $5 Amazon Dash Button to use as a doorbell for my Facial Recognition doorbell project. Initially, I thought it would be a seamless process, however, such was not the case. Especially with the new JK29LP model.
It took some time to figure out the best way to get the button working on macOS and for that reason I want to share how to set it up without any hiccups.
The Amazon Dash Button is a $5 IoT device that you can use to purchase specific items from Amazon. The way it works is that you stick the button around your house and use it whenever you are running low on something. Press the button and the item will be ordered through your Amazon account.
It’s able to do this by using your Wi-Fi. Each time you press the button, the device connects to your Wi-Fi and sends a request to order the item. Our intention here is to intercept this request and trigger an event specified by us on each button press.
Dash Button Setup
Before we setup the button we need to get its MAC address. There are a few ways to do this but the easiest way is to put the device into config mode.
- Hold the button for about 6 seconds until the device goes into config mode.
- The device will now start broadcasting a wireless network with the SSID ‘Amazon ConfigureMe’.
- Connect to this network on your Mac, open a browser, and go to http://192.168.0.1 You’ll see the following:
Now we can start the setup process:
- Download the Amazon app.
- Go to Your Account > Dash Buttons & Devices
- Set up the Dash button through the app so it connects to your network.
- Quit the app right when the product selection page shows up. Without selecting a product!!
You do not want to select a product when setting up the device. This way, the dash button will not order an item when we press it and your house won’t be full of toilet paper or Nerf darts.
Once you are done with the dash button we need to move onto the computer.
This is where some difficulties may arise. The way we are going to detect button presses is pretty interesting. We will sniff packets on our network using a packet manipulation library called Scapy in Python, and whenever we see the Dash button we will execute our own event. Unlike the old buttons that would do an ARP request from source IP “0.0.0.0”, the new ones send out a DHCP request prior to that. This is why a lot of the scripts online at the moment don’t work for the new buttons. On the other hand, Scapy does not work natively on macOS which causes some difficulties for people. This can be addressed by installing certain Python bindings.
You need to have Homebrew and you should also be using virtual environments. I suggest reading Use Python Effectively on OS X if you don’t have those setup already. I am using Python 2.7.13.
Open up terminal and run these commands
⇒ pip install scapy
brew install --with-python libdnet
It’s possible that Python will not recognize modules installed by Homebrew. If that’s the case, Homebrew will let you know and you can just run the commands it suggests.
Everything is set up now and you should be able to run Scapy.
Here is the script I use to detect button presses. There are other ways but this works well for me and is quite short. Suggestions are welcome!
Run that script. You will probably have to run it as sudo. Once running, press the button and you should see “Button Press Detected” printed on your terminal.
The dash button is an amazing device. The application possibilities are endless. Here are some interesting examples.
As mentioned earlier, I will be using it to make a face recognizing doorbell, that will recognize my Facebook friends and send a text notification with their name.
I’ll be writing about that project in the next few weeks.