summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKljunas2 <miha@korenjak.si>2023-01-13 16:16:14 +0100
committerKljunas2 <miha@korenjak.si>2023-01-13 16:16:14 +0100
commit95a3dab93a156c028cd612df13dd8cd9d50fc2d4 (patch)
treeebf476d9140b6033f5c95a78f26707cfc0593ff6
parentMerge pull request #2 from JHthe4/master (diff)
downloadentrust-identityguard-tools-95a3dab93a156c028cd612df13dd8cd9d50fc2d4.tar
entrust-identityguard-tools-95a3dab93a156c028cd612df13dd8cd9d50fc2d4.tar.gz
entrust-identityguard-tools-95a3dab93a156c028cd612df13dd8cd9d50fc2d4.tar.bz2
entrust-identityguard-tools-95a3dab93a156c028cd612df13dd8cd9d50fc2d4.tar.lz
entrust-identityguard-tools-95a3dab93a156c028cd612df13dd8cd9d50fc2d4.tar.xz
entrust-identityguard-tools-95a3dab93a156c028cd612df13dd8cd9d50fc2d4.tar.zst
entrust-identityguard-tools-95a3dab93a156c028cd612df13dd8cd9d50fc2d4.zip
-rwxr-xr-xcrack-otp.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/crack-otp.py b/crack-otp.py
index 2d27fb9..f3d6fdd 100755
--- a/crack-otp.py
+++ b/crack-otp.py
@@ -3,6 +3,7 @@ from hashlib import pbkdf2_hmac
import argparse
import logging
import hashlib
+import base64
from oath import totp
logging.basicConfig(level=logging.WARNING)
@@ -17,6 +18,7 @@ parser.add_argument('OTP', type=str, nargs=1, help='An OTP token generated from
parser.add_argument('OTPTime', type=int, nargs=1, help='The time in seconds since EPOCH when the OTP was generated. There is some slack in this value (approximately 30 seconds). Example (2019-10-07 07:50:09 UTC): 1570434609')
parser.add_argument('--policy', type=str, nargs=1, required=False, help='The policy associated with the identity. Example: {"allowUnsecured":"false","trustedExecution":"NOT_ALLOWED"}')
parser.add_argument('--strict-time', type=bool, nargs='?', const=True, required=False, help='Only search for valid keys strictly for the given timestamp. Without this option, the tool will attempt to search 30 seconds ahead or behind the given OTPTime to increase the chances of finding the key')
+parser.add_argument('--label', type=str, nargs='?', const=True, required=False, help='Label to use for generating otpauth:// URL')
args = parser.parse_args()
# Remove dashes from input so we can work with the data
@@ -88,6 +90,10 @@ if len(keys) == 0:
elif len(keys) == 1:
print("To generate a code immediately, run:")
print("oathtool -v --totp=sha256 --digits=6 " + keys[0].hex())
+ if (args.label):
+ print(f"otpauth://totp:{args.label}?secret={bytes.decode(base64.b32encode(keys[0]))}&algorithm=sha256&digits=8")
+ else:
+ print("base32 encoded key: " + bytes.decode(base64.b32encode(keys[0])))
else:
print("To generate a code immediately, run:")
print("oathtool -v --totp=sha256 --digits=6 (found key)")