Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

added some fixes for python3 support #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__/*
colors.pyc
output/*
44 changes: 22 additions & 22 deletions danger-zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
domains_from_email = util.get_domain_from_email(email, elastic_output)

if len(domains_from_email) > 0:
print "Found domain: "
print("Found domain: ")
for i_domain in domains_from_email:
print bcolors.OKGREEN + i_domain + bcolors.ENDC
print(bcolors.OKGREEN + i_domain + bcolors.ENDC)
G.add_edge(email, i_domain)

answer1 = raw_input("Do you want to check domains? [y/n] ")
Expand All @@ -61,17 +61,17 @@
ip_help.append(i_ip)
G.add_edge(j_domain, i_ip, color='yellow')
else:
print "[*] Bye "
print("[*] Bye ")
tools.save_graph(G, email)
sys.exit()
else:
print "No domain found"
print("No domain found")
sys.exit()

if len(ip_help) > 0:
print "Found following IPs "
print("Found following IPs ")
for j_ip in ip_help:
print bcolors.OKGREEN + j_ip + bcolors.ENDC
print(bcolors.OKGREEN + j_ip + bcolors.ENDC)

answer2 = raw_input("Do you want to check IP(s)? [y/n] ")
if answer2 == "y":
Expand All @@ -80,16 +80,16 @@
domain_from_ip = util.get_domain_from_ip(k_ip, elastic_output)
for k_domain in domain_from_ip:
G.add_edge(k_ip, k_domain)
print k_domain
print(k_domain)

else:
print "[*] Bye"
print("[*] Bye")
tools.save_graph(G, email)
sys.exit()

else:
tools.save_graph(G, email)
print "No IP was found"
print("No IP was found")
sys.exit()

tools.save_graph(G, email)
Expand All @@ -102,10 +102,10 @@

domain_from_ip = util.get_domain_from_ip(address, elastic_output)

print "Found domain:"
print("Found domain:")
for i_domain in domain_from_ip:
G.add_edge(address, i_domain)
print bcolors.OKGREEN + i_domain + bcolors.ENDC
print(bcolors.OKGREEN + i_domain + bcolors.ENDC)

if len(domain_from_ip) > 0:
answer3 = raw_input("Do you want to check domain(s)? [y/n] ")
Expand All @@ -130,13 +130,13 @@
tools.save_graph(G, address)

else:
print "No domain found"
print("No domain found")
sys.exit()

if len(emails_help) > 0:
print "Found emails:"
print("Found emails:")
for j_email in emails_help:
print j_email
print(j_email)

answer4 = raw_input("Do you want to check email(s) [y/n] ")
if answer4 == 'y':
Expand All @@ -151,12 +151,12 @@
tools.save_graph(G, address)
sys.exit()
else:
print "No email found"
print("No email found")
tools.save_graph(G, address)
sys.exit()

if len(domains_help) > 0:
print "Found domains:"
print("Found domains:")

for l_domain in domains_help:
tools.finding(l_domain)
Expand All @@ -167,7 +167,7 @@
G.add_edge(l_domain, l_email)
else:
tools.save_graph(G, address)
print "No domain found"
print("No domain found")
sys.exit()

tools.save_graph(G, address)
Expand All @@ -182,17 +182,17 @@
ip_tmp = util.get_ip_from_domain(domain, elastic_output)
email_tmp = util.get_email_from_domain(domain, elastic_output)

print "[*] Found email"
print("[*] Found email")
for i_email in email_tmp:
G.add_edge(domain, i_email)
print i_email
print(i_email)

print "[*] Found IP: "
print("[*] Found IP: ")
for i_ip in ip_tmp:
print bcolors.HEADER + i_ip + bcolors.ENDC
print(bcolors.HEADER + i_ip + bcolors.ENDC)
G.add_edge(domain, i_ip)

print "[*] Going deeper..."
print("[*] Going deeper...")
for j_email in email_tmp:
tools.finding(j_email)
domains_from_email1 = util.get_domain_from_email(j_email, elastic_output)
Expand Down
88 changes: 43 additions & 45 deletions domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ def get_tld(self):
try:
tld_from_domain = get_tld("https://" + self.domain, as_object=True)
except:
print "Unknown domain"
print("Unknown domain")
return False

req_tld = requests.get("https://raw.githubusercontent.com/mikewesthad/tld-data/master/data/tlds.json")
json_tld = json.loads(req_tld.content)

for i in json_tld:
if i['domain'] == "." + tld_from_domain.extension:
print "." + tld_from_domain.extension + " is sponsored by " + i['sponsor']
print("." + tld_from_domain.extension + " is sponsored by " + i['sponsor'])

def threatcrowd(self, elastic_output):
output = {}
Expand All @@ -33,17 +33,17 @@ def threatcrowd(self, elastic_output):
if json_threatcrowd['response_code'] == "0":
return False

print "--------------------Threatcrowd module------------------------"
print("--------------------Threatcrowd module------------------------")
votes = json_threatcrowd['votes']
trust = "non-trusted" if votes < 0 else "trusted" if votes > 0 else "no opinion"
print "Reputation of " + self.domain + ": " + trust
print("Reputation of " + self.domain + ": " + trust)

print "[*] Domain was resolved to following IPs: "
print("[*] Domain was resolved to following IPs: ")
for i, j in enumerate(json_threatcrowd['resolutions']):
if i == 3:
break
if len(j['ip_address']) > 1:
print bcolors.HEADER + j['ip_address'] + bcolors.ENDC
print(bcolors.HEADER + j['ip_address'] + bcolors.ENDC)
output[j["ip_address"]] = j["last_resolved"]

else:
Expand All @@ -60,42 +60,42 @@ def threatcrowd(self, elastic_output):
# return json_threatcrowd

def whois(self, key, elastic_output):
print "-------------------WhoIs module---------------------"
print("-------------------WhoIs module---------------------")
req_whois = requests.get("https://api.whoxy.com/?key=" + key + "&whois=" + self.domain)
json_whois = json.loads(req_whois.content)
# #

output = {self.domain: {}}

if json_whois['status'] == 0:
print bcolors.FAIL + "Whois Retrieval Failed" + bcolors.ENDC
print(bcolors.FAIL + "Whois Retrieval Failed" + bcolors.ENDC)

try:
if json_whois['domain_registered'] != 'no':

print "[*] Domain " + bcolors.HEADER + json_whois[
print("[*] Domain " + bcolors.HEADER + json_whois[
'domain_name'] + bcolors.ENDC + " was registered on " + bcolors.OKGREEN + json_whois[
'create_date'] + bcolors.ENDC + " in " + json_whois['domain_registrar']['registrar_name']
print "[*] Name servers"
'create_date'] + bcolors.ENDC + " in " + json_whois['domain_registrar']['registrar_name'])
print("[*] Name servers")

output[self.domain]['create_date'] = json_whois['create_date']

for j in json_whois['name_servers']:
print bcolors.OKBLUE + j + bcolors.ENDC
print(bcolors.OKBLUE + j + bcolors.ENDC)

output[self.domain]['contact'] = json_whois['registrant_contact']
output[self.domain]['dns'] = json_whois['name_servers']
output[self.domain]['domain_name'] = json_whois['domain_name']

print "[*] Contact: "
print("[*] Contact: ")

for k in json_whois['registrant_contact']:
print bcolors.OKBLUE + json_whois['registrant_contact'][k] + bcolors.ENDC
print(bcolors.OKBLUE + json_whois['registrant_contact'][k] + bcolors.ENDC)
else:
print bcolors.FAIL + "No match for domain" + self.domain + bcolors.ENDC
print(bcolors.FAIL + "No match for domain" + self.domain + bcolors.ENDC)

except KeyError as e:
print bcolors.FAIL + "No information found about " + e.message + bcolors.ENDC
print(bcolors.FAIL + "No information found about " + e.message + bcolors.ENDC)

# create_date, domain_registered, domain_registar, name_servers

Expand All @@ -108,7 +108,7 @@ def whois(self, key, elastic_output):
# return json_whois

def whois_history(self, key, elastic_output):
print "-------------------WhoIs history module---------------------"
print("-------------------WhoIs history module---------------------")
req_whois_history = requests.get(
"http://api.whoxy.com/?key=" + key + "&history=" + self.domain)
json_whois_history = json.loads(req_whois_history.content)
Expand All @@ -117,20 +117,19 @@ def whois_history(self, key, elastic_output):
help = 0

if json_whois_history['status'] == 0:
print "Whois Retrieval Failed"
print("Whois Retrieval Failed")
return False

print "[*} Found " + bcolors.OKGREEN + str(
json_whois_history['total_records_found']) + bcolors.ENDC + " result(s)"
print("[*} Found " + bcolors.OKGREEN + str(
json_whois_history['total_records_found']) + bcolors.ENDC + " result(s)")

if json_whois_history['total_records_found'] > 0:

for c, i in enumerate(json_whois_history['whois_records']):
try:

print "[*] Domain " + bcolors.HEADER + self.domain + bcolors.ENDC + " was registered on " + i[
'create_date'] + " in " + \
i['domain_registrar']['registrar_name']
print("[*] Domain " + bcolors.HEADER + self.domain + bcolors.ENDC + " was registered on " + i[
'create_date'] + " in " + i['domain_registrar']['registrar_name'])
# output = {counter: {'create_date': i['create_date'], 'contact': i['registrant_contact'],
# 'dns': i['name_servers']}}
output[c] = {}
Expand All @@ -139,23 +138,23 @@ def whois_history(self, key, elastic_output):
output[c]['dns'] = i['name_servers']
output[c]['domain_name'] = i['domain_name']

print "[*] Contact: "
print("[*] Contact: ")
for k in i['registrant_contact']:
print bcolors.OKBLUE + i['registrant_contact'][k] + bcolors.ENDC
print(bcolors.OKBLUE + i['registrant_contact'][k] + bcolors.ENDC)

print "[*] Name servers:"
print("[*] Name servers:")
for j in i["name_servers"]:
print bcolors.OKBLUE + j + bcolors.ENDC
print(bcolors.OKBLUE + j + bcolors.ENDC)

help = help + 1

except KeyError as e:
print bcolors.FAIL + "No information found about " + e.message + bcolors.ENDC
print(bcolors.FAIL + "No information found about " + e.message + bcolors.ENDC)
help = help - 1

print "---"
print("---")
else:
"No records found"
print("No records found")
return False

# output = { sdate: :{create_date : xxx, contact : {xxx : xxx}, dns : [xxx]}
Expand All @@ -169,7 +168,7 @@ def whois_history(self, key, elastic_output):
# return json_whois_history

def virustotal_opinion(self, key):
print "-------------------VirusTotal module---------------------"
print("-------------------VirusTotal module---------------------")
req_virustotal = requests.get(
"https://www.virustotal.com/vtapi/v2/url/report?apikey=" + key + "&allinfo=true&resource=" + self.domain)

Expand All @@ -181,11 +180,11 @@ def virustotal_opinion(self, key):
json_virustotal = json.loads(req_virustotal.content)

if json_virustotal['response_code'] == 0:
print "[*] No results from VirusTotal"
print("[*] No results from VirusTotal")
return False

print "[*] Domain " + self.domain + " was last scanned on " + json_virustotal['scan_date']
print "[*] Has " + str(json_virustotal['positives']) + " positive results"
print("[*] Domain " + self.domain + " was last scanned on " + json_virustotal['scan_date'])
print("[*] Has " + str(json_virustotal['positives']) + " positive results")

# dorobic skaner

Expand All @@ -196,50 +195,49 @@ def virustotal_opinion(self, key):
# return json_virustotal

def wayback(self):
print "----------------------Wayback Machine module------------------------"
print("----------------------Wayback Machine module------------------------")
req_wayback = requests.get("http://archive.org/wayback/available?url=" + self.domain)
json_wayback = json.loads(req_wayback.content)

if json_wayback['archived_snapshots']:
print json_wayback['archived_snapshots']['closest']['url']
print(json_wayback['archived_snapshots']['closest']['url'])
else:
print "No results for " + self.domain
print("No results for " + self.domain)

return json_wayback

# print res

def virustotal(self, key, elastic_output):
output = {self.domain: []}
help = 0
print "----------------VirusTotal module---------------------------"
print("----------------VirusTotal module---------------------------")

req_virustotal = requests.get(
"https://www.virustotal.com/vtapi/v2/domain/report?apikey=" + key + "&domain=" + self.domain)

if req_virustotal.status_code == 204:
print "API limitation, putting into sleep for 70 sec"
print("API limitation, putting into sleep for 70 sec")
time.sleep(70)
req_virustotal = requests.get(
"https://www.virustotal.com/vtapi/v2/domain/report?apikey=" + key + "&domain=" + self.domain)

if req_virustotal.status_code == 403:
print "Wrong API key, no more info can be gathered"
print("Wrong API key, no more info can be gathered")
sys.exit()

json_virustotal = json.loads(req_virustotal.content)

if json_virustotal['response_code'] != 0:
print "[*] Domain was resolved to following IPs: "
print("[*] Domain was resolved to following IPs: ")
for i in json_virustotal['resolutions']:
print bcolors.HEADER + i['ip_address'] + bcolors.ENDC + " on " + bcolors.OKBLUE + i[
'last_resolved'] + bcolors.ENDC
print(bcolors.HEADER + i['ip_address'] + bcolors.ENDC + " on " + bcolors.OKBLUE + i[
'last_resolved'] + bcolors.ENDC)
output[self.domain].append(i['ip_address'])
help = help + 1
if help > 2:
break
else:
print bcolors.FAIL + "Nothing found" + bcolors.ENDC
print(bcolors.FAIL + "Nothing found" + bcolors.ENDC)

# output = { self.domain : [xxx.xxx,zzz.zzz,yyy.yyy]
if elastic_output:
Expand Down
Loading