Last active
June 1, 2019 08:52
-
-
Save iiie/33314479f2d84db9285c4e3e0921de09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Dependancies: | |
pip install "qrtools==1.4" "pyotp==2.2.6" "urllib3==1.23" | |
Usage: | |
qr2f.py /path/to/screenshot1 [screenshot2 [screenshot3]] | |
""" | |
import urllib | |
import qrtools | |
import pyotp | |
import urlparse | |
def main(*filenames): | |
for filename in filenames: | |
#print filename | |
qr = qrtools.QR() | |
qr.decode(filename) | |
if qr.data.startswith('otpauth://totp'): | |
parsed = urlparse.urlparse(qr.data) | |
print urllib.unquote(parsed.path).decode('utf8').strip('/') | |
secret = urlparse.parse_qs(parsed.query)['secret'][0] | |
try: | |
#totp = pyotp.TOTP(qr.data[-16:]) | |
totp = pyotp.TOTP(secret) | |
print totp.now() | |
except TypeError as te: | |
print te | |
else: | |
print 'Not TOTP' | |
print qr.data | |
if __name__ == '__main__': | |
import sys | |
main(*sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment