Skip to content

Instantly share code, notes, and snippets.

@Malvineous
Created October 1, 2017 09:11
Show Gist options
  • Save Malvineous/99e464e00471d805c38857e66daa8493 to your computer and use it in GitHub Desktop.
Save Malvineous/99e464e00471d805c38857e66daa8493 to your computer and use it in GitHub Desktop.
Shell script to generate Google Authenticator codes
#!/bin/sh
# This is the path to the Google Authenticator app file. It's typically located
# in /data under Android. Copy it to your PC in a safe location and specify the
# path to it here.
DB="/path/to/com.google.android.apps.authenticator/databases/databases"
sqlite3 "$DB" 'SELECT email,secret FROM accounts;' | while read A
do
NAME=`echo "$A" | cut -d '|' -f 1`
KEY=`echo "$A" | cut -d '|' -f 2`
CODE=`oathtool --totp -b "$KEY"`
echo -e "\e[1;32m$CODE\e[0m - \e[1;33m$NAME\e[0m"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment