Modified hostchecker to use corountines,also added suip module (needs testing).

This commit is contained in:
NotoriousRebel 2019-10-01 17:27:03 -04:00
parent 1286ba4b75
commit ffe0ce88e4
3 changed files with 38 additions and 2 deletions

View file

@ -346,6 +346,19 @@ def start():
else:
pass
elif engineitem == 'suip':
print('\033[94m[*] Searching suip. \033[0m')
from theHarvester.discovery import suip
try:
suip_search = suip.SearchSuip(word)
suip_search.process()
hosts = filter(suip_search.get_hostnames())
all_hosts.extend(hosts)
db = stash.stash_manager()
db.store_all(word, all_hosts, 'host', 'suip')
except Exception as e:
print(e)
elif engineitem == 'threatcrowd':
print('\033[94m[*] Searching Threatcrowd. \033[0m')
from theHarvester.discovery import threatcrowd
@ -451,15 +464,16 @@ def start():
if len(all_hosts) == 0:
print('\n[*] No hosts found.\n\n')
else:
import asyncio
print('\n[*] Hosts found: ' + str(len(all_hosts)))
print('---------------------')
all_hosts = sorted(list(set(all_hosts)))
full_host = hostchecker.Checker(all_hosts)
full = full_host.check()
full = asyncio.run(full_host.check())
#full = full_host.check()
for host in full:
host = str(host)
print(host.lower())
db = stash.stash_manager()
db.store_all(word, host_ip, 'ip', 'DNS-resolver')

View file

@ -82,6 +82,7 @@ def get_supportedengines() -> Set[Union[str, Any]]:
'netcraft',
'otx',
'securityTrails',
'suip',
'threatcrowd',
'trello',
'twitter',

View file

@ -25,6 +25,26 @@ async def query(host, resolver) -> [list, str]:
# print(f'An error occurred in query: {e}')
return f"{host}:"
async def query_all(self, resolver) -> list:
results = await asyncio.gather(*[asyncio.create_task(self.query(host, resolver))
for host in self.hosts])
return results
async def check(self):
import pprint as p
p.pprint(self.hosts, indent=4)
loop = asyncio.get_event_loop()
resolver = aiodns.DNSResolver(loop=loop)
results = await self.query_all(resolver)
print('results: ', results)
import pprint as p
p.pprint(results, indent=4)
#loop.close()
return self.realhosts
"""
def check(self):
loop = asyncio.get_event_loop()
resolver = aiodns.DNSResolver(loop=loop)
@ -42,3 +62,4 @@ def check(self):
self.realhosts.append(true_result)
loop.close()
return self.realhosts
"""