SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Check host validity in sfp_crt.
smicallef1cd61c5f2c1d
diff --git a/modules/sfp_crt.py b/modules/sfp_crt.pyindex efc4d5c7..6a5a0384 100644--- a/modules/sfp_crt.py+++ b/modules/sfp_crt.py@@ -44,7 +44,7 @@ class sfp_crt(SpiderFootPlugin):# This is to support the end user in selecting modules based on events# produced.def producedEvents(self):- return ["SSL_CERTIFICATE_RAW",+ return ["SSL_CERTIFICATE_RAW", "RAW_RIR_DATA",'INTERNET_NAME', 'INTERNET_NAME_UNRESOLVED', 'DOMAIN_NAME','AFFILIATE_INTERNET_NAME', 'AFFILIATE_INTERNET_NAME_UNRESOLVED','AFFILIATE_DOMAIN_NAME']@@ -84,7 +84,7 @@ class sfp_crt(SpiderFootPlugin):if data is None or len(data) == 0:return None- evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", str(data), self.__name__, event)+ evt = SpiderFootEvent("RAW_RIR_DATA", str(data), self.__name__, event)self.notifyListeners(evt)cert_ids = list()@@ -112,14 +112,17 @@ class sfp_crt(SpiderFootPlugin):if domain in self.results:continue+ if not self.sf.validHost(domain, self.opts['_internettlds']):+ continue+if self.getTarget().matches(domain, includeChildren=True, includeParents=True):evt_type = 'INTERNET_NAME'else:evt_type = 'AFFILIATE_INTERNET_NAME'if self.opts['verify'] and not self.sf.resolveHost(domain):- self.sf.debug("Host " + domain + " could not be resolved")- evt_type += '_UNRESOLVED'+ self.sf.debug("Host " + domain + " could not be resolved")+ evt_type += '_UNRESOLVED'evt = SpiderFootEvent(evt_type, domain, self.__name__, event)self.notifyListeners(evt)diff --git a/sflib.py b/sflib.pyindex 22c7a8f4..d35c5c82 100644--- a/sflib.py+++ b/sflib.py@@ -768,6 +768,14 @@ class SpiderFoot:# Is the host a valid host (some filenames look like hosts)def validHost(self, hostname, tldList):+ # First basic content checks+ if "." not in hostname:+ return False++ if not re.match("^[a-z0-9-\.]*$", hostname, re.IGNORECASE):+ return False++ # Finally check if it's on a valid TLDps = PublicSuffixList(tldList)sfx = ps.get_public_suffix(hostname, strict=True)return sfx != None@@ -781,12 +789,6 @@ class SpiderFoot:suffix = ps.get_public_suffix(hostname)return hostname == suffix- # Is the host a valid host (some filenames look like hosts)- def validHost(self, hostname, tldList):- ps = PublicSuffixList(tldList)- sfx = ps.get_public_suffix(hostname, strict=True)- return sfx != None-# Simple way to verify IPv4 addresses.def validIP(self, address):if not address: