-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathgauth.py
39 lines (33 loc) · 908 Bytes
/
gauth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sqlite3
import sys
import json
def get_accounts(filename):
conn = sqlite3.connect(filename)
c = conn.cursor()
accounts = []
for row in c.execute("SELECT email,secret,issuer,type,counter FROM accounts"):
if row[3] == 0:
type_ = "TOTP"
else:
type_ = "HOTP"
accounts.append(
{
'label': row[0],
'secret': row[1],
'issuer': row[2],
'type': type_,
'digits': 6,
'counter': row[4],
'algorithm': 'SHA1',
}
)
c.close()
return accounts
def main():
if len(sys.argv) != 3:
print("Usage: python gauth.py [INPUT_FILE] [OUTPUT_FILE]")
return
output_file = open(sys.argv[2], 'w')
output_file.write(json.dumps(get_accounts(sys.argv[1])))
output_file.close()
main()