Last active
August 30, 2021 20:13
-
-
Save mtfurlan/821722424f94e3f909b88bc617dcd44e to your computer and use it in GitHub Desktop.
read google authenitcator database and generate codes
This file contains 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
#!/usr/bin/env python3 | |
# read google authenticator database and output TOTP codes. | |
# /data/data/com.google.android.apps.authenticator2/databases/databases | |
#import qrcode | |
import sqlite3 | |
import pyotp | |
from tabulate import tabulate | |
conn = sqlite3.connect('databases') | |
c = conn.cursor() | |
output = [] | |
for idx, (email, secret, issuer) in enumerate(c.execute("SELECT email,secret,issuer FROM accounts").fetchall()): | |
# if you want to make a QR code to import it elsewhere I guess this will do that? | |
# https://gist.github.com/jbinto/8876658#gistcomment-1522362 | |
#url = 'otpauth://totp/{}?secret={}&issuer={}'.format(email, secret, issuer) | |
#im = qrcode.make(url) | |
#im.save('{}.png'.format(idx)) | |
totp = pyotp.TOTP(secret) | |
code = totp.now() | |
#print(f"{email}: {code}") | |
output.append([email, code]); | |
print(tabulate(output, headers=['service', 'code'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment