async def aio_resolve(subdomain_list, process_num, coroutine_num): """ 异步解析子域A记录 :param list subdomain_list: 待解析的子域列表 :param int process_num: 解析进程数 :param int coroutine_num: 每个解析进程下的协程数 :return: 解析结果 """ m = Manager() done_obj = m.Value('done', 0) # 创建一个进程间可以共享的值 loop = asyncio.get_event_loop() loop.run_in_executor(None, resolve_progress_func, done_obj, len(subdomain_list)) wrapped_resolve_func = functools.partial(do_resolve, done_obj) result_list = list() # macOS上队列大小不能超过2**15 - 1 = 32767 # https://stackoverflow.com/questions/5900985/multiprocessing-queue-maxsize-limit-is-32767 if sys.platform == 'darwin': split_subdomain_list = utils.split_list(subdomain_list, 32767) for current_subdomain_list in split_subdomain_list: async with aiomp.Pool(processes=process_num, childconcurrency=coroutine_num) as pool: result = await pool.map(wrapped_resolve_func, current_subdomain_list) result_list.extend(result) return result_list async with aiomp.Pool(processes=process_num, childconcurrency=coroutine_num) as pool: result_list = await pool.map(wrapped_resolve_func, subdomain_list) return result_list
def gen_tasks(self, domain): logger.log('INFOR', f'正在生成{domain}的字典') if self.domain != domain: # 如果domain不是self.domain,而是self.domain的子域 生成递归爆破字典 domains = gen_brute_domains(domain, self.recursive_namelist) elif self.fuzz and self.rule: # 开启fuzz模式并指定了fuzz正则规则 domains = gen_fuzz_domains(domain, self.rule) else: domains = gen_brute_domains(domain, self.wordlist) domains = list(domains) return utils.split_list(domains, 500) # 分割任务组 500个子域为一组任务
def gen_tasks(self, domain): # 如果domain不是self.domain,而是self.domain的子域 生成递归爆破字典 if self.domain != domain: logger.log('INFOR', f'使用{self.recursive_namelist}字典') domains = gen_brute_domains(domain, self.recursive_namelist) elif self.fuzz and self.rule: # 开启fuzz模式并指定了fuzz正则规则 logger.log('INFOR', f'正在生成{domain}的fuzz字典') domains = gen_fuzz_domains(domain, self.rule) else: logger.log('INFOR', f'使用{self.wordlist}字典') domains = gen_brute_domains(domain, self.wordlist) domains = list(domains) return utils.split_list(domains, self.segment) # 分割任务组