Skip to content

Instantly share code, notes, and snippets.

@seth2810
Forked from Malvineous/google-authenticator.sh
Created December 24, 2020 16:46
Show Gist options
  • Save seth2810/1b3ff52b39df2e9cc8bf1a3d3c7efe01 to your computer and use it in GitHub Desktop.
Save seth2810/1b3ff52b39df2e9cc8bf1a3d3c7efe01 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