Forked from jbinto/howto-recover-google-authenticator-keys.txt
Last active
February 2, 2018 19:47
-
-
Save tamadamas/f7ff365527694a938336e187dae7ec03 to your computer and use it in GitHub Desktop.
Recovering Google Authenticator keys from Android device for backup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qrcode | |
import sqlite3 | |
conn = sqlite3.connect('databases') | |
c = conn.cursor() | |
for idx, (email, secret, issuer) in enumerate(c.execute("SELECT email,secret,issuer FROM accounts").fetchall()): | |
url = 'otpauth://totp/{}?secret={}&issuer={}'.format(email, secret, issuer) | |
print url | |
im = qrcode.make(url) | |
im.save('{}.png'.format(idx)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Device with Google Authenticator must have root. | |
### Computer requires Android Developer Tools and python with sqlite3 and qrcode | |
### Connect your device in USB debugging mode. | |
# Original solution with `adb root` does not work for me | |
$ cd /tmp | |
$ adb shell | |
# Now you're on the phone | |
$ su # and do any auth action your root requires | |
$ cp /data/data/com.google.android.apps.authenticator2/databases/databases /sdcard/Download/ | |
$ exit | |
$ exit | |
# Now you're back on the computer | |
$ adb pull /sdcard/Download/databases | |
# Remove databases from public folder | |
$ adb shell | |
$ rm /sdcard/Download/databases | |
$ python gen_qrcode.py | |
### You can see generated qr images in the current folder. Scan them in Google Authenticator when you are ready |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment