-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecksum_manual.py
97 lines (62 loc) · 1.98 KB
/
checksum_manual.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import pymysql
import csv
import sys
import warnings
if not sys.warnoptions:
warnings.simplefilter("ignore")
hostname = 'localhost'
username = 'root'
password = 'rootpassword'
database = 'custom1'
conn = pymysql.connect( host=hostname, user=username, passwd=password, db=database )
cur = conn.cursor()
def command_gen(rez):
bad_chars = ['(', ')', "'"]
test_string = rez[0]
test_string = str(test_string)
#for i in bad_chars:
# test_string = test_string.replace(i, '')
#test_string = test_string.replace(',', '')
#cmd1='use '+ pez
cmd2='checksum table '+ test_string
#print(cmd1)
return cmd2
def db_gen(rez):
test_string = rez[1]
test_string = str(test_string)
cmd1='use '+ test_string
return cmd1
#with open(f'C:/Users/balaji Vyshnavy/Desktop/evidence/checksum.csv', mode='a') as f:
#f.truncate()
#f.close()
def writecsv(hash):
with open(f'C:/Users/balaji Vyshnavy/Desktop/evidence/checksum.csv', mode='a') as csv_file:
fieldnames = hash
writer = csv.DictWriter(csv_file, fieldnames=hash, )
writer.writeheader()
cur.execute('select table_name,table_schema from information_schema.tables')
gg=cur.fetchall()
for res in gg:
cmd2 = command_gen(res)
cmd1 = db_gen(res)
#print(cmd1)
#print(cmd2)
cur.execute(cmd1)
cur.execute(cmd2)
hsh = cur.fetchall()
print(hsh)
#writecsv(hsh)
conn.close()
#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()