minor changes
This commit is contained in:
parent
b193999667
commit
1633b975c3
@ -5,6 +5,7 @@ import validators
|
||||
from ipwhois import IPWhois
|
||||
from whois import whois
|
||||
from .constants import DOMAIN, EMAIL, IPV4, IPV6, URL
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def determine(host):
|
||||
@ -25,9 +26,11 @@ def determine(host):
|
||||
|
||||
|
||||
def domain(host):
|
||||
result = dict(whois(host))
|
||||
if type(result["domain_name"]) is list:
|
||||
result["domain_name"] = result["domain_name"][0]
|
||||
info = dict(whois(host))
|
||||
if type(info["domain_name"]) is list:
|
||||
info["domain_name"] = info["domain_name"][0]
|
||||
selection = {"registrar_country", "registrar"}
|
||||
result = {key: info.get(key) for key in selection}
|
||||
return result
|
||||
|
||||
|
||||
|
@ -17,12 +17,21 @@ from . import host_data
|
||||
import tldextract
|
||||
|
||||
|
||||
class Test(object):
|
||||
def __init__(self):
|
||||
self.host = "joostagterhoek.nl"
|
||||
self.host_type = "domain"
|
||||
self.vt = {"whatever": "whatever", "second_key": 4}
|
||||
self.email_security = ["1", 1, "2", "3"]
|
||||
|
||||
|
||||
class Lookedup(object):
|
||||
def __init__(self, host):
|
||||
self.host = host
|
||||
self.host_type = determine(self.host)
|
||||
self = self.specific()
|
||||
# TODO: consolidate all below functions if possible
|
||||
# Implement an __eq__ method based on host name: https://dnmtechs.com/comparing-object-instances-by-attributes-in-python-3-a-comprehensive-guide/
|
||||
|
||||
def url_lookup(self):
|
||||
self.domain = urlparse(self.host).netloc
|
||||
@ -46,7 +55,8 @@ class Lookedup(object):
|
||||
self.metadata = domain(self.host)
|
||||
self.domain = self.metadata["domain_name"]
|
||||
self.email_security = spf_dmarc(self.domain)
|
||||
self.vt, self.vt_dict = virustotal_api.analyse2(self.host, self.host_type)
|
||||
# self.vt, self.vt_dict = virustotal_api.analyse2(self.host, self.host_type)
|
||||
self.vt = virustotal_api.analyse2(self.host, self.host_type)
|
||||
self.abuseipdb = abuseipdb_api.analyse(self.ip_address)
|
||||
return self
|
||||
|
||||
@ -127,18 +137,25 @@ def extract(user_input):
|
||||
hosts.append(item)
|
||||
else:
|
||||
errors.append(item)
|
||||
print(hosts)
|
||||
print(errors)
|
||||
return hosts, errors
|
||||
|
||||
|
||||
def domain(host):
|
||||
result = dict(whois(host))
|
||||
print("RESULT IS: ", result)
|
||||
if type(result["creation_date"]) is list:
|
||||
result["creation_date"] = result["creation_date"][0].strftime("%d-%m-%Y")
|
||||
else:
|
||||
result["creation_date"] = result["creation_date"].strftime("%d-%m-%Y")
|
||||
if type(result["domain_name"]) is list:
|
||||
result["domain_name"] = result["domain_name"][0]
|
||||
return result
|
||||
# result["creation_date"] = result["creation_date"].isoformat()
|
||||
included = {"domain_name", "creation_date", "registrar", "registrar_country"}
|
||||
filtered = {key: value for key, value in result.items() if key in included}
|
||||
print("FILTERED IS: ", filtered)
|
||||
return filtered
|
||||
|
||||
|
||||
def spf_dmarc(domain):
|
||||
|
@ -108,4 +108,5 @@ def analyse2(host, host_type):
|
||||
"%d-%m-%Y",
|
||||
time.gmtime(last_update),
|
||||
)
|
||||
return summary, analysis_json
|
||||
# return summary, analysis_json
|
||||
return summary
|
||||
|
Loading…
x
Reference in New Issue
Block a user