-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash_storage.py
78 lines (58 loc) · 2.01 KB
/
hash_storage.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
72
73
74
75
76
77
78
import pymysql
import hashing
from datetime import datetime
hostname = 'localhost'
username = 'root'
password = 'rootpassword'
database = 'sys'
conn = pymysql.connect( host=hostname, user=username, passwd=password, db=database )
cur = conn.cursor()
list=("C:/Users/Balaji Vyshnavy/Desktop/evidence/columns.csv"
,"C:/Users/Balaji Vyshnavy/Desktop/evidence/history.sql"
,"C:/Users/Balaji Vyshnavy/Desktop/evidence/LAPTOP-67H7KN81.log"
,"C:/Users/Balaji Vyshnavy/Desktop/evidence/innodb_tables.csv")
def command_gen():
dateTimeObj = datetime.now()
time= dateTimeObj.strftime("%d-%b-%Y--%H:%M:%S.%f-")
res=""
for file in list:
res=res +"','"+ hashing.custom_hash(file)
res = "('" + time + res + "')"
cmd="insert into HASH values"+res
return cmd
#cmd=command_gen()
cur.execute('use sys')
#cur.execute(cmd)
cur.execute('select * from HASH')
rez=cur.fetchall()
print(rez)
conn.commit()
def hash_table():
#cur.execute("SET group_concat_max_len = 18446744073709547520")
cur.execute("SELECT MD5( GROUP_CONCAT( CONCAT_WS('',timestamp,columns_csv,history_sql,LAPTOP_67H7KN81_LOG,tables_csv) SEPARATOR ',' ) ) as 'HASH SIGNATURE OF TABLE {HASH}' FROM hash")
rez=cur.fetchall()
print(rez)
hash_table()
conn.close()
#g='select * from logininfo'
#cur.execute('use custom1')
#cur.execute(g)
#rez=cur.fetchall()
#print(rez)
#print(g)
'''cmd=command_gen()
print(cmd)
cur.execute('use sys')
cur.execute(cmd)
cur.execute('select * from HASH')
rez=cur.fetchall()
print(rez)'''
'''def command_gen():
def file_as_bytes(file):
with file:
return file.read()
print(hashlib.sha256(file_as_bytes(open("C:/Users/Balaji Vyshnavy/Desktop/evidence/files.csv", 'rb'))).hexdigest())
res=hashlib.sha256(file_as_bytes(open("C:/Users/Balaji Vyshnavy/Desktop/evidence/files.csv", 'rb'))).hexdigest()
#res=hashing.custom_hash()
cmd="insert into hash values('"+res+"')"
return cmd'''