acasown.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import ripe
  2. import censys
  3. import bong
  4. import webtech
  5. import sys
  6. import json
  7. import ripe
  8. import censys
  9. import bong
  10. import webtech
  11. import sys
  12. import json
  13. r = ripe.Ripe()
  14. c = censys.Censys_WEB("stripped", "stripped")
  15. b = bong.Bing()
  16. w = webtech.WebTech(options={'json': True})
  17. targets = r.search(sys.argv[1])
  18. print("Found " + str(len(targets)) + " ranges from Ripe")
  19. hosts = c.search_ipv4(c.build_query_ipv4(targets))
  20. print("Found " + str(len(hosts)) + " hosts from Censys")
  21. hosts_bing = b.search_hosts(hosts)
  22. result = []
  23. for host in hosts:
  24. result_ip = host['ip']
  25. result_vhosts = host['vhosts']
  26. result_urls = []
  27. for host_bing in hosts_bing:
  28. if host_bing['ip'] == result_ip:
  29. result_urls = host_bing['urls']
  30. for vhost in host_bing['vhosts']:
  31. if vhost not in result_vhosts:
  32. result_vhosts.append(vhost)
  33. result.append({'ip': result_ip, 'urls': result_urls, 'vhosts': list(dict.fromkeys(result_vhosts)), 'protocols': host['protocols']})
  34. print("Result has " + str(len(result)) + " entries")
  35. final = {}
  36. for host in result:
  37. if "443/https" in host['protocols']:
  38. try:
  39. url = 'https://' + host['ip']
  40. report = w.start_from_url(url, timeout=2)
  41. final[url] = report
  42. except webtech.utils.ConnectionException:
  43. print("Site down " + url)
  44. if "80/http" in host['protocols']:
  45. try:
  46. url = 'http://' + host['ip']
  47. report = w.start_from_url('http://' + host['ip'], timeout=2)
  48. final[url] = report
  49. except webtech.utils.ConnectionException:
  50. print("Site down " + url)
  51. for vhost in host['vhosts']:
  52. if "443/https" in host['protocols']:
  53. try:
  54. url = 'https://' + host['ip'] + ' (' + vhost + ')'
  55. report = w.start_from_url(url, headers={'Host': vhost}, timeout=2)
  56. final[url] = report
  57. except webtech.utils.ConnectionException:
  58. print("Site down " + url)
  59. if "80/http" in host['protocols']:
  60. try:
  61. url = 'http://' + host['ip'] + ' (' + vhost + ')'
  62. report = w.start_from_url('http://' + host['ip'], headers={'Host': vhost}, timeout=2)
  63. final[url] = report
  64. except webtech.utils.ConnectionException:
  65. print("Site down " + url)
  66. for urls in host['urls']:
  67. try:
  68. report = w.start_from_url(url, timeout=2)
  69. final[url] = report
  70. except webtech.utils.ConnectionException:
  71. print("Site down " + url)
  72. print(json.dumps(final, indent=4))