From 2ede6519fad2ab15767632350e3c48d2a1903522 Mon Sep 17 00:00:00 2001 From: Stephen Shkardoon Date: Sun, 6 Oct 2019 21:59:50 +1300 Subject: Minor tweaks and formatting to decode-qr-uri --- README.md | 2 +- decode-qr-uri.py | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5ca3c3a..6fd582f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Run this with the URI from a QR code to recieve the decrypted data. The decrypte Example: ``` -$ ./generate-hmacs.py 'igmobileotp://?action=secactivate&enc=VRUq6IoLWQRCMRITZEHtHUSWJiPwgu%2FN1BFyUHE5kxuHIEYoE3zmNTrAHeeUM5S3gzCnTy%2F%2Bdnbu%2FsjjQW%2BNEISx8C4ra8rLpxOl8E8w4KXHgjeBRgdvSzl%2BbzX5RYRrQlWgK8hsBT4pQYE0eFgW2TmRbzXu1Mu7XjKDcwsJLew32jQC2qyPLP8hljnv2rHwwsMfhQwgJUJYfctwLWWEDUFukEckaZ4O&v=1&mac=mhVL8BWKaishMa5%2B' 54998317 +$ ./decode-qr-uri.py 'igmobileotp://?action=secactivate&enc=VRUq6IoLWQRCMRITZEHtHUSWJiPwgu%2FN1BFyUHE5kxuHIEYoE3zmNTrAHeeUM5S3gzCnTy%2F%2Bdnbu%2FsjjQW%2BNEISx8C4ra8rLpxOl8E8w4KXHgjeBRgdvSzl%2BbzX5RYRrQlWgK8hsBT4pQYE0eFgW2TmRbzXu1Mu7XjKDcwsJLew32jQC2qyPLP8hljnv2rHwwsMfhQwgJUJYfctwLWWEDUFukEckaZ4O&v=1&mac=mhVL8BWKaishMa5%2B' 54998317 {"sn":"48244-13456","ac":"1745-7712-6942-8698","policy":"{\"allowUnsecured\":\"false\",\"trustedExecution\":\"NOT_ALLOWED\"}","regurl":"myid.umc.edu\/igst"} ``` diff --git a/decode-qr-uri.py b/decode-qr-uri.py index f376e38..711ce5b 100755 --- a/decode-qr-uri.py +++ b/decode-qr-uri.py @@ -1,6 +1,4 @@ #!/bin/env python3 -import hashlib -import hmac import urllib.parse from hashlib import pbkdf2_hmac import base64 @@ -56,11 +54,11 @@ logging.debug("KDF Salt: 0x%s", kdfSalt.hex()) # Run PBKDF2 to obtain our AES key key = pbkdf2_hmac( - hash_name = 'sha256', - password = args.Password[0].encode('utf-8'), - salt = kdfSalt, - iterations = 1000, - dklen = 64 + hash_name='sha256', + password=args.Password[0].encode('utf-8'), + salt=kdfSalt, + iterations=1000, + dklen=64 ) logging.debug("KDF Output: 0x%s", key.hex()) @@ -99,7 +97,7 @@ logging.debug("IV: 0x%s", iv.hex()) logging.debug("AES Key: 0x%s", aesKey.hex()) # custom unpad, as pycrytodome does not support pkcs5 -unpad = lambda s : s[0:-(s[-1])] +unpad = lambda s: s[0:-(s[-1])] cipher = AES.new(aesKey, mode=AES.MODE_CBC, iv=iv) decrypted_data = unpad(cipher.decrypt(encdata)) -- cgit v1.2.3