SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Bug fix finding keywords when sub-domains are supplied.
smicallefc3e4059eb02d
diff --git a/modules/sfp_ir.py b/modules/sfp_ir.pyindex 83667abe..f2dbcf97 100644--- a/modules/sfp_ir.py+++ b/modules/sfp_ir.py@@ -31,6 +31,7 @@ class sfp_ir(SpiderFootPlugin):currentEventSrc = NonememCache = dict()nbreported = dict()+ keyword = Nonedef setup(self, sfc, target, userOpts=dict()):global sf@@ -45,6 +46,8 @@ class sfp_ir(SpiderFootPlugin):for opt in userOpts.keys():self.opts[opt] = userOpts[opt]+ self.keyword = sf.domainKeyword(self.baseDomain, self.opts['_internettlds']).lower()+# What events is this module interested in for inputdef watchedEvents(self):return ['IP_ADDRESS']@@ -198,7 +201,6 @@ class sfp_ir(SpiderFootPlugin):return True# Slightly more complex..- keyword = sf.domainKeyword(self.baseDomain).lower()rx = ['^{0}[-_/\'\"\\\.,\?\! ]','[-_/\'\"\\\.,\?\! ]{0}$',@@ -208,10 +210,10 @@ class sfp_ir(SpiderFootPlugin):# Mess with the keyword as a last resort..keywordList = list()# Create versions of the keyword, esp. if hyphens are involved.- keywordList.append(keyword)- keywordList.append(keyword.replace('-', ' '))- keywordList.append(keyword.replace('-', '_'))- keywordList.append(keyword.replace('-', ''))+ keywordList.append(self.keyword)+ keywordList.append(self.keyword.replace('-', ' '))+ keywordList.append(self.keyword.replace('-', '_'))+ keywordList.append(self.keyword.replace('-', ''))# More versions in future..for kw in keywordList:for r in rx:diff --git a/modules/sfp_malcheck.py b/modules/sfp_malcheck.pyindex 688c81bd..f0361423 100644--- a/modules/sfp_malcheck.py+++ b/modules/sfp_malcheck.py@@ -312,7 +312,7 @@ class sfp_malcheck(SpiderFootPlugin):return Nonedef start(self):- keyword = sf.domainKeyword(self.baseDomain)+ keyword = sf.domainKeyword(self.baseDomain, self.opts['_internettlds'])sf.debug("Keyword extracted from " + self.baseDomain + ": " + keyword)if self.baseDomain in self.results:return None@@ -326,7 +326,7 @@ class sfp_malcheck(SpiderFootPlugin):url = self.lookupItem(cid, 'domain', self.baseDomain)if url != None:text = check + " [" + self.baseDomain + "]\n" + url- evt = SpiderFootEvent('MALICIOUS_SUBDOMAIN', url, self.__name__)+ evt = SpiderFootEvent('MALICIOUS_SUBDOMAIN', text, self.__name__)self.notifyListeners(evt)# End of sfp_malcheck classdiff --git a/modules/sfp_similar.py b/modules/sfp_similar.pyindex 4236fde7..9cd478a7 100644--- a/modules/sfp_similar.py+++ b/modules/sfp_similar.py@@ -221,7 +221,7 @@ class sfp_similar(SpiderFootPlugin):# Search for similar sounding domainsdef start(self):- keyword = sf.domainKeyword(self.baseDomain)+ keyword = sf.domainKeyword(self.baseDomain, self.opts['_internettlds'])sf.debug("Keyword extracted from " + self.baseDomain + ": " + keyword)# No longer seems to work.diff --git a/modules/sfp_tldsearch.py b/modules/sfp_tldsearch.pyindex a70b04cf..be25ba2b 100644--- a/modules/sfp_tldsearch.py+++ b/modules/sfp_tldsearch.py@@ -127,7 +127,7 @@ class sfp_tldsearch(SpiderFootPlugin):# Search for similar sounding domainsdef start(self):- keyword = sf.domainKeyword(self.baseDomain)+ keyword = sf.domainKeyword(self.baseDomain, self.opts['_internettlds'])sf.debug("Keyword extracted from " + self.baseDomain + ": " + keyword)targetList = list()diff --git a/sflib.py b/sflib.pyindex 9c38bc11..e25b1f18 100644--- a/sflib.py+++ b/sflib.py@@ -387,7 +387,7 @@ class SpiderFoot:finalBits.append(chunk)- self.debug('xfrmed rel to abs path: ' + url + ' to ' + '/'.join(finalBits))+ #self.debug('xfrmed rel to abs path: ' + url + ' to ' + '/'.join(finalBits))return '/'.join(finalBits)# Extract the top level directory from a URL@@ -397,16 +397,16 @@ class SpiderFoot:# For cases like 'www.somesite.com'if len(bits) == 0:- self.debug('base dir of ' + url + ' not identified, using URL as base.')+ #self.debug('base dir of ' + url + ' not identified, using URL as base.')return url + '/'# For cases like 'http://www.blah.com'if '://' in url and url.count('/') < 3:- self.debug('base dir of ' + url + ' is: ' + url + '/')+ #self.debug('base dir of ' + url + ' is: ' + url + '/')return url + '/'base = '/'.join(bits[:-1])- self.debug('base dir of ' + url + ' is: ' + base + '/')+ #self.debug('base dir of ' + url + ' is: ' + base + '/')return base + '/'# Extract the scheme and domain from a URL@@ -437,9 +437,17 @@ class SpiderFoot:# Extract the keyword (the domain without the TLD or any subdomains)# from a domain.- def domainKeyword(self, domain):- return domain.split('.', 2)[0].lower()-+ def domainKeyword(self, domain, tldList):+ # Strip off the TLD+ tld = '.'.join(self.hostDomain(domain.lower(), tldList).split('.')[1:])+ ret = domain.lower().replace('.'+tld, '')++ # If the user supplied a domain with a sub-domain, return the second part+ if '.' in ret:+ return ret.split('.')[-1]+ else:+ return ret+# Obtain the domain name for a supplied hostname# tldList needs to be an array based on the Mozilla public listdef hostDomain(self, hostname, tldList):