diff --git a/Readme.md b/Readme.md index 8f2a4d3..d92e51b 100644 --- a/Readme.md +++ b/Readme.md @@ -37,8 +37,19 @@ javascript, but it didn't work straight out the box so I didn't bother spending ## Usage 1. Clone this Git repository -2. Make `otp-codes.sh` and `gen-qr-codes.sh` executable: `chmod +x *.sh` -3. Extract codes `./otp-codes.sh ... > urls.txt` -4. Encode all the images to QR codes `./gen-qr-codes.sh` -5. Import each code, one by one, using ALLthenticator's user interface -6. DELETE `urls.txt` and each generated qr code file. These files contain your secrets and MUST NOT be kept. \ No newline at end of file +2. Install dependencies +```bash +./install_dependencies.sh +``` +3. Install node packages +``` +npm i +``` +4. Take a screenshot of your exported QR code from Google Authenticator and save it to your disk +5. Extract codes, which will be automatically displayed and scan them with the Allthenticator +```bash +./otp-codes.sh +``` +6. Import each code, one by one, using ALLthenticator's user interface + - Press `ESC` to advance each picture +7. DELETE your screenshot! That is your secrets! diff --git a/gen-qr-codes.sh b/gen-qr-codes.sh deleted file mode 100755 index dd07bba..0000000 --- a/gen-qr-codes.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -counter=0 - -for x in `cat urls.txt` -do - qrencode -s 10 "$x" -o qr$counter.png - ((counter++)) -done diff --git a/index.js b/index.js index beff8d7..c85ab3d 100644 --- a/index.js +++ b/index.js @@ -22,8 +22,8 @@ async function printOTPCodes(otpBuffer) { for(let i = 0; i < otpArray.length; i++) { const otp = otpArray[i]; console.log("otpauth://totp/" + - (otp.issuer == undefined ? "" : otp.issuer) + - ":" + otp.name + + (otp.issuer == undefined ? "" : encodeURIComponent(otp.issuer)) + + ":" + encodeURIComponent(otp.name) + "?secret=" + base32.encode(otp.secret)) } } diff --git a/install_dependencies.sh b/install_dependencies.sh new file mode 100644 index 0000000..e19907b --- /dev/null +++ b/install_dependencies.sh @@ -0,0 +1,2 @@ +#!/bin/sh +sudo apt-get -y install qrencode zbar-tools feh diff --git a/otp-codes.sh b/otp-codes.sh index e0e2822..7917659 100755 --- a/otp-codes.sh +++ b/otp-codes.sh @@ -3,6 +3,12 @@ # Decode all the QR codes given on the command line for qrfile in "$@"; do qrcode="$(zbarimg -q --raw "$qrfile" 2>/dev/null)" - url="${qrcode/#QR-Code:}" - node index.js "$url" + mainurl="${qrcode/#QR-Code:}" + urls=$(node index.js "$mainurl") + for url in $urls; do + echo "Generating image for URI: $url" + qrencode -s 10 "$url" -o /tmp/qr_allthenticator.png + feh /tmp/qr_allthenticator.png + rm /tmp/qr_allthenticator.png + done done