diff --git a/conf/config.json b/conf/config.json index ea5b775..7b4a27b 100644 --- a/conf/config.json +++ b/conf/config.json @@ -1,6 +1,7 @@ { "common": { - "timeout": 30 + "timeout": 30, + "dns_servers": "8.8.8.8, 8.8.4.4, 1.1.1.1, 1.0.0.1" }, "ssl_cert": { "ssl_port": 443 @@ -12,7 +13,6 @@ "threads": 50, "redirect": false, "verify_ssl": false, - "dns_server": "8.8.8.8, 8.8.4.4, 1.1.1.1, 1.0.0.1", "extension": "" }, "export": { diff --git a/finalrecon.py b/finalrecon.py index b7935b7..4d9de50 100644 --- a/finalrecon.py +++ b/finalrecon.py @@ -66,7 +66,7 @@ r=config.dir_enum_redirect, s=config.dir_enum_sslv, sp=config.ssl_port, - d=config.dir_enum_dns, + d=config.custom_dns, e=config.dir_enum_ext, o=config.export_fmt, cd=config.usr_data @@ -251,12 +251,12 @@ def save_key(key_string): headers(target, out_settings, data) cert(hostname, sslp, out_settings, data) whois_lookup(domain, domain_suffix, path_to_script, out_settings, data) - dnsrec(hostname, out_settings, data) + dnsrec(hostname, dserv, out_settings, data) if not type_ip and not private_ip: subdomains(hostname, tout, out_settings, data, conf_path) scan(ip, out_settings, data, pscan_threads) crawler(target, protocol, netloc, out_settings, data) - hammer(target, threads, tout, wdlist, redir, sslv, dserv, out_settings, data, filext) + hammer(target, threads, tout, wdlist, redir, sslv, out_settings, data, filext) timetravel(target, data, out_settings) if headinfo: @@ -282,7 +282,7 @@ def save_key(key_string): if dns: from modules.dns import dnsrec log_writer('Starting DNS enum...') - dnsrec(hostname, out_settings, data) + dnsrec(hostname, dserv, out_settings, data) if subd and not type_ip and not private_ip: from modules.subdom import subdomains @@ -307,7 +307,7 @@ def save_key(key_string): if dirrec: from modules.dirrec import hammer log_writer('Starting dir enum...') - hammer(target, threads, tout, wdlist, redir, sslv, dserv, out_settings, data, filext) + hammer(target, threads, tout, wdlist, redir, sslv, out_settings, data, filext) if not any([full, headinfo, sslinfo, whois, crawl, dns, subd, wback, pscan, dirrec]): print(f'\n{R}[-] Error : {C}At least One Argument is Required with URL{W}') diff --git a/modules/dirrec.py b/modules/dirrec.py index d176869..45e3e73 100644 --- a/modules/dirrec.py +++ b/modules/dirrec.py @@ -71,11 +71,10 @@ async def consumer(queue, target, session, redir, total_num_words): print(f'{Y}[!] {C}Requests : {W}{count}/{total_num_words}', end='\r') -async def run(target, threads, tout, wdlist, redir, sslv, dserv, filext, total_num_words): +async def run(target, threads, tout, wdlist, redir, sslv, filext, total_num_words): queue = asyncio.Queue(maxsize=threads) - resolver = aiohttp.AsyncResolver(nameservers=dserv.split(', ')) - conn = aiohttp.TCPConnector(limit=threads, resolver=resolver, family=socket.AF_INET, verify_ssl=sslv) + conn = aiohttp.TCPConnector(limit=threads, family=socket.AF_INET, verify_ssl=sslv) timeout = aiohttp.ClientTimeout(total=None, sock_connect=tout, sock_read=tout) async with aiohttp.ClientSession(connector=conn, timeout=timeout) as session: distrib = asyncio.create_task(insert(queue, filext, target, wdlist, redir)) @@ -131,14 +130,13 @@ def dir_output(output, data): export(output, data) -def hammer(target, threads, tout, wdlist, redir, sslv, dserv, output, data, filext): +def hammer(target, threads, tout, wdlist, redir, sslv, output, data, filext): print(f'\n{Y}[!] Starting Directory Enum...{W}\n') print(f'{G}[+] {C}Threads : {W}{threads}') print(f'{G}[+] {C}Timeout : {W}{tout}') print(f'{G}[+] {C}Wordlist : {W}{wdlist}') print(f'{G}[+] {C}Allow Redirects : {W}{redir}') print(f'{G}[+] {C}SSL Verification : {W}{sslv}') - print(f'{G}[+] {C}DNS Servers : {W}{dserv}') with open(wdlist, 'r') as wordlist: num_words = sum(1 for i in wordlist) print(f'{G}[+] {C}Wordlist Size : {W}{num_words}') @@ -150,7 +148,7 @@ def hammer(target, threads, tout, wdlist, redir, sslv, dserv, output, data, file loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) - loop.run_until_complete(run(target, threads, tout, wdlist, redir, sslv, dserv, filext, total_num_words)) + loop.run_until_complete(run(target, threads, tout, wdlist, redir, sslv, filext, total_num_words)) dir_output(output, data) loop.close() log_writer('[dirrec] Completed') diff --git a/modules/dns.py b/modules/dns.py index 0cc4630..cb5d194 100644 --- a/modules/dns.py +++ b/modules/dns.py @@ -12,7 +12,7 @@ Y = '\033[33m' # yellow -def dnsrec(domain, output, data): +def dnsrec(domain, dns_servers, output, data): result = {} print(f'\n{Y}[!] Starting DNS Enumeration...{W}\n') dns_records = ['A', 'AAAA', 'AFSDB', 'APL', 'CAA', 'CDNSKEY', 'CDS', 'CERT', @@ -24,7 +24,7 @@ def dnsrec(domain, output, data): full_ans = [] res = dns.asyncresolver.Resolver(configure=False) - res.nameservers = ['1.1.1.1', '1.0.0.1', '8.8.8.8', '8.8.4.4', '9.9.9.9', '149.112.112.112'] + res.nameservers = dns_servers async def fetch_records(res, domain, record): diff --git a/settings.py b/settings.py index 3b51dac..47e6942 100644 --- a/settings.py +++ b/settings.py @@ -20,20 +20,24 @@ if not path.exists(usr_data): makedirs(usr_data, exist_ok=True) -with open(conf_file_path, 'r') as config_file: - config_read = config_file.read() - config_json = loads(config_read) - timeout = config_json['common']['timeout'] - - ssl_port = config_json['ssl_cert']['ssl_port'] - - port_scan_th = config_json['port_scan']['threads'] - - dir_enum_th = config_json['dir_enum']['threads'] - dir_enum_redirect = config_json['dir_enum']['redirect'] - dir_enum_sslv = config_json['dir_enum']['verify_ssl'] - dir_enum_dns = config_json['dir_enum']['dns_server'] - dir_enum_ext = config_json['dir_enum']['extension'] - dir_enum_wlist = f'{path_to_script}/wordlists/dirb_common.txt' - - export_fmt = config_json['export']['format'] +while True: + with open(conf_file_path, 'r') as config_file: + config_read = config_file.read() + config_json = loads(config_read) + + try: + timeout = config_json['common']['timeout'] + custom_dns = config_json['common']['dns_servers'].split(', ') + ssl_port = config_json['ssl_cert']['ssl_port'] + port_scan_th = config_json['port_scan']['threads'] + dir_enum_th = config_json['dir_enum']['threads'] + dir_enum_redirect = config_json['dir_enum']['redirect'] + dir_enum_sslv = config_json['dir_enum']['verify_ssl'] + dir_enum_ext = config_json['dir_enum']['extension'] + dir_enum_wlist = f'{path_to_script}/wordlists/dirb_common.txt' + export_fmt = config_json['export']['format'] + except KeyError: + # reset conf.json + copytree(src_conf_path, conf_path, dirs_exist_ok=True) + else: + break