-
Notifications
You must be signed in to change notification settings - Fork 12
Update generator code and README #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,53 @@ | ||
| from Crypto.Cipher import AES | ||
| from Crypto.Util.Padding import pad, unpad | ||
| from pyotp import TOTP | ||
| import base64 | ||
| #!/bin/env python3 | ||
| # | ||
| # This code is based on article | ||
| # https://huggable.tech/blog/extracting-fortitoken-mobile-totp-secret | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this article does not exist (anymore?)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yesterday it was in google cache and now it's gone.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I place link to web.archive.org instead then? |
||
| # | ||
| import hashlib | ||
| import base64 | ||
| import qrcode | ||
| from Cryptodome.Cipher import AES | ||
| from pyotp import TOTP | ||
|
|
||
| SEED = 'MNmAN7drtlNJxjFqo5bgSN/DZcdWVK9Qv1YyUP3OjuJkDXgV06siQYlQfO0678Lg' | ||
| UUID = 'N7gAr30eX72sR2owbVR4WrFiw4e3ignGBO6IcgA4qJjvBYjZvIxZXIMTHOix8QDt' | ||
| DEVICE_ID = 'eefd7d4837294e94' | ||
|
|
||
| SERIAL = 'TOKENSERIALunknown' | ||
|
|
||
|
|
||
| def unpad(s): | ||
| return s[0:-ord(s[-1])] | ||
|
|
||
|
|
||
| def decrypt(cipher, key): | ||
| sha256 = hashlib.sha256() | ||
| sha256.update(bytes(key, 'utf-8')) | ||
| digest = sha256.digest() | ||
| iv = bytes([0] * 16) | ||
| aes = AES.new(digest, AES.MODE_CBC, iv) | ||
| decrypted = aes.decrypt(base64.b64decode(cipher)) | ||
| return unpad(str(decrypted, "utf-8")) | ||
|
|
||
|
|
||
| uuid_key = DEVICE_ID + SERIAL[11:] | ||
| print("UUID KEY: %s" % uuid_key) | ||
| decoded_uuid = decrypt(UUID, uuid_key) | ||
| print("UUID: %s" % decoded_uuid) | ||
|
|
||
| seed_decryption_key = uuid_key + decoded_uuid | ||
| print("SEED KEY: %s" % seed_decryption_key) | ||
| decrypted_seed = decrypt(SEED, seed_decryption_key) | ||
|
|
||
| totp_secret = bytes.fromhex(decrypted_seed) | ||
|
|
||
| # fill these with values explained in README.md | ||
| android_ssaid = b'' | ||
| seed = b'' | ||
| totp_secret_encoded = str(base64.b32encode(totp_secret), "utf-8") | ||
| print("TOTP SECRET: %s" % totp_secret_encoded) | ||
|
|
||
| key = hashlib.sha256(android_ssaid + b'unknownnull').digest() | ||
| aes = AES.new(key, AES.MODE_CBC, b'\x00'*16) | ||
| data = unpad(aes.decrypt(base64.b64decode(seed)), 8) | ||
| data = base64.b32encode(bytes.fromhex(data.decode('utf-8'))) | ||
| totp = TOTP(totp_secret_encoded, interval=60) | ||
| print("Current TOTP: %s" % totp.now()) | ||
|
|
||
| totp = TOTP(data, interval = 60) | ||
| print(totp.now()) | ||
| str=totp.provisioning_uri(name='vpn', issuer_name='fortivpn') | ||
| img=qrcode.make(str) | ||
| type(img) | ||
| img.show() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| pycryptodome==3.10.1 | ||
| pycryptodome==3.11.0 | ||
| pyotp==2.6.0 | ||
| pycryptodomex==3.16.0 | ||
| qrcode==7.3.1 | ||
| pillow==9.3.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a bogus value, i hope you didn't replace it (and the other two) with your actual ones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are fake values from the article.