def main(self, domain): start = time.time() logger.log('INFOR', f'Blasting {domain} ') massdns_dir = settings.third_party_dir.joinpath('massdns') result_dir = settings.result_save_dir temp_dir = result_dir.joinpath('temp') utils.check_dir(temp_dir) massdns_path = utils.get_massdns_path(massdns_dir) timestring = utils.get_timestring() wildcard_ips = list() # 泛解析IP列表 wildcard_ttl = int() # 泛解析TTL整型值 ns_list = query_domain_ns(self.domain) ns_ip_list = query_domain_ns_a(ns_list) # DNS权威名称服务器对应A记录列表 if self.enable_wildcard is None: self.enable_wildcard = wildcard.detect_wildcard(domain) if self.enable_wildcard: wildcard_ips, wildcard_ttl = wildcard.collect_wildcard_record( domain, ns_ip_list) ns_path = utils.get_ns_path(self.in_china, self.enable_wildcard, ns_ip_list) dict_set = self.gen_brute_dict(domain) dict_name = f'generated_subdomains_{domain}_{timestring}.txt' dict_path = temp_dir.joinpath(dict_name) save_brute_dict(dict_path, dict_set) del dict_set gc.collect() output_name = f'resolved_result_{domain}_{timestring}.json' output_path = temp_dir.joinpath(output_name) log_path = result_dir.joinpath('massdns.log') check_dict() logger.log('INFOR', f'Running massdns to brute subdomains') utils.call_massdns(massdns_path, dict_path, ns_path, output_path, log_path, quiet_mode=self.quite, concurrent_num=self.concurrent_num) appear_times = stat_appear_times(output_path) self.infos, self.subdomains = deal_output(output_path, appear_times, wildcard_ips, wildcard_ttl) delete_file(dict_path, output_path) end = time.time() self.elapse = round(end - start, 1) logger.log( 'ALERT', f'{self.source} module takes {self.elapse} seconds, ' f'found {len(self.subdomains)} subdomains of {domain}') logger.log( 'DEBUG', f'{self.source} module found subdomains of {domain}: ' f'{self.subdomains}') self.gen_result() self.save_db() return self.subdomains
def main(self): """ OneForAll main process :return: subdomain results :rtype: list """ utils.init_table(self.domain) if not self.access_internet: logger.log('ALERT', 'Because it cannot access the Internet, ' 'OneForAll will not execute the subdomain collection module!') if self.access_internet: self.enable_wildcard = wildcard.detect_wildcard(self.domain) collect = Collect(self.domain) collect.run() srv = BruteSRV(self.domain) srv.run() if self.brute: # Due to there will be a large number of dns resolution requests, # may cause other network tasks to be error brute = Brute(self.domain, word=True, export=False) brute.enable_wildcard = self.enable_wildcard brute.in_china = self.in_china brute.quite = True brute.run() utils.deal_data(self.domain) # Export results without resolve if not self.dns: return self.export_data() self.data = utils.get_data(self.domain) # Resolve subdomains utils.clear_data(self.domain) self.data = resolve.run_resolve(self.domain, self.data) # Save resolve results resolve.save_db(self.domain, self.data) # Export results without HTTP request if not self.req: return self.export_data() if self.enable_wildcard: # deal wildcard self.data = wildcard.deal_wildcard(self.data) # HTTP request utils.clear_data(self.domain) request.run_request(self.domain, self.data, self.port) # Finder module if settings.enable_finder_module: finder = Finder() finder.run(self.domain, self.data, self.port) # altdns module if settings.enable_altdns_module: altdns = Altdns(self.domain) altdns.run(self.data, self.port) # Information enrichment module if settings.enable_enrich_module: enrich = Enrich(self.domain) enrich.run() # Export self.datas.extend(self.export_data()) # Scan subdomain takeover if self.takeover: subdomains = utils.get_subdomains(self.data) takeover = Takeover(targets=subdomains) takeover.run() return self.data