@@ -281,6 +281,62 @@ def do_check(self, args):
281
281
self ._print_item (error , Fore .RED )
282
282
return False
283
283
284
+ # 处理指定多个目标的情况
285
+ if self .module_instance .multi_target :
286
+ # 读取多个目标
287
+ target_type = self .module_instance .target_type
288
+ target_field = None
289
+
290
+ if target_type == "tcp" :
291
+ target_field = "HOST"
292
+ elif target_type == "http" :
293
+ target_field = "URL"
294
+
295
+ target_filename = self .module_instance .options .get_option (target_field )
296
+
297
+ try :
298
+ target_file = open (target_filename , 'r' )
299
+ self .module_instance .targets = []
300
+ for line in target_file .readlines ():
301
+ self .module_instance .targets .append (line .strip ())
302
+ self .module_instance .multi_target = True
303
+ except IOError as e :
304
+ self ._print_item (e , color = Fore .RED )
305
+ return False
306
+
307
+ # 将targets数组中的目标写到队列中
308
+ targets = self .module_instance .targets
309
+ targets_queue = Queue ()
310
+ for target in targets :
311
+ targets_queue .put (target )
312
+
313
+ while not targets_queue .empty ():
314
+ [target , port ] = module .parse_ip_port (targets_queue .get ())
315
+ exp = self .module_class .Exploit ()
316
+ exp .options .set_option (target_field , target )
317
+ exp .options .set_option ("TIMEOUT" , self .module_instance .options .get_option ("TIMEOUT" ))
318
+ if port :
319
+ exp .options .set_option ("PORT" , port )
320
+ else :
321
+ exp .options .set_option ("PORT" , self .module_instance .options .get_option ("PORT" ))
322
+
323
+ exploit_result = exp .check ()
324
+
325
+ if exploit_result is None :
326
+ self ._print_item ("Check Error: check function no results returned" )
327
+ return None
328
+
329
+ if exploit_result .status :
330
+ self ._print_item (exploit_result .success_message )
331
+ else :
332
+ self ._print_item (exploit_result .error_message , color = Fore .RED )
333
+
334
+ self .poutput ("{style}[*]{style_end} module execution completed" .format (
335
+ style = Fore .BLUE + Style .BRIGHT ,
336
+ style_end = Style .RESET_ALL
337
+ ))
338
+ return None
339
+
284
340
exploit_result = self .module_instance .check ()
285
341
286
342
if exploit_result is None :
0 commit comments