Exemple #1
0
 def run(self):
     print(banner)
     dt = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
     print(f'[*] Starting OneForAll @ {dt}\n')
     logger.log('INFOR', f'开始运行OneForAll')
     self.domains = utils.get_domains(self.target)
     if self.domains:
         for self.domain in self.domains:
             collect = Collect(self.domain, export=False)
             collect.run()
             if self.brute:
                 # 由于爆破会有大量dns解析请求 并发常常会导致其他任务中的网络请求超时
                 brute = AIOBrute(self.domain)
                 brute.run()
             table_name = self.domain.replace('.', '_')
             db_conn = database.connect_db()
             self.datas = database.get_data(db_conn, table_name).as_dict()
             loop = asyncio.get_event_loop()
             asyncio.set_event_loop(loop)
             self.datas = loop.run_until_complete(resolve.bulk_query_a(self.datas))
             self.datas = loop.run_until_complete(request.bulk_get_request(self.datas, self.port))
             loop.run_until_complete(asyncio.sleep(0.25))  # 在关闭事件循环前加入一小段延迟让底层连接得到关闭的缓冲时间
             loop.close()
             database.clear_table(db_conn, table_name)
             database.save_db(db_conn, table_name, self.datas)
             # 数据库导出
             if not self.path:
                 self.path = config.result_save_path.joinpath(f'{self.domain}.{self.format}')
             dbexport.export(table_name, db_conn, self.valid, self.path, self.format, self.output)
             db_conn.close()
     else:
         logger.log('FATAL', f'获取域名失败')
     logger.log('INFOR', f'结束运行OneForAll')
Exemple #2
0
 def save_db(self):
     lock.acquire()
     db_conn = database.connect_db()
     table_name = self.domain.replace('.', '_')
     database.create_table(db_conn, table_name)
     source, results = self.results
     database.save_db(db_conn, table_name, results, source)  # 将结果存入数据库中
     lock.release()
Exemple #3
0
    def run(self, rx_queue=None):
        self.domains = utils.get_domains(self.target)
        while self.domains:
            self.domain = self.domains.pop()
            start = time.time()
            db_conn = database.connect_db()
            table_name = self.domain.replace('.', '_')
            database.create_table(db_conn, table_name)
            if not rx_queue:
                rx_queue = queue.Queue()
            logger.log('INFOR', f'开始执行{self.source}模块爆破域名{self.domain}')
            logger.log(
                'INFOR',
                f'{self.source}模块使用{self.processes}个进程乘{self.coroutine}个协程')
            # logger.log('INFOR', f'{self.source}模块使用个进程乘{self.coroutine}个协程')
            if self.recursive_brute and not self.fuzz:  # fuzz模式不使用递归爆破
                logger.log('INFOR', f'开始递归爆破{self.domain}的第1层子域')
            loop = asyncio.get_event_loop()
            asyncio.set_event_loop(loop)
            loop.run_until_complete(self.main(self.domain, rx_queue))

            # 递归爆破下一层的子域
            if self.recursive_brute and not self.fuzz:  # fuzz模式不使用递归爆破
                for layer_num in range(
                        1,
                        self.recursive_depth):  # 之前已经做过1层子域爆破 当前实际递归层数是layer+1
                    logger.log('INFOR',
                               f'开始递归爆破{self.domain}的第{layer_num + 1}层子域')
                    for subdomain in self.subdomains.copy():
                        if subdomain.count('.') - self.domain.count(
                                '.') == layer_num:  # 进行下一层子域爆破的限制条件
                            loop.run_until_complete(
                                self.main(subdomain, rx_queue))

            while not rx_queue.empty():  # 队列不空就一直取数据存数据库
                source, results = rx_queue.get()
                database.save_db(db_conn, table_name, results,
                                 source)  # 将结果存入数据库中
            database.copy_table(db_conn, table_name)
            database.deduplicate_subdomain(db_conn, table_name)
            database.remove_invalid(db_conn, table_name)

            end = time.time()
            self.elapsed = round(end - start, 1)
            logger.log('INFOR', f'结束执行{self.source}模块爆破域名{self.domain}')
            logger.log(
                'INFOR',
                f'{self.source}模块耗时{self.elapsed}秒发现{self.domain}的域名{len(self.subdomains)}个'
            )
            logger.log(
                'DEBUG',
                f'{self.source}模块发现{self.domain}的的域名 {self.subdomains}')