46 lines
1.1 KiB
Markdown
46 lines
1.1 KiB
Markdown
---
|
|
title: "How to: backup google authenticator app two-factor secrets"
|
|
tags: ["gauth", "root", "android", "2fa"]
|
|
categories: ["recipe"]
|
|
date: "2017-06-12T11:44:46+02:00"
|
|
draft: false
|
|
---
|
|
|
|
Quick and dirty:
|
|
|
|
- Connect your device to the PC via USB
|
|
- Enable debugging mode
|
|
- From the terminal:
|
|
|
|
```bash
|
|
adb root
|
|
adb pull /data/data/com.google.android.apps.authenticator2/databases/databases
|
|
sqlite3 ./databases "select * from accounts" > ./gauth_backup.txt
|
|
```
|
|
|
|
If you want to generate an auth code from a TOTP secret you can use `oathtool`:
|
|
|
|
```bash
|
|
oathtool --base32 --totp "<secret>"
|
|
```
|
|
|
|
Enjoy!
|
|
|
|
---
|
|
|
|
Pro tip: to generate all the QR codes from the `sqlite` database you could use this python script (which requires the `qrcode` module):
|
|
|
|
```py
|
|
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))
|
|
```
|
|
|
|
(source: [thouis](https://github.com/thouis)) |