-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetupDB.py
71 lines (56 loc) · 1.64 KB
/
setupDB.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
67
68
69
70
71
#!/usr/bin/env python3
try:
import sqlite3
except ImportError as e:
raise ImportError('Error importing %s' % e)
class PotfileDatabase():
def __init__(self):
#vars
self.potfileDB = 'potfile.db'
def createdatabase(self):
# Database Connection
print('[i] Creating Database')
try:
connection = sqlite3.connect(self.potfileDB)
c = connection.cursor()
#Create table
c.execute('''CREATE TABLE client(
ID INTEGER PRIMARY KEY,
name text,
Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
UNIQUE(name))''')
c.execute('''CREATE TABLE plain(
ID INTEGER PRIMARY KEY,
plaintext text,
hash_val text,
type text,
client_id integer,
FOREIGN KEY(client_id) REFERENCES client(ID),
FOREIGN KEY(hash_val) REFERENCES hashvalue(value))''')
c.execute('''CREATE TABLE hashvalue(
ID INTEGER PRIMARY KEY,
value text,
plain_text text,
type text,
client_id integer,
FOREIGN KEY(type) REFERENCES hashtypes(hashname),
FOREIGN KEY(client_id) REFERENCES client(ID),
FOREIGN KEY(plain_text) REFERENCES plain(plaintext)) ''')
c.execute('''CREATE TABLE hashtypes(
ID INTEGER PRIMARY KEY,
hashname text,
hashcatmode integer,
UNIQUE(hashname),
UNIQUE(hashcatmode))''')
print('[i] Populating NTLM type')
c.execute("INSERT INTO hashtypes (hashname, hashcatmode) VALUES ('ntlm','1000') ")
# Commit and close connection to database
connection.commit()
connection.close()
except sqlite3.Error as e:
print(" [-] Database Error: %s" % e.args[0])
def main():
createDb = PotfileDatabase()
createDb.createdatabase()
if __name__ == '__main__':
main()