Skip to main content

Google TOTP decode and self-generate

Pre-requirements

  • An ubuntu system
    • with python3 supports
    • with python3-pip
    • with package installer, likes apt

Step1. Export TOTP

Export your TOTP from Google Authenticator by using "Transfer Codes". Take a screenshot of the generated QR-Code.

Step 2. Decode the exports

Step 2-1. Decode QR-code

  • Install dependencies

    sudo apt install -y libzbar0
    
    pip install pyzbar pillow
    
  • Run the script

    from pyzbar.pyzbar import decode
    from PIL import Image
    
    img = Image.open('google_auth.jpg')
    
    decoded_objects = decode(img)
    
    for obj in decoded_objects:
        print('Type:', obj.type)
        print('Data:', obj.data.decode('utf-8'), '\n')
    
  • The script output should be

    Type: QRCODE
    Data: otpauth-migration://offline?data=...
    
  • Just save the string after data paramater

Step 2-2. Decode URL