Fixed error when passing in comma seperated resolvers and allow for user to pass in --dns-resolve flag with no arguments to use default resolvers that user has.

This commit is contained in:
NotoriousRebel 2023-04-08 12:44:43 -04:00
parent dc25d583fb
commit fa57681871
3 changed files with 19 additions and 11 deletions

View file

@ -24,12 +24,16 @@ Passive:
* bingapi: Microsoft search engine, through the API (Requires an API key, see below.)
* brave: Brave search engine - https://search.brave.com/
* bufferoverun: https://tls.bufferover.run
* censys: [Censys search engine](https://search.censys.io/), will use certificates searches to enumerate subdomains and gather emails (Requires an API key, see below.) - [censys.io](https://censys.io/)
* certspotter: Cert Spotter monitors Certificate Transparency logs - https://sslmate.com/certspotter/
* criminalip Specialized Cyber Threat Intelligence (CTI) search engine - https://www.criminalip.io
* crtsh: Comodo Certificate search - https://crt.sh
* dnsdumpster: DNSdumpster search engine - https://dnsdumpster.com
@ -44,6 +48,8 @@ Passive:
* hunter: Hunter search engine (Requires an API key, see below.) - www.hunter.io
* hunterhow: Internet Search Engines For Security Researchers - https://hunter.how
* intelx: Intelx search engine (Requires an API key, see below.) - www.intelx.io
* omnisint: Project Crobat, A Centralised Searchable Open Source Project Sonar DNS Database - https://github.com/Cgboal/SonarSearch
@ -64,11 +70,9 @@ Passive:
* securityTrails: Security Trails search engine, the world's largest repository of historical DNS data<br>
(Requires an API key, see below.) - www.securitytrails.com
* shodan: Shodan search engine, will search for ports and banners from discovered hosts (Requires an API key, see below.) - www.shodanhq.com
* shodan: Shodan search engine, will search for ports and banners from discovered hosts (Requires an API key, see below.) - https://shodan.io
* sublist3r: Fast subdomains enumeration tool for penetration testers - https://api.sublist3r.com/search.php?domain=example.com
* threatcrowd: Open source threat intelligence - www.threatcrowd.org
* subdomainfinderc99: A subdomain finder is a tool used to find the subdomains of a given domain - https://subdomainfinder.c99.nl
* threatminer: Data mining for threat intelligence - https://www.threatminer.org/
@ -97,9 +101,11 @@ Documentation to setup API keys can be found at - https://github.com/laramies/th
* bing
* bufferoverun - uses the free api
* censys - API keys are required and can be retrieved from your [Censys account](https://search.censys.io/account/api).
* criminalip
* fullhunt
* github
* hunter - limited to 10 on the free plan, so you will need to do -l 10 switch
* hunterhow
* intelx
* pentesttools - $
* projecdiscovery - invite only for now
@ -110,7 +116,7 @@ Documentation to setup API keys can be found at - https://github.com/laramies/th
Install and dependencies:
-------------------------
* Python 3.10+
* Python 3.9+
* https://github.com/laramies/theHarvester/wiki/Installation

View file

@ -26,4 +26,3 @@
# As we are not using Windows, we can change the spawn method to fork for greater performance
aiomultiprocess.set_context("fork")
asyncio.run(__main__.entry_point())

View file

@ -30,7 +30,7 @@ async def start(rest_args: Optional[argparse.Namespace] = None):
parser.add_argument('-t', '--take-over', help='Check for takeovers.', default=False, action='store_true')
# TODO add dns resolver flag
parser.add_argument('-r', '--dns-resolve', help='Perform DNS resolution on subdomains with given resolver list or passed in resolvers, default False.', default="",
type=str)
type=str, nargs='?')
parser.add_argument('-n', '--dns-lookup', help='Enable DNS server lookup, default False.', default=False, action='store_true')
parser.add_argument('-c', '--dns-brute', help='Perform a DNS brute force on the domain.', default=False, action='store_true')
parser.add_argument('-f', '--filename', help='Save the results to an XML and JSON file.', default='', type=str)
@ -68,6 +68,7 @@ async def start(rest_args: Optional[argparse.Namespace] = None):
import os
if len(filename) > 2 and filename[:2] == "~/":
filename = os.path.expanduser(filename)
all_emails: List = []
all_hosts: List = []
all_ip: List = []
@ -75,7 +76,7 @@ async def start(rest_args: Optional[argparse.Namespace] = None):
dnsserver = args.dns_server # TODO arg is not used anywhere replace with resolvers wordlist arg dnsresolve
dnsresolve = args.dns_resolve
final_dns_resolver_list = []
if len(dnsresolve) > 0:
if dnsresolve is not None and len(dnsresolve) > 0:
# Three scenarios:
# 8.8.8.8
# 1.1.1.1,8.8.8.8 or 1.1.1.1, 8.8.8.8
@ -95,7 +96,7 @@ async def start(rest_args: Optional[argparse.Namespace] = None):
else:
try:
if ',' in dnsresolve:
cleaned = dnsresolve.replace(' ')
cleaned = dnsresolve.replace(' ', '')
for item in cleaned.split(','):
_ = netaddr.IPAddress(item)
final_dns_resolver_list.append(item)
@ -106,10 +107,12 @@ async def start(rest_args: Optional[argparse.Namespace] = None):
except Exception as e:
print(f'Passed in DNS resolvers are invalid double check, got error: {e}')
print(f'Dumping resolvers passed in: {e}')
sys.exit(0)
# if for some reason there are duplicates
final_dns_resolver_list = list(set(final_dns_resolver_list))
# print(f'My final list: {final_dns_resolver_list}')
engines: List = []
# If the user specifies
full: List = []
@ -167,8 +170,8 @@ async def store(search_engine: Any, source: str, process_param: Any = None, stor
if source != 'hackertarget' and source != 'pentesttools' and source != 'rapiddns':
# If source is inside this conditional it means the hosts returned must be resolved to obtain ip
# This should only be checked if --dns-resolve has a wordlist
if len(final_dns_resolver_list) > 0:
# indicates there are nameservers passed in
if dnsresolve is None or len(final_dns_resolver_list) > 0:
# indicates that -r was passed in
full_hosts_checker = hostchecker.Checker(host_names, final_dns_resolver_list)
temp_hosts, temp_ips = await full_hosts_checker.check()
ips.extend(temp_ips)