diff --git a/README.md b/README.md index 22e1f1b..8e06430 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ The data parameter is a base64 encoded proto3 message (Google Protocol Buffers). Command for regeneration of Python code from proto3 message definition file (only necessary in case of changes of the proto3 message definition or new protobuf versions): - protoc -plugin=protoc-gen-mypy=path/to/protoc-gen-mypy --python_out=protobuf_generated_python --mypy_out=protobuf_generated_python google_auth.proto + protoc --plugin=protoc-gen-mypy=path/to/protoc-gen-mypy --python_out=src/protobuf_generated_python --mypy_out=src/protobuf_generated_python src/google_auth.proto The generated protobuf Python code was generated by protoc 21.12 (https://github.com/protocolbuffers/protobuf/releases/tag/v21.12). diff --git a/build.sh b/build.sh index 5a1d063..ec35027 100755 --- a/build.sh +++ b/build.sh @@ -147,7 +147,7 @@ echo -e "\nProtoc remote version $VERSION\n" echo -e "Protoc local version: $OLDVERSION\n" if $clean; then - cmd="rm -r dist/ build/ *.whl pytest.xml pytest-coverage.txt .coverage tests/reports || true; find . -name '*.pyc' -type f -delete; find . -name '__pycache__' -type d -exec rm -r {} \; || true; find . -name '*.egg-info' -type d -exec rm -r {} \; || true; find . -name '*_cache' -type d -exec rm -r {} \; || true" + cmd="rm -r dist/ build/ *.whl pytest.xml pytest-coverage.txt .coverage tests/reports || true; find . -name '*.pyc' -type f -delete; find . -name '__pycache__' -type d -exec rm -r {} \; || true; find . -name '*.egg-info' -type d -exec rm -r {} \; || true; find . -name '*_cache' -type d -exec rm -r {} \; || true; mkdir -p tests/reports;" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" @@ -200,7 +200,7 @@ if [ "$OLDVERSION" != "$VERSION" ] || ! $ignore_version_check; then if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" - cmd="$BIN/$DEST/bin/protoc --plugin=protoc-gen-mypy=$HOME/.local/bin/protoc-gen-mypy --python_out=protobuf_generated_python --mypy_out=protobuf_generated_python src/google_auth.proto" + cmd="$BIN/$DEST/bin/protoc --plugin=protoc-gen-mypy=$HOME/.local/bin/protoc-gen-mypy --python_out=src/protobuf_generated_python --mypy_out=src/protobuf_generated_python --proto_path=src google_auth.proto" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" @@ -311,7 +311,7 @@ if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}"; eval "$cmd" COVERAGE_OUT_FILE="tests/reports/pytest-coverage.txt" -cmd="mkdir -p tests/reports; pytest --cov=extract_otp_secrets_test --junitxml=tests/reports/pytest.xml --cov-report html:tests/reports/html --cov-report=term-missing tests/ | tee $COVERAGE_OUT_FILE" +cmd="pytest --cov=extract_otp_secrets_test --junitxml=tests/reports/pytest.xml --cov-report html:tests/reports/html --cov-report=term-missing tests/ | tee $COVERAGE_OUT_FILE" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" diff --git a/src/extract_otp_secrets.py b/src/extract_otp_secrets.py index 1ed933e..84ffa74 100644 --- a/src/extract_otp_secrets.py +++ b/src/extract_otp_secrets.py @@ -1,28 +1,15 @@ -# TODO rewrite - -# Extract two-factor authentication (2FA, TFA) secrets from export QR codes of "Google Authenticator" app +# Extract one time password (OTP) secrets from QR codes exported by two-factor authentication (2FA) apps such as "Google Authenticator" # -# Usage: -# 1. Export the QR codes from "Google Authenticator" app -# 2. Read QR codes with QR code reader (e.g. with a second device) -# 3. Save the captured QR codes in a text file. Save each QR code on a new line. (The captured QR codes look like "otpauth-migration://offline?data=...") -# 4. Call this script with the file as input: -# python extract_otp_secrets.py example_export.txt +# For more information, see README.md # -# Requirement: -# The protobuf package of Google for proto3 is required for running this script. -# pip install protobuf -# -# Optional: -# For printing QR codes, the qrcode module is required -# pip install qrcode +# Source code available on https://github.com/scito/extract_otp_secrets # # Technical background: -# The export QR code of "Google Authenticator" contains the URL "otpauth-migration://offline?data=...". +# The export QR code from "Google Authenticator" contains the URL "otpauth-migration://offline?data=...". # The data parameter is a base64 encoded proto3 message (Google Protocol Buffers). # # Command for regeneration of Python code from proto3 message definition file (only necessary in case of changes of the proto3 message definition): -# protoc --python_out=generated_python google_auth.proto +# protoc --plugin=protoc-gen-mypy=path/to/protoc-gen-mypy --python_out=src/protobuf_generated_python --mypy_out=src/protobuf_generated_python --proto_path=src google_auth.proto # # References: # Proto3 documentation: https://developers.google.com/protocol-buffers/docs/pythontutorial