Intercept Fitbit Aria Wi-Fi Smart Scale scale logging to local database
How to perform a MITM of Fitbit Aria Wi-Fi Smart Scale HTTP uploads to do local IoT logging.
Overview
I have my own IoT device logging system that records interesting data from various sensors, some custom
designed and others just purchased as-is. I have also done work with adding logging to devices that
are old and not designed for this, such as a
water meter and
computer vision gas meter.
For devices which log to some kind of proprietary server, I use either a (hopefully available) open API, or worst case a Linux machine running Selenium
to login to a web site, scrape the HTML, and extract the value of interest.
This has worked for many years, but then
Google decided to completely remove any web interface for Fitbit,
requiring you to use either the Android or iOS app and limiting your ability to get to the raw data.
I decided to investigate the protocol being used by my Fitbit Aria Wi-Fi Smart Scale and it turns
out that it uses unencrypted HTTP requests to communicate with its proprietary service.
The first step is to configure your local router (I'm using Ubiquiti UniFi) to redirect all DNS lookups for www.fitbit.com to a web server under your control.
The Fitbit scale needs to be on the network of the local router, but the web server can be anywhere on the Internet.
The URL requested by the Wi-Fi scale is http://www.fitbit.com/scale/upload - I have an Apache2 web server with PHP
running to handle that URL.
The PHP code reads the binary Fitbit protocol and extracts out the user id and weight, and then logs it to a custom IoT
logging service which you can customize to whatever you are using. Most importantly, the PHP code also takes the entire request
and replays it to the hard-coded IP address for www.fitbit.com so that the scale gets to communicate with the official
server and receive whatever response it would normally get. This allows the existing Fitbit app functionality to
keep working, and for the scale to know that it logged the value successfully. Without this replay support, the scale will keep
trying to upload older weight measurements forever and show a failure icon on the screen.
References
In order to understand the Fitbit binary protocol, I found this documentation quite helpful, although
I'm only parsing the bare minimum to get the weight information out and ignoring everything else:
https://github.com/micolous/helvetic/blob/master/protocol.md
https://www.hackerspace-bamberg.de/Fitbit_Aria_Wi-Fi_Smart_Scale
|