From ae967ef84ec62c9a0f6549827b72c8e10e890806 Mon Sep 17 00:00:00 2001 From: NotoriousRebel Date: Mon, 17 Feb 2020 00:33:33 -0500 Subject: [PATCH 1/2] If host did not resolve to ip strip colon from it. --- theHarvester/__main__.py | 5 +++-- theHarvester/lib/hostchecker.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/theHarvester/__main__.py b/theHarvester/__main__.py index acde95b3..8384039b 100644 --- a/theHarvester/__main__.py +++ b/theHarvester/__main__.py @@ -428,9 +428,10 @@ async def handler(lst): """full_host = hostchecker.Checker(all_hosts) full, ips = await full_host.check()""" db = stash.StashManager() - full.sort(key=lambda el: el.split(':')[0]) + full = [host if ':' in host else word in host.split(':')[0] and host for host in full] + full = [host for host in full if host] + full.sort(key=lambda el: el.split(':')[0] if el else ':' in el and el) for host in full: - host = str(host) print(host) host_ip = [netaddr_ip.format() for netaddr_ip in sorted([netaddr.IPAddress(ip) for ip in ips])] await db.store_all(word, host_ip, 'ip', 'DNS-resolver') diff --git a/theHarvester/lib/hostchecker.py b/theHarvester/lib/hostchecker.py index 9d0ffa40..bc19a18d 100644 --- a/theHarvester/lib/hostchecker.py +++ b/theHarvester/lib/hostchecker.py @@ -28,7 +28,7 @@ async def query(host, resolver) -> Tuple[str, Any]: else: return f"{host}:{', '.join(map(str, addresses))}", addresses except Exception: - return f"{host}:", tuple() + return f"{host}", tuple() async def query_all(self, resolver) -> list: results = await asyncio.gather(*[asyncio.create_task(self.query(host, resolver)) From 5a4b6cee78a05dcceb64b3464b6d71d25d2f3e2d Mon Sep 17 00:00:00 2001 From: NotoriousRebel Date: Mon, 17 Feb 2020 10:08:26 -0500 Subject: [PATCH 2/2] Updated how final list gets displayed. --- theHarvester/__main__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/theHarvester/__main__.py b/theHarvester/__main__.py index 8384039b..7867fe54 100644 --- a/theHarvester/__main__.py +++ b/theHarvester/__main__.py @@ -425,12 +425,10 @@ async def handler(lst): print('\n[*] Hosts found: ' + str(len(all_hosts))) print('---------------------') all_hosts = sorted(list(set(all_hosts))) - """full_host = hostchecker.Checker(all_hosts) - full, ips = await full_host.check()""" db = stash.StashManager() - full = [host if ':' in host else word in host.split(':')[0] and host for host in full] + full = [host if ':' in host and word in host else word in host.split(':')[0] and host for host in full] full = [host for host in full if host] - full.sort(key=lambda el: el.split(':')[0] if el else ':' in el and el) + full.sort(key=lambda el: el.split(':')[0]) for host in full: print(host) host_ip = [netaddr_ip.format() for netaddr_ip in sorted([netaddr.IPAddress(ip) for ip in ips])]