Skip to content

Instantly share code, notes, and snippets.

@jbinto
Created February 8, 2014 04:20
Show Gist options
  • Star 96 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save jbinto/8876658 to your computer and use it in GitHub Desktop.
Save jbinto/8876658 to your computer and use it in GitHub Desktop.
Recovering Google Authenticator keys from Android device for backup
### Last tested February 7 2014 on a Galaxy S3 (d2att) running Cyanogenmod 11 nightly, with Google Authenticator 2.49.
### Device with Google Authenticator must have root.
### Computer requires Android Developer Tools and SQLite 3.
### Connect your device in USB debugging mode.
$ cd /tmp
$ adb root
$ adb pull /data/data/com.google.android.apps.authenticator2/databases/databases
$ sqlite3 ./databases "select * from accounts" > /Volumes/TRUECRYPT_ENCRYPTED_VOLUME/google_authenticator_backup.txt
$ rm ./databases
### If you look at the file, you see a pipe-delimited file with entries looking like the following.
### The X's mark the key.
1|Google:me@gmail.com|XXXXXXXXXXXXXXXXXXXXXXXX|0|0|0||
2|Google:me@domain.org|XXXXXXXXXXXXXXXXXXXXXXXX|0|0|0|Google|Google:me@domain.org
3|Dropbox:me@gmail.com|XXXXXXXXXXXXXXXXXXXXXXXX|0|0|0|Dropbox|Dropbox:me@gmail.com
### To restore the keys, you can key them in manually in Google Authenticator:
### Menu -> Set up account -> Enter provided key.
### Enter the key exactly as it appears, case sensitive, and choose Time-based.
@moghingold
Copy link

Link is dead

@krison1
Copy link

krison1 commented Dec 2, 2022

copy and paste the link instead, but he didn't specify how he did the simulated restore but then again I don't really understand sqlite3 that well.

@shokolatha
Copy link

shokolatha commented Dec 10, 2022

copy and paste the link instead, but he didn't specify how he did the simulated restore but then again I don't really understand sqlite3 that well.

he did mention the procedure at scito/extract_otp_secrets#24 , but the solution is misleading.
his solution is based on database of google authenticator version prior 5.10 which doesn't encrypt the secrets.
so the problem of encrypted secrets still persists.

@wegood9
Copy link

wegood9 commented Feb 11, 2023

I searched Google and accidentally found this website that can decode secrets from the newer Apps. I tested myself and it did work.

@shokolatha
Copy link

I searched Google and accidentally found this website that can decode secrets from the newer Apps. I tested myself and it did work.

It requires the QR codes, so it doesn't decrypt them "just by the database file".

@Fluorax
Copy link

Fluorax commented Oct 2, 2023

You can try disabling selinux. Tried the earlier suggestions, but Authenticator kept crashing. Restoring through Titanium backup that way, while upgrading from Android 10 to Android 13, I managed to recover my passwords.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment