2018-12-02 01:30:08 +00:00
|
|
|
#!/usr/bin/env python2.7
|
|
|
|
|
|
|
|
import pyotp
|
|
|
|
import requests
|
|
|
|
import base64
|
|
|
|
import json
|
|
|
|
import sys
|
|
|
|
from urllib2 import unquote
|
|
|
|
|
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())
|
|
|
|
|
|
|
|
print "secret", secret
|
|
|
|
print "count", count
|
|
|
|
|
|
|
|
hotp = pyotp.HOTP(secret)
|
|
|
|
print "Code:", hotp.at(count)
|
|
|
|
|
|
|
|
f.seek(offset)
|
|
|
|
f.write(str(count + 1))
|
|
|
|
f.close()
|
|
|
|
|