@@ -43,19 +43,21 @@ def print_warn(self, message):
43
43
def print_verbose (self , message ):
44
44
print ("[debug]" ,message )
45
45
46
- def report_test_result (self , uuid , version , namedpipe , msprotocol_rpc_instance , result , exploitpath ):
46
+ def report_test_result (self , target , uuid , version , namedpipe , msprotocol_rpc_instance , result , exploitpath ):
47
47
function_name = msprotocol_rpc_instance .function ["name" ]
48
- if uuid not in self .test_results .keys ():
49
- self .test_results [uuid ] = {}
50
- if version not in self .test_results [uuid ].keys ():
51
- self .test_results [uuid ][version ] = {}
52
- if function_name not in self .test_results [uuid ][version ].keys ():
53
- self .test_results [uuid ][version ][function_name ] = {}
54
- if namedpipe not in self .test_results [uuid ][version ][function_name ].keys ():
55
- self .test_results [uuid ][version ][function_name ][namedpipe ] = []
48
+ if target not in self .test_results .keys ():
49
+ self .test_results [target ] = {}
50
+ if uuid not in self .test_results [target ].keys ():
51
+ self .test_results [target ][uuid ] = {}
52
+ if version not in self .test_results [target ][uuid ].keys ():
53
+ self .test_results [target ][uuid ][version ] = {}
54
+ if function_name not in self .test_results [target ][uuid ][version ].keys ():
55
+ self .test_results [target ][uuid ][version ][function_name ] = {}
56
+ if namedpipe not in self .test_results [target ][uuid ][version ][function_name ].keys ():
57
+ self .test_results [target ][uuid ][version ][function_name ][namedpipe ] = []
56
58
57
59
# Save result to database
58
- self .test_results [uuid ][version ][function_name ][namedpipe ].append ({
60
+ self .test_results [target ][ uuid ][version ][function_name ][namedpipe ].append ({
59
61
"function" : msprotocol_rpc_instance .function ,
60
62
"protocol" : msprotocol_rpc_instance .protocol ,
61
63
"testresult" : result .name ,
@@ -102,21 +104,22 @@ def exportXLSX(self, filename):
102
104
worksheet = workbook .add_worksheet ()
103
105
104
106
header_format = workbook .add_format ({'bold' : 1 })
105
- header_fields = ["Interface UUID" , "Interface version" , "SMB named pipe" , "Protocol long name" , "Protocol short name" , "RPC function name" , "Operation number" , "Result" , "Working path" ]
107
+ header_fields = ["Target" , " Interface UUID" , "Interface version" , "SMB named pipe" , "Protocol long name" , "Protocol short name" , "RPC function name" , "Operation number" , "Result" , "Working path" ]
106
108
for k in range (len (header_fields )):
107
109
worksheet .set_column (k , k + 1 , len (header_fields [k ]) + 3 )
108
110
worksheet .set_row (0 , 60 , header_format )
109
111
worksheet .write_row (0 , 0 , header_fields )
110
112
111
113
row_id = 1
112
- for uuid in self .test_results .keys ():
113
- for version in self .test_results [uuid ].keys ():
114
- for function_name in self .test_results [uuid ][version ].keys ():
115
- for namedpipe in self .test_results [uuid ][version ][function_name ].keys ():
116
- for test_result in self .test_results [uuid ][version ][function_name ][namedpipe ]:
117
- data = [uuid , version , namedpipe , test_result ["protocol" ]["longname" ], test_result ["protocol" ]["shortname" ], test_result ["function" ]["name" ], test_result ["function" ]["opnum" ], test_result ["testresult" ], test_result ["exploitpath" ]]
118
- worksheet .write_row (row_id , 0 , data )
119
- row_id += 1
114
+ for target in self .test_results .keys ():
115
+ for uuid in self .test_results [target ].keys ():
116
+ for version in self .test_results [target ][uuid ].keys ():
117
+ for function_name in self .test_results [target ][uuid ][version ].keys ():
118
+ for namedpipe in self .test_results [target ][uuid ][version ][function_name ].keys ():
119
+ for test_result in self .test_results [target ][uuid ][version ][function_name ][namedpipe ]:
120
+ data = [target , uuid , version , namedpipe , test_result ["protocol" ]["longname" ], test_result ["protocol" ]["shortname" ], test_result ["function" ]["name" ], test_result ["function" ]["opnum" ], test_result ["testresult" ], test_result ["exploitpath" ]]
121
+ worksheet .write_row (row_id , 0 , data )
122
+ row_id += 1
120
123
worksheet .autofilter (0 , 0 , row_id , len (header_fields ) - 1 )
121
124
workbook .close ()
122
125
self .print_info ("Results exported to XLSX in '%s'" % path_to_file )
@@ -136,7 +139,7 @@ def exportJSON(self, filename):
136
139
f .close ()
137
140
self .print_info ("Results exported to JSON in '%s'" % path_to_file )
138
141
139
- def exportSQLITE (self , target , filename ):
142
+ def exportSQLITE (self , filename ):
140
143
basepath = os .path .dirname (filename )
141
144
filename = os .path .basename (filename )
142
145
if basepath not in ["." , "" ]:
@@ -151,23 +154,25 @@ def exportSQLITE(self, target, filename):
151
154
# Creating a cursor object using the cursor() method
152
155
cursor = conn .cursor ()
153
156
cursor .execute ("CREATE TABLE IF NOT EXISTS results(target VARCHAR(255), uuid VARCHAR(255), version VARCHAR(255), named_pipe VARCHAR(255), protocol_shortname VARCHAR(255), protocol_longname VARCHAR(512), function_name VARCHAR(255), result VARCHAR(255), path VARCHAR(512));" )
154
- for uuid in self .test_results .keys ():
155
- for version in self .test_results [uuid ].keys ():
156
- for function_name in self .test_results [uuid ][version ].keys ():
157
- for named_pipe in self .test_results [uuid ][version ][function_name ].keys ():
158
- for test_result in self .test_results [uuid ][version ][function_name ][named_pipe ]:
159
- cursor .execute ("INSERT INTO results VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)" , (
160
- target ,
161
- uuid ,
162
- version ,
163
- named_pipe ,
164
- test_result ["protocol" ]["shortname" ],
165
- test_result ["protocol" ]["longname" ],
166
- function_name ,
167
- test_result ["testresult" ],
168
- str (bytes (test_result ["exploitpath" ], 'utf-8' ))[2 :- 1 ].replace ('\\ \\ ' , '\\ ' )
157
+ cursor .execute ("DELETE FROM results;" )
158
+ for target in self .test_results .keys ():
159
+ for uuid in self .test_results [target ].keys ():
160
+ for version in self .test_results [target ][uuid ].keys ():
161
+ for function_name in self .test_results [target ][uuid ][version ].keys ():
162
+ for named_pipe in self .test_results [target ][uuid ][version ][function_name ].keys ():
163
+ for test_result in self .test_results [target ][uuid ][version ][function_name ][named_pipe ]:
164
+ cursor .execute ("INSERT INTO results VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)" , (
165
+ target ,
166
+ uuid ,
167
+ version ,
168
+ named_pipe ,
169
+ test_result ["protocol" ]["shortname" ],
170
+ test_result ["protocol" ]["longname" ],
171
+ function_name ,
172
+ test_result ["testresult" ],
173
+ str (bytes (test_result ["exploitpath" ], 'utf-8' ))[2 :- 1 ].replace ('\\ \\ ' , '\\ ' )
174
+ )
169
175
)
170
- )
171
176
# Commit your changes in the database
172
177
conn .commit ()
173
178
# Closing the connection
0 commit comments