Compare commits

..

5 Commits

Author SHA1 Message Date
scito
3502294172 remove dependency to module and fix build script 2023-01-03 02:00:07 +01:00
scito
2707e244be update README 2023-01-03 01:04:44 +01:00
scito
4ba0fad000 capture QR codes from camera and major refactoring
- add GUI for QR code capturing from camera (CV2 is used)
- support different QR readers: ZBAR,QREADER,QREADER_DEEP,CV2,CV2_WECHAT
- support several input files
- add option to ignore duplicate otps
- write warnings and errors to stderr
- add output coloring
- rename project from extract_otp_secret_keys to extract_otp_secrets
- improve help
- clean verbose level output
- use Python type hints and check with mypy
- use f-strings
- clean up code
- add more tests
- calculate code coverage
- use src-layout: move files and folders
- support wheel packing
- enhance README.md
- bugfixes
    * fix -k -
    * fix utf-8 encoding on windows
2023-01-03 00:28:32 +01:00
scito
9d052dc78a refactor image import and add Alpine docker image
- dynamic import of QR reader
- build docker also for arm64
2023-01-03 00:26:46 +01:00
qwertyca
915efcf192 Add the ability so provide an image file as the infile. If the file contains a QR code generated by Google Authenticator's "Transfer Accounts" function, it will be decoded directly in a single step. This is meant to help users who need to access their secrets from Google Authenticator but don't have a QR code decoder and don't want to use an online one due to security concerns. 2023-01-03 00:26:46 +01:00
4 changed files with 13 additions and 15 deletions

View File

@@ -9,7 +9,6 @@ name: docker
on: on:
# run it on push to the default repository branch # run it on push to the default repository branch
push: push:
branches: [master]
schedule: schedule:
# Run weekly on default branch # Run weekly on default branch
- cron: '47 3 * * 6' - cron: '47 3 * * 6'

View File

@@ -1,4 +1,4 @@
# Extract secrets from QR codes exported by two-factor authentication apps # Extract TOTP/HOTP secrets from QR codes exported by two-factor authentication apps
[![CI tests](https://github.com/scito/extract_otp_secrets/actions/workflows/ci.yml/badge.svg)](https://github.com/scito/extract_otp_secrets/actions/workflows/ci.yml) [![CI tests](https://github.com/scito/extract_otp_secrets/actions/workflows/ci.yml/badge.svg)](https://github.com/scito/extract_otp_secrets/actions/workflows/ci.yml)
![coverage](https://img.shields.io/badge/coverage-96%25-brightgreen) ![coverage](https://img.shields.io/badge/coverage-96%25-brightgreen)
@@ -13,15 +13,15 @@
--- ---
The Python script `extract_otp_secrets.py` extracts one time password (OTP) secrets from QR codes exported by two-factor authentication (2FA) apps such as "Google Authenticator". The Python script `extract_otp_secrets.py` extracts one time password (OTP) secrets from QR codes exported by two-factor authentication (2FA) apps such as "Google Authenticator".
The export QR codes from authentication apps can be provided in three ways to this script: The exported QR codes from authentication apps can be read in three ways:
1. Capture from the system camera in a GUI, 1. Capture from the system camera using a GUI, _(new!)_
2. Image files containing the QR codes, and 2. Read image files containing the QR codes, and _(new!)_
3. Text files containing the QR code data generated by QR readers. 3. Read text files containing the QR code data generated by third-party QR readers.
The secret and otp values can be exported to json or csv files, as well as printed or saved to PNG images. The secret and otp values can be exported to json or csv files, as well as printed or saved to PNG images.
This script/project was renamed from extract_otp_secret_keys to extract_otp_secrets in version 2.0.0. **The project and the script were renamed from extract_otp_secret_keys to extract_otp_secrets in version 2.0.0.**
## Installation ## Installation
@@ -518,10 +518,10 @@ FileNotFoundError: Could not find module 'libiconv.dll' (or one of its dependenc
* [ZBar](https://github.com/mchehab/zbar) is an open source software suite for reading bar codes from various sources, including webcams. * [ZBar](https://github.com/mchehab/zbar) is an open source software suite for reading bar codes from various sources, including webcams.
* [Aegis Authenticator](https://github.com/beemdevelopment/Aegis) is a free, secure and open source 2FA app for Android. * [Aegis Authenticator](https://github.com/beemdevelopment/Aegis) is a free, secure and open source 2FA app for Android.
* [Android OTP Extractor](https://github.com/puddly/android-otp-extractor) can extract your tokens from popular Android OTP apps and export them in a standard format or just display them as QR codes for easy importing. [Requires a _rooted_ Android phone.] * [pyzbar](https://github.com/NaturalHistoryMuseum/pyzbar) is a good QR code reader Python module
* [Python QReader](https://github.com/Eric-Canas/QReader)
* [pyzbar](https://github.com/NaturalHistoryMuseum/pyzbar)
* [OpenCV](https://docs.opencv.org/4.x/) (CV2) Open Source Computer Vision library with [opencv-python](https://github.com/opencv/opencv-python) * [OpenCV](https://docs.opencv.org/4.x/) (CV2) Open Source Computer Vision library with [opencv-python](https://github.com/opencv/opencv-python)
* [Python QReader](https://github.com/Eric-Canas/QReader) Python QR code readers
* [Android OTP Extractor](https://github.com/puddly/android-otp-extractor) can extract your tokens from popular Android OTP apps and export them in a standard format or just display them as QR codes for easy importing. [Requires a _rooted_ Android phone.]
*** ***

View File

@@ -317,7 +317,7 @@ eval "$cmd"
# Build wheel # Build wheel
cmd="$PIP wheel . cmd="$PIP wheel ."
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
eval "$cmd" eval "$cmd"

View File

@@ -2,8 +2,6 @@ from typing import Any
import pytest import pytest
from extract_otp_secrets import QRMode
def pytest_addoption(parser: pytest.Parser) -> None: def pytest_addoption(parser: pytest.Parser) -> None:
parser.addoption("--relaxed", action='store_true', help="run tests in relaxed mode") parser.addoption("--relaxed", action='store_true', help="run tests in relaxed mode")
@@ -17,6 +15,7 @@ def relaxed(request: pytest.FixtureRequest) -> Any:
def pytest_generate_tests(metafunc: pytest.Metafunc) -> None: def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
if "qr_mode" in metafunc.fixturenames: if "qr_mode" in metafunc.fixturenames:
number = 2 if metafunc.config.getoption("fast") else len(QRMode) all_qr_modes = ['ZBAR', 'QREADER', 'QREADER_DEEP', 'CV2', 'CV2_WECHAT']
qr_modes = [mode.name for mode in QRMode] number = 2 if metafunc.config.getoption("fast") else len(all_qr_modes)
qr_modes = [mode for mode in all_qr_modes]
metafunc.parametrize("qr_mode", qr_modes[0:number]) metafunc.parametrize("qr_mode", qr_modes[0:number])