A Python script that extracts OTP secrets from QR codes exported by 2FA apps like Google Authenticator, enabling export and display in multiple formats.
Extract one time password (OTP) secrets from QR codes exported by two-factor authentication (2FA) apps such as "Google Authenticator". The exported QR codes from authentication apps can be captured by camera, read from images, or read from text files. The secrets can be exported to JSON or CSV, or printed as QR codes to console.
This tool is used to recover or backup one-time password (OTP) secrets from QR codes generated by two-factor authentication apps, facilitating migration or auditing of 2FA credentials. Security professionals, system administrators, and users needing to export or analyze their 2FA secrets would benefit from this tool.
Users should ensure they handle extracted OTP secrets securely to prevent unauthorized access. The tool requires Python 3.9+ and optionally shared system libraries for optimal performance. The ability to capture QR codes via camera requires a compatible system camera and GUI support. This tool is intended for legitimate backup, migration, or auditing purposes and should be used ethically.
Download the latest binary executable from the GitHub releases page for your OS (Linux, Windows, MacOS)
Alternatively, clone the repository: git clone https://github.com/scito/extract_otp_secrets.git
Install Python 3.9 or higher (up to 3.13 supported)
Install required Python dependencies (not explicitly listed, but typically via pip install -r requirements.txt)
Optionally install shared system libraries for improved performance (recommended)
Run the Python script directly or use the provided executable
python extract_otp_secrets.py --camera
Capture QR codes from the system camera using the GUI to extract OTP secrets
python extract_otp_secrets.py --image path/to/qr_image.png
Extract OTP secrets from a QR code image file using the built-in decoder
python extract_otp_secrets.py --text path/to/qr_text.txt
Read QR code data from a text file generated by an external QR decoder and extract OTP secrets
python extract_otp_secrets.py --export json --output secrets.json
Export extracted OTP secrets to a JSON file
python extract_otp_secrets.py --export csv --output secrets.csv
Export extracted OTP secrets to a CSV file
python extract_otp_secrets.py --print-qr
Print the extracted OTP secrets as QR codes directly to the console
python extract_otp_secrets.py --save-png path/to/output.png
Save the extracted OTP secret as a PNG image of the QR code