Gadgetbridge: Mi Band 4 Auth Key (sqlite3)

Created on 27 Sep 2019  路  2Comments  路  Source: Freeyourgadget/Gadgetbridge

Before requesting a new feature, please confirm the following:
I have read the wiki, and I didn't find a solution to my problem / an answer to my question.
I have searched the issues, and I didn't find a solution to my problem / an answer to my question.
If you upload an image or other content, please make sure you have read and understood the github policies and terms of services

Your issue is:
I am out of my depth, so excuse me if this seems an unreasonable question to ask or if this is the wrong place to ask just delete this. I've searched for hours and tried a lot of commands, I am trying to obtain my MB4 auth key, I've searched and searched but the terminal command keeps failing. There is a screenshot in one of the other issues of someone extracting their auth key, and as far as I can tell, I am doing it exactly as they were only with my DB name, and it's failing

What I'm doing.

  • With file explorer navigating to
    /data/data/com.xiaomi.hm.health/databases/
    -There are 3 different origin_db files, one which ends in "1", one that ends with -shm, and one that ends with -wal
  • my database name which looks like
    origin_db_5b860cd35909327f13f3683d07ac3fb1 (I replaced a few of those numbers just incase that is sensitive info)
  • Open Termux
  • Type su
  • Type sqlite3 /data/data/com.xiaomi.hm.health/databases/origin_db_5b860cd35909327f13f3683d07ac3fb1 "select AUTHKEY from DEVICE"

at which point I get the response
system/bin/sh: sqlite3: not found

If I only type "sqlite3" and hit enter the response is:
SQLite version 3.29.0 2019-07-10 17:32:03
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite>

If I then try to enter the command from the wiki with my database name, I just continually get the response
...>

If I try to enter the command without typing su, I get
Error: Unable to open database

Is there something else I need to download? Any help would be super appreciated. I really don't want to have to use the anonymous random Chinese app to get my auth key.

Your wearable device is:
Mi Band 4

Phone is:
Moto g6, Android Pie, Magisk 19.3

Most helpful comment

@Pg214
I would not use termux since it is more than a terminal, it is more like a linux userspace tool distribution.

I would connect the phone with usb and use adb shell, then type su and do your sqlite3 stuff.
There are many other ways of obtaining the key. You could use adb root, then adb pull to get the file and open it with sqlitebrowser on a linux desktop etc.

All 2 comments

@Pg214
I would not use termux since it is more than a terminal, it is more like a linux userspace tool distribution.

I would connect the phone with usb and use adb shell, then type su and do your sqlite3 stuff.
There are many other ways of obtaining the key. You could use adb root, then adb pull to get the file and open it with sqlitebrowser on a linux desktop etc.

But if you insist: while not (yet) being root, and SQLite still working, run which sqlite3. This will give you the full path. Then, when being root, use that full path instead of just sqlite3.

And of course you cannot open the database without being root (or com.xiaomi.hm.health, which owns it). That's the idea behind "sandboxing" and Linux permissions. Otherwise apps could steal other apps' data ad libitum, which nobody (except the hackers and data collectors) would want.

So, as your question is rather about "Linux basics" than something specific to Gadgetbridge, I'm closing this issue. Hope our answers solved it anyway 馃槈

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jiack214 picture Jiack214  路  6Comments

ruimnetob picture ruimnetob  路  4Comments

bigretromike picture bigretromike  路  8Comments

RustyRaptor picture RustyRaptor  路  3Comments

6arms1leg picture 6arms1leg  路  6Comments