From 9cd9d0d1d67849f26ddd0c0530749c5e2abb0d88 Mon Sep 17 00:00:00 2001 From: Stephen Shkardoon Date: Thu, 24 Oct 2019 23:33:14 +1300 Subject: [crack-otp] Set TOTP format length correctly --- crack-otp.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crack-otp.py b/crack-otp.py index ea958bd..2d27fb9 100755 --- a/crack-otp.py +++ b/crack-otp.py @@ -29,6 +29,15 @@ activation = activation[0:-1] # remove last digit -- check digit activationbytes = int(activation).to_bytes(7, byteorder='big') logging.info("Activation bytes: 0x%s", activationbytes.hex()) +# Determine the number of digits in the OTP and set the format accordingly +digitlen = len(args.OTP[0]) +if digitlen == 6: + digitformat = "dec6" +elif digitlen == 8: + digitformat = "dec8" +else: + logging.fatal("Failed to determine format of OTP.") + keys = [] timeToSearch = [] @@ -68,7 +77,7 @@ for otpTime in timeToSearch: ) # Verify whether the output is valid for the given time - otp = totp(key.hex(), hash=hashlib.sha256, t=otpTime) + otp = totp(key.hex(), hash=hashlib.sha256, t=otpTime, format=digitformat) if otp == args.OTP[0]: print("Possibe valid OTP seed found: ", key.hex()) -- cgit v1.2.3