Skip to content

Commit 94f5ef7

Browse files
committed
feat(module): Add to specify multiple targets for the module check function
1 parent dfeec28 commit 94f5ef7

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

lib/Pocket.py

+56
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,62 @@ def do_check(self, args):
281281
self._print_item(error, Fore.RED)
282282
return False
283283

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+
284340
exploit_result = self.module_instance.check()
285341

286342
if exploit_result is None:

0 commit comments

Comments
 (0)