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-10-02 21:56:05 +00:00
|
|
|
debug = False
|
2018-12-02 01:30:08 +00:00
|
|
|
|
|
|
|
hotp = pyotp.HOTP(secret)
|
2019-10-02 21:56:05 +00:00
|
|
|
if debug:
|
|
|
|
print("secret", secret)
|
|
|
|
print("count", count)
|
|
|
|
print("code:", hotp.at(count))
|
|
|
|
else:
|
|
|
|
print(hotp.at(count))
|
2018-12-02 01:30:08 +00:00
|
|
|
|
|
|
|
f.seek(offset)
|
|
|
|
f.write(str(count + 1))
|
2019-10-02 21:56:05 +00:00
|
|
|
f.close()
|