forked from cmaruti/paimei
-
Notifications
You must be signed in to change notification settings - Fork 3
/
__setup_mysql.py
158 lines (142 loc) · 6.02 KB
/
__setup_mysql.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!c:\python\python.exe
# $Id: __setup_mysql.py 231 2008-07-21 22:43:36Z pedram.amini $
import MySQLdb
import sys
USAGE = "__setup_mysql.py <mysql host> <username> <password>"
error = lambda msg: sys.stderr.write("ERROR> " + msg + "\n") or sys.exit(1)
if len(sys.argv) != 4:
error(USAGE)
host = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]
try:
mysql = MySQLdb.connect(host=host, user=username, passwd=password)
except MySQLdb.OperationalError, err:
error("Failed connecting to MySQL server: %s" % err[1])
cursor = mysql.cursor()
try:
cursor.execute("CREATE DATABASE paimei")
cursor.execute("USE paimei")
cursor.execute("""CREATE TABLE cc_hits (
target_id int(10) unsigned NOT NULL default '0',
tag_id int(10) unsigned NOT NULL default '0',
num int(10) unsigned NOT NULL default '0',
timestamp int(10) unsigned NOT NULL default '0',
eip int(10) unsigned NOT NULL default '0',
tid int(10) unsigned NOT NULL default '0',
eax int(10) unsigned NOT NULL default '0',
ebx int(10) unsigned NOT NULL default '0',
ecx int(10) unsigned NOT NULL default '0',
edx int(10) unsigned NOT NULL default '0',
edi int(10) unsigned NOT NULL default '0',
esi int(10) unsigned NOT NULL default '0',
ebp int(10) unsigned NOT NULL default '0',
esp int(10) unsigned NOT NULL default '0',
esp_4 int(10) unsigned NOT NULL default '0',
esp_8 int(10) unsigned NOT NULL default '0',
esp_c int(10) unsigned NOT NULL default '0',
esp_10 int(10) unsigned NOT NULL default '0',
esp_14 int(10) unsigned NOT NULL default '0',
esp_18 int(10) unsigned NOT NULL default '0',
esp_1c int(10) unsigned NOT NULL default '0',
esp_20 int(10) unsigned NOT NULL default '0',
eax_deref text NOT NULL,
ebx_deref text NOT NULL,
ecx_deref text NOT NULL,
edx_deref text NOT NULL,
edi_deref text NOT NULL,
esi_deref text NOT NULL,
ebp_deref text NOT NULL,
esp_deref text NOT NULL,
esp_4_deref text NOT NULL,
esp_8_deref text NOT NULL,
esp_c_deref text NOT NULL,
esp_10_deref text NOT NULL,
esp_14_deref text NOT NULL,
esp_18_deref text NOT NULL,
esp_1c_deref text NOT NULL,
esp_20_deref text NOT NULL,
is_function int(1) unsigned NOT NULL default '0',
module varchar(255) NOT NULL default '',
base int(10) unsigned NOT NULL default '0',
PRIMARY KEY (target_id,tag_id,num),
KEY tag_id (tag_id),
KEY target_id (target_id)
) ENGINE=MyISAM""")
cursor.execute("""CREATE TABLE cc_tags (
id int(10) unsigned NOT NULL auto_increment,
target_id int(10) unsigned NOT NULL default '0',
tag varchar(255) NOT NULL default '',
notes text NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM""")
cursor.execute("""CREATE TABLE cc_targets (
id int(10) unsigned NOT NULL auto_increment,
target varchar(255) NOT NULL default '',
notes text NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM""")
cursor.execute("""CREATE TABLE pp_hits (
id int(10) unsigned NOT NULL auto_increment,
recon_id int(10) unsigned NOT NULL default '0',
timestamp int(10) unsigned NOT NULL default '0',
tid int(10) unsigned NOT NULL default '0',
eax int(10) unsigned NOT NULL default '0',
ebx int(10) unsigned NOT NULL default '0',
ecx int(10) unsigned NOT NULL default '0',
edx int(10) unsigned NOT NULL default '0',
edi int(10) unsigned NOT NULL default '0',
esi int(10) unsigned NOT NULL default '0',
ebp int(10) unsigned NOT NULL default '0',
esp int(10) unsigned NOT NULL default '0',
esp_4 int(10) unsigned NOT NULL default '0',
esp_8 int(10) unsigned NOT NULL default '0',
esp_c int(10) unsigned NOT NULL default '0',
esp_10 int(10) unsigned NOT NULL default '0',
esp_14 int(10) unsigned NOT NULL default '0',
esp_18 int(10) unsigned NOT NULL default '0',
esp_1c int(10) unsigned NOT NULL default '0',
esp_20 int(10) unsigned NOT NULL default '0',
eax_deref text NOT NULL,
ebx_deref text NOT NULL,
ecx_deref text NOT NULL,
edx_deref text NOT NULL,
edi_deref text NOT NULL,
esi_deref text NOT NULL,
ebp_deref text NOT NULL,
esp_deref text NOT NULL,
esp_4_deref text NOT NULL,
esp_8_deref text NOT NULL,
esp_c_deref text NOT NULL,
esp_10_deref text NOT NULL,
esp_14_deref text NOT NULL,
esp_18_deref text NOT NULL,
esp_1c_deref text NOT NULL,
esp_20_deref text NOT NULL,
base int(10) unsigned NOT NULL default '0',
boron_tag varchar(255) NOT NULL default '',
module_id int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id)
) ENGINE=MyISAM""")
cursor.execute("""CREATE TABLE pp_modules (
id int(10) unsigned NOT NULL auto_increment,
name varchar(255) NOT NULL default '',
base int(10) unsigned NOT NULL default '0',
notes text NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM""")
cursor.execute("""CREATE TABLE pp_recon (
id int(10) unsigned NOT NULL auto_increment,
module_id int(10) unsigned NOT NULL default '0',
offset int(10) unsigned NOT NULL default '0',
stack_depth int(2) unsigned NOT NULL default '0',
reason text NOT NULL,
status varchar(255) NOT NULL default '',
username varchar(255) NOT NULL default '',
boron_tag varchar(255) NOT NULL default '',
notes text NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM""")
except MySQLdb.ProgrammingError, err:
error("Failed creating db / tables: %s" % err[1])
cursor.close()