For a long time I used a two-factor authentication (2FA) app on Android called Authenticator Plus. However, in 2019 its author vanished and it started decaying from lack of updates. First its cloud backup feature stopped working due to changes in Android, then, as of Android 11, the feature for exporting its data to plain text also broke. However, it is still possible to use the feature that copies the data to an encrypted database, and as that’s in a standard format we can get the data out.
This small Python utility script generates QR codes from the extracted data, which you can then scan into a different 2FA app.
Open Authenticator Plus and go to Settings → Backup & Restore. Tap Backup to Sd Card. Where precisely that destination is in your filesystem will vary by device, but the path is shown there.
Use a method of your choice to copy the authplus.db
file to the computer you’re using this script on.
Getting this script to be able to open an encrypted SQLite database would make it significantly more complicated for me to write, so we’re handling that part with a separate tool.
Install DB Browser for SQLite. When installing, pick the version with SQLCipher support.
Run DB Browser (SQLCipher). Click Open Database and choose the authplus.db
file. In Encryption settings, pick “SQLCipher 3 defaults”. Enter your Authenticator Plus password.
Put this query into the Execute SQL
tab and click the play (
SELECT issuer, email AS label, secret FROM accounts
Click the result pane, select all (Ctrl-A), copy, paste into a text file. Save in the same directory as this script, named export.csv
.
Look at the issuer
column in the results in DB Browser. If it’s empty in any rows, open the CSV file in your text editor and add something on those lines. Separate it with a tab character from the label that follows, like in the other entries.
In a terminal:
pip install pillow qrcode rich
In a terminal:
python generate-qr-codes.py
You should see the names of your services and some identifying info for each printed out to the terminal. In the qr
directory you’ll now find PNG images with a QR code for each service. You can scan those into your new 2FA app as usual.
The idea of extracting the data with SQL and using Python to generate the QR codes came from this blog post by Nigel Sim. Thanks!
I’m not a Python programmer usually so unfortunately can’t offer any support if something goes wrong with this script (dependency issues or the like). If you do encounter an issue and are able to fix it, please file a PR.
Good luck!