Python 3 support

This commit is contained in:
Andreas Thienemann 2019-03-20 11:41:31 +01:00 committed by Andreas Thienemann
parent 5cb5600104
commit aa4807cc6a
2 changed files with 11 additions and 15 deletions

View File

@ -1,14 +1,14 @@
#!/usr/bin/env python2.7 #!/usr/bin/env python3
import pyotp import pyotp
import requests import requests
import base64 import base64
import json import json
import sys import sys
from urllib2 import unquote
if len(sys.argv) < 2: if len(sys.argv) < 2:
print "Usage: python duo_bypass.py <url to duo qr>"; exit() print("Usage: python duo_bypass.py <url to duo qr>")
sys.exit()
qr_url = sys.argv[1] qr_url = sys.argv[1]
@ -38,16 +38,16 @@ response = json.loads(r.text)
try: try:
secret = base64.b32encode(response['response']['hotp_secret']) secret = base64.b32encode(response['response']['hotp_secret'])
except KeyError: except KeyError:
print response print(response)
sys.exit(1) sys.exit(1)
print "secret", secret print("secret", secret)
print "10 Next OneTime Passwords!" print("10 Next OneTime Passwords!")
# Generate 10 Otps! # Generate 10 Otps!
hotp = pyotp.HOTP(secret) hotp = pyotp.HOTP(secret)
for _ in xrange(10): for _ in xrange(10):
print hotp.at(_) print(hotp.at(_))
f = open('duotoken.hotp', 'w') f = open('duotoken.hotp', 'w')
f.write(secret + "\n") f.write(secret + "\n")

View File

@ -1,11 +1,7 @@
#!/usr/bin/env python2.7 #!/usr/bin/env python3
import pyotp import pyotp
import requests
import base64
import json
import sys import sys
from urllib2 import unquote
if len(sys.argv) == 2: if len(sys.argv) == 2:
file = sys.argv[1] file = sys.argv[1]
@ -17,11 +13,11 @@ secret = f.readline()[0:-1]
offset = f.tell() offset = f.tell()
count = int(f.readline()) count = int(f.readline())
print "secret", secret print("secret", secret)
print "count", count print("count", count)
hotp = pyotp.HOTP(secret) hotp = pyotp.HOTP(secret)
print "Code:", hotp.at(count) print("Code:", hotp.at(count))
f.seek(offset) f.seek(offset)
f.write(str(count + 1)) f.write(str(count + 1))