SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
sfp_whois: Add support for NETBLOCKV6_OWNER (#1411)
bcoles3b9417b3d3d0
diff --git a/modules/sfp_whois.py b/modules/sfp_whois.pyindex 34f48527..8247e28c 100644--- a/modules/sfp_whois.py+++ b/modules/sfp_whois.py@@ -12,13 +12,11 @@# -------------------------------------------------------------------------------import ipwhois--from netaddr import IPAddress+import netaddr+import whoisfrom spiderfoot import SpiderFootEvent, SpiderFootPlugin-import whois-class sfp_whois(SpiderFootPlugin):@@ -49,7 +47,7 @@ class sfp_whois(SpiderFootPlugin):# What events is this module interested in for inputdef watchedEvents(self):- return ["DOMAIN_NAME", "DOMAIN_NAME_PARENT", "NETBLOCK_OWNER",+ return ["DOMAIN_NAME", "DOMAIN_NAME_PARENT", "NETBLOCK_OWNER", "NETBLOCKV6_OWNER","CO_HOSTED_SITE_DOMAIN", "AFFILIATE_DOMAIN_NAME", "SIMILARDOMAIN"]# What events this module produces@@ -89,16 +87,22 @@ class sfp_whois(SpiderFootPlugin):data = None- if eventName == "NETBLOCK_OWNER":- qry = eventData.split("/")[0]- ip = IPAddress(qry) + 1+ if eventName in ["NETBLOCK_OWNER", "NETBLOCKV6_OWNER"]:+ try:+ netblock = netaddr.IPNetwork(eventData)+ except Exception as e:+ self.sf.error(f"Invalid netblock {eventData}: {e}")+ return++ ip = netblock[0]self.sf.debug(f"Sending RDAP query for IP address: {ip}")+try:# TODO: this should use the configured proxy- r = ipwhois.IPWhois(qry)- data = r.lookup_rdap(depth=1)+ r = ipwhois.IPWhois(ip)+ data = str(r.lookup_rdap(depth=1))except Exception as e:- self.sf.error(f"Unable to perform WHOIS query on {qry}: {e}")+ self.sf.error(f"Unable to perform WHOIS query on {ip}: {e}")else:self.sf.debug(f"Sending WHOIS query for domain: {eventData}")try:@@ -112,7 +116,7 @@ class sfp_whois(SpiderFootPlugin):return# This is likely to be an error about being throttled rather than real data- if len(data) < 250:+ if len(str(data)) < 250:self.sf.error(f"WHOIS data ({len(data)} bytes) is smaller than 250 bytes. Throttling from WHOIS server is probably happening. Ignoring response.")return