import ripe import censys import bong import webtech import sys import json import ripe import censys import bong import webtech import sys import json r = ripe.Ripe() c = censys.Censys_WEB("stripped", "stripped") b = bong.Bing() w = webtech.WebTech(options={'json': True}) targets = r.search(sys.argv[1]) print("Found " + str(len(targets)) + " ranges from Ripe") hosts = c.search_ipv4(c.build_query_ipv4(targets)) print("Found " + str(len(hosts)) + " hosts from Censys") hosts_bing = b.search_hosts(hosts) result = [] for host in hosts: result_ip = host['ip'] result_vhosts = host['vhosts'] result_urls = [] for host_bing in hosts_bing: if host_bing['ip'] == result_ip: result_urls = host_bing['urls'] for vhost in host_bing['vhosts']: if vhost not in result_vhosts: result_vhosts.append(vhost) result.append({'ip': result_ip, 'urls': result_urls, 'vhosts': list(dict.fromkeys(result_vhosts)), 'protocols': host['protocols']}) print("Result has " + str(len(result)) + " entries") final = {} for host in result: if "443/https" in host['protocols']: try: url = 'https://' + host['ip'] report = w.start_from_url(url, timeout=2) final[url] = report except webtech.utils.ConnectionException: print("Site down " + url) if "80/http" in host['protocols']: try: url = 'http://' + host['ip'] report = w.start_from_url('http://' + host['ip'], timeout=2) final[url] = report except webtech.utils.ConnectionException: print("Site down " + url) for vhost in host['vhosts']: if "443/https" in host['protocols']: try: url = 'https://' + host['ip'] + ' (' + vhost + ')' report = w.start_from_url(url, headers={'Host': vhost}, timeout=2) final[url] = report except webtech.utils.ConnectionException: print("Site down " + url) if "80/http" in host['protocols']: try: url = 'http://' + host['ip'] + ' (' + vhost + ')' report = w.start_from_url('http://' + host['ip'], headers={'Host': vhost}, timeout=2) final[url] = report except webtech.utils.ConnectionException: print("Site down " + url) for urls in host['urls']: try: report = w.start_from_url(url, timeout=2) final[url] = report except webtech.utils.ConnectionException: print("Site down " + url) print(json.dumps(final, indent=4))