-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdbcommands.py
66 lines (41 loc) · 1.31 KB
/
dbcommands.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
import sqlite3
class Database:
def __init__(self,db_filtered_hash_dict):
self.db_filtered_hash_dict = db_filtered_hash_dict
self.potfileDB = 'potfile.db'
def connect(self):
try:
dbconn = sqlite3.connect(self.potfileDB)
except sqlite3.Error as e:
print("[-] Database Error: %s" % e.args[0])
return dbconn
def add_hash(self):
self.connect()
dbconn=self.connect()
cur = dbconn.cursor()
#for hashval, plaintext, hashcatmode, and hashtype
for h,vals in self.db_filtered_hash_dict.items():
m=str(vals[2])
p=str(vals[1])
t=str(vals[0])
h=str(h)
#print (h,t,m,p)
#try:
cur.execute("INSERT OR IGNORE INTO hashtypes (hashname, hashcatmode) VALUES ('{}', '{}') ".format(t,m))
dbconn.commit()
cur.execute("INSERT OR IGNORE INTO hashvalue (value, plain_text, type) VALUES ('{}', '{}', '{}') ".format(h,p,t))
dbconn.commit()
cur.execute("INSERT OR IGNORE INTO plain (plaintext, type) VALUES ('{}', '{}') ".format(p,h,t))
dbconn.commit()
'''#and display it
cur.execute("SELECT * FROM client WHERE (name = '{}') ".format(c))
results = cur.fetchall()
cur.close()'''
'''except sqlite3.Error as e:
print("[-] Database Error: %s" % e.args[0])'''
print('\n')
def main():
dbOps=Database()
if __name__ == '__main__':
main()