def run(self): """ OneForAll running entrance :return: All subdomain results :rtype: list """ print(oneforall_banner) dt = datetime.now().strftime('%Y-%m-%d %H:%M:%S') print(f'[*] Starting OneForAll @ {dt}\n') logger.log('DEBUG', 'Python ' + utils.python_version()) logger.log('DEBUG', 'OneForAll ' + version) utils.check_dep() self.access_internet, self.in_china = utils.get_net_env() if self.access_internet and settings.enable_check_version: utils.check_version(version) logger.log('INFOR', 'Start running OneForAll') self.config_param() self.check_param() self.domains = utils.get_domains(self.target, self.targets) count = len(self.domains) logger.log('INFOR', f'Got {count} domains') if not count: logger.log('FATAL', 'Failed to obtain domain') exit(1) for domain in self.domains: self.domain = utils.get_main_domain(domain) self.main() if count > 1: utils.export_all(self.alive, self.fmt, self.path, self.datas) logger.log('INFOR', 'Finished OneForAll')
def run(self): """ OneForAll running entrance :return: All subdomain results :rtype: list """ print(oneforall_banner) dt = datetime.now().strftime('%Y-%m-%d %H:%M:%S') print(f'[*] Starting OneForAll @ {dt}\n') utils.check_env() if settings.enable_check_version: utils.check_version(version) logger.log('DEBUG', 'Python ' + utils.python_version()) logger.log('DEBUG', 'OneForAll ' + version) logger.log('INFOR', 'Start running OneForAll') self.config_param() self.check_param() self.domains = utils.get_domains(self.target, self.targets) if self.domains: for domain in self.domains: self.domain = utils.get_main_domain(domain) self.main() utils.export_all(self.alive, self.format, self.path, self.datas) else: logger.log('FATAL', 'Failed to obtain domain') logger.log('INFOR', 'Finished OneForAll')
def run(self): start = time.time() logger.log('INFOR', f'开始执行{self.source}模块') self.subdomains = utils.get_domains(self.target) self.format = utils.check_format(self.format, len(self.subdomains)) timestamp = utils.get_timestamp() name = f'takeover_check_result_{timestamp}' self.path = utils.check_path(self.path, name, self.format) if self.subdomains: logger.log('INFOR', f'正在检查子域接管风险') self.fingerprints = get_fingerprint() self.results.headers = ['subdomain', 'cname'] # 创建待检查的子域队列 for domain in self.subdomains: self.subdomainq.put(domain) # 检查线程 for _ in range(self.thread): check_thread = Thread(target=self.check, daemon=True) check_thread.start() # 进度线程 progress_thread = Thread(target=self.progress, daemon=True) progress_thread.start() self.subdomainq.join() self.save() else: logger.log('FATAL', f'获取域名失败') end = time.time() elapse = round(end - start, 1) logger.log( 'INFOR', f'{self.source}模块耗时{elapse}秒' f'发现{len(self.results)}个子域存在接管风险') logger.log('INFOR', f'子域接管风险检查结果 {self.path}') logger.log('INFOR', f'结束执行{self.source}模块')
def run(self): start = time.time() logger.log('INFOR', f'Start running {self.source} module') self.subdomains = utils.get_domains(self.target) self.format = utils.check_format(self.format, len(self.subdomains)) timestamp = utils.get_timestamp() name = f'takeover_check_result_{timestamp}' self.path = utils.check_path(self.path, name, self.format) if self.subdomains: logger.log('INFOR', f'Checking subdomain takeover') self.fingerprints = get_fingerprint() self.results.headers = ['subdomain', 'cname'] # 创建待检查的子域队列 for domain in self.subdomains: self.subdomainq.put(domain) # 检查线程 for _ in range(self.thread): check_thread = Thread(target=self.check, daemon=True) check_thread.start() # 进度线程 progress_thread = Thread(target=self.progress, daemon=True) progress_thread.start() self.subdomainq.join() self.save() else: logger.log('FATAL', f'Failed to obtain domain') end = time.time() elapse = round(end - start, 1) logger.log( 'INFOR', f'{self.source} module takes {elapse} seconds, ' f'There are {len(self.results)} subdomains exists takeover') logger.log('INFOR', f'Subdomain takeover results: {self.path}') logger.log('INFOR', f'Finished {self.source} module')
def run(self): start = time.time() logger.log('INFOR', f'正在检查子域接管风险') self.format = utils.check_format(self.format) self.dpath = utils.check_dpath(self.dpath) self.subdomains = utils.get_domains(self.target) if self.subdomains: self.fingerprints = get_fingerprint() self.results.headers = ['subdomain', 'cname'] for domain in self.subdomains: self.domainq.put(domain) threads = [] for _ in range(self.thread): thread = Thread(target=self.check, daemon=True) thread.start() threads.append(thread) for thread in threads: thread.join() self.save() else: logger.log('FATAL', f'获取域名失败') end = time.time() elapsed = round(end - start, 1) logger.log( 'INFOR', f'{self.source}模块耗时{elapsed}秒' f'发现{len(self.results)}个子域存在接管风险')
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')
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 = Database() db.create_table(self.domain) if not rx_queue: rx_queue = queue.Queue() logger.log('INFOR', f'开始执行{self.source}模块爆破域名{self.domain}') logger.log('INFOR', f'使用{self.process}进程乘{self.coroutine}协程') # fuzz模式不使用递归爆破 if self.recursive_brute and not self.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)) # 递归爆破下一层的子域 # fuzz模式不使用递归爆破 if self.recursive_brute and not self.fuzz: for layer_num in range(1, self.recursive_depth): # 之前已经做过1层子域爆破 当前实际递归层数是layer+1 logger.log('INFOR', f'开始递归爆破{self.domain}的' f'第{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() # 将结果存入数据库中 db.save_db(self.domain, results, source) end = time.time() self.elapsed = round(end - start, 1) logger.log('INFOR', f'结束执行{self.source}模块爆破域名{self.domain}') length = len(self.subdomains) logger.log( 'INFOR', f'{self.source}模块耗时{self.elapsed}秒' f'发现{self.domain}的域名{length}个') logger.log( 'DEBUG', f'{self.source}模块发现{self.domain}的域名:\n' f'{self.subdomains}') # 数据库导出 if self.export: if not self.path: name = f'{self.domain}_brute.{self.format}' self.path = config.result_save_path.joinpath(name) dbexport.export(self.domain, valid=self.valid, path=self.path, format=self.format, show=self.show)
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: self.main() else: logger.log('FATAL', f'获取域名失败') logger.log('INFOR', f'结束运行OneForAll')
def export(target, type='target', db=None, alive=False, limit=None, path=None, format='csv', show=False): """ OneForAll export from database module Example: python3 dbexport.py --target name --format csv --dir= ./result.csv python3 dbexport.py --db result.db --target name --show False python3 dbexport.py --target table_name --tb True --show False Note: --format rst/csv/tsv/json/yaml/html/jira/xls/xlsx/dbf/latex/ods (result format) --path Result directory (default directory is ./results) :param str target: Table to be exported :param str type: Type of target :param str db: Database path to be exported (default ./results/result.sqlite3) :param bool alive: Only export the results of alive subdomains (default False) :param str limit: Export limit (default None) :param str format: Result format (default csv) :param str path: Result directory (default None) :param bool show: Displays the exported data in terminal (default False) """ if type == 'target': database = Database(db) domains = utils.get_domains(target) datas = [] if domains: for domain in domains: table_name = domain_to_table(domain) rows = database.export_data(table_name, alive, limit) if rows is None: continue data = export_data(format, path, rows, show, table_name, target) datas.extend(data) database.close() if len(domains) > 1: utils.export_all(alive, format, path, datas) elif type == 'table': database = Database(db) rows = database.export_data(target, alive, limit) data = export_data(format, path, rows, show, target, target) database.close() return data
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}')
def run(self): print(banner) dt = datetime.now().strftime('%Y-%m-%d %H:%M:%S') print(f'[*] Starting OneForAll @ {dt}\n') logger.log('DEBUG', 'Python ' + utils.python_version()) logger.log('DEBUG', 'OneForAll ' + version) logger.log('INFOR', f'开始运行OneForAll') self.domains = utils.get_domains(self.target) if self.domains: for self.domain in self.domains: self.main() utils.export_all(self.format, self.path, self.datas) else: logger.log('FATAL', f'获取域名失败') logger.log('INFOR', f'结束运行OneForAll')
def run(self): logger.log('INFOR', f'Start running {self.source} module') if self.check_env: utils.check_env() self.domains = utils.get_domains(self.target, self.targets) for self.domain in self.domains: self.results = list() # 置空 all_subdomains = list() self.check_brute_params() if self.recursive_brute: logger.log( 'INFOR', f'Start recursively brute the 1 layer subdomain' f' of {self.domain}') valid_subdomains = self.main(self.domain) all_subdomains.extend(valid_subdomains) # 递归爆破下一层的子域 # fuzz模式不使用递归爆破 if self.recursive_brute: for layer_num in range(1, self.recursive_depth): # 之前已经做过1层子域爆破 当前实际递归层数是layer+1 logger.log( 'INFOR', f'Start recursively brute the {layer_num + 1} ' f'layer subdomain of {self.domain}') for subdomain in all_subdomains: self.place = '*.' + subdomain # 进行下一层子域爆破的限制条件 num = subdomain.count('.') - self.domain.count('.') if num == layer_num: valid_subdomains = self.main(subdomain) all_subdomains.extend(valid_subdomains) logger.log( 'INFOR', f'Finished {self.source} module to brute {self.domain}') if not self.path: name = f'{self.domain}_brute_result.{self.format}' self.path = settings.result_save_dir.joinpath(name) # 数据库导出 if self.export: dbexport.export(self.domain, type='table', alive=self.alive, limit='resolve', path=self.path, format=self.format)
def run(self): logger.log('INFOR', f'Start running {self.source} module') if self.in_china is None: _, self.in_china = utils.get_net_env() self.domains = utils.get_domains(self.target, self.targets) for self.domain in self.domains: self.results = list() # 置空 all_subdomains = list() self.init_dict_path() self.check_brute_params() if self.recursive_brute: logger.log('INFOR', f'Start recursively brute the 1 layer subdomain' f' of {self.domain}') valid_subdomains = self.main(self.domain) all_subdomains.extend(valid_subdomains) # Recursively # Fuzz mode does not use recursive blasting if self.recursive_brute: for layer_num in range(1, self.recursive_depth): # I have done 1 layer of subdomain blasting before, and the actual number of recursive layers is layer+1 logger.log('INFOR', f'Start recursively brute the {layer_num + 1} ' f'layer subdomain of {self.domain}') for subdomain in all_subdomains: self.place = '*.' + subdomain # Restrictions for the next level of subdomain blasting num = subdomain.count('.') - self.domain.count('.') if num == layer_num: valid_subdomains = self.main(subdomain) all_subdomains.extend(valid_subdomains) logger.log('INFOR', f'Finished {self.source} module to brute {self.domain}') if not self.path: name = f'{self.domain}_brute_result.{self.fmt}' self.path = settings.result_save_dir.joinpath(name) # Database export if self.export: export.export_data(self.domain, alive=self.alive, limit='resolve', path=self.path, fmt=self.fmt)
def export_data(target, db=None, alive=False, limit=None, path=None, fmt='csv', show=False): """ Garuda export from database module Example: python3 export.py --target name --fmt csv --dir= ./result.csv python3 export.py --target name --tb True --show False python3 export.py --db result.db --target name --show False Note: --fmt csv/json (result format) --path Result directory (default directory is ./results) :param str target: Table to be exported :param str db: Database path to be exported (default ./results/result.sqlite3) :param bool alive: Only export the results of alive subdomains (default False) :param str limit: Export limit (default None) :param str fmt: Result format (default csv) :param str path: Result directory (default None) :param bool show: Displays the exported data in terminal (default False) """ database = Database(db) domains = utils.get_domains(target) datas = list() if domains: for domain in domains: table_name = domain.replace('.', '_') rows = database.export_data(table_name, alive, limit) if rows is None: continue data, _, _ = do_export(fmt, path, rows, show, domain, target) datas.extend(data) database.close() if len(domains) > 1: utils.export_all(alive, fmt, path, datas) return datas
def run(self): start = time.time() logger.log('INFOR', f'Start running {self.source} module') if isinstance(self.targets, set): self.subdomains = self.targets else: self.subdomains = utils.get_domains(self.target, self.targets) self.fmt = utils.check_format(self.fmt) timestamp = utils.get_timestamp() name = f'takeover_check_result_{timestamp}' self.path = utils.check_path(self.path, name, self.fmt) if self.subdomains: logger.log('INFOR', f'Checking subdomain takeover') self.fingerprints = get_fingerprint() self.results.headers = ['subdomain', 'cname'] for domain in self.subdomains: self.queue.put(domain) progress_thread = Thread(target=self.progress, name='ProgressThread', daemon=True) progress_thread.start() for i in range(self.thread): check_thread = Thread(target=self.check, name=f'CheckThread{i}', daemon=True) check_thread.start() self.queue.join() self.save() else: logger.log('FATAL', f'Failed to obtain domain') end = time.time() elapse = round(end - start, 1) logger.log( 'ALERT', f'{self.source} module takes {elapse} seconds, ' f'There are {len(self.results)} subdomains exists takeover') logger.log('INFOR', f'Subdomain takeover results: {self.path}') logger.log('INFOR', f'Finished {self.source} module')
def run(self): logger.log('INFOR', f'开始执行{self.source}模块') if self.check_env: utils.check_env() self.domains = utils.get_domains(self.target) all_subdomains = list() for self.domain in self.domains: self.check_brute_params() if self.recursive_brute: logger.log('INFOR', f'开始递归爆破{self.domain}的第1层子域') valid_subdomains = self.main(self.domain) all_subdomains.extend(valid_subdomains) # 递归爆破下一层的子域 # fuzz模式不使用递归爆破 if self.recursive_brute: for layer_num in range(1, self.recursive_depth): # 之前已经做过1层子域爆破 当前实际递归层数是layer+1 logger.log('INFOR', f'开始递归爆破{self.domain}的' f'第{layer_num + 1}层子域') for subdomain in all_subdomains: self.place = '*.' + subdomain # 进行下一层子域爆破的限制条件 num = subdomain.count('.') - self.domain.count('.') if num == layer_num: valid_subdomains = self.main(subdomain) all_subdomains.extend(valid_subdomains) logger.log('INFOR', f'结束执行{self.source}模块爆破域名{self.domain}') if not self.path: name = f'{self.domain}_brute_result.{self.format}' self.path = config.result_save_dir.joinpath(name) # 数据库导出 if self.export: dbexport.export(self.domain, alive=self.alive, limit='resolve', path=self.path, format=self.format)
def run(self): """ OneForAll运行入口 :return: 总的子域结果 :rtype: list """ # print(banner) # dt = datetime.now().strftime('%Y-%m-%d %H:%M:%S') # print(f'[*] Starting OneForAll @ {dt}\n') # logger.log('DEBUG', 'Python ' + utils.python_version()) # logger.log('DEBUG', 'OneForAll ' + version) logger.log('INFOR', f'开始运行OneForAll') self.config() self.domains = utils.get_domains(self.target) if self.domains: for self.domain in self.domains: date = self.main() # utils.export_all(self.format, self.path, self.datas) # 将结果输出到文件 return self.data else: logger.log('FATAL', f'获取域名失败') logger.log('INFOR', f'结束运行OneForAll')
def run(self): start = time.time() logger.log('INFOR', f'开始执行{self.source}模块') self.format = utils.check_format(self.format) self.dpath = utils.check_dpath(self.dpath) self.subdomains = utils.get_domains(self.target) if self.subdomains: logger.log('INFOR', f'正在检查子域接管风险') self.fingerprints = get_fingerprint() self.results.headers = ['subdomain', 'cname'] # 创建待检查的子域队列 for domain in self.subdomains: self.subdomainq.put(domain) # 设置进度 self.bar.total = self.subdomainq.qsize() self.bar.desc = 'Progress' self.bar.ncols = True # 进度线程 threads = [] thread = Thread(target=self.progress, daemon=True) thread.start() threads.append(thread) # 检查线程 for _ in range(self.thread): thread = Thread(target=self.check, daemon=True) thread.start() threads.append(thread) for thread in threads: thread.join() self.save() else: logger.log('FATAL', f'获取域名失败') end = time.time() elapsed = round(end - start, 1) logger.log('INFOR', f'{self.source}模块耗时{elapsed}秒' f'发现{len(self.results)}个子域存在接管风险') logger.log('DEBUG', f'结束执行{self.source}模块')