2019-03-20 10:41:31 +00:00
|
|
|
#!/usr/bin/env python3
|
2018-12-02 01:30:08 +00:00
|
|
|
|
|
|
|
import pyotp
|
|
|
|
import sys
|
|
|
|
|
2019-03-19 23:48:54 +00:00
|
|
|
if len(sys.argv) == 2:
|
|
|
|
file = sys.argv[1]
|
|
|
|
else:
|
|
|
|
file = "duotoken.hotp"
|
|
|
|
|
|
|
|
f = open(file, "r+");
|
2018-12-02 01:30:08 +00:00
|
|
|
secret = f.readline()[0:-1]
|
|
|
|
offset = f.tell()
|
|
|
|
count = int(f.readline())
|
|
|
|
|
2019-03-20 10:41:31 +00:00
|
|
|
print("secret", secret)
|
|
|
|
print("count", count)
|
2018-12-02 01:30:08 +00:00
|
|
|
|
|
|
|
hotp = pyotp.HOTP(secret)
|
2019-03-20 10:41:31 +00:00
|
|
|
print("Code:", hotp.at(count))
|
2018-12-02 01:30:08 +00:00
|
|
|
|
|
|
|
f.seek(offset)
|
|
|
|
f.write(str(count + 1))
|
|
|
|
f.close()
|