SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Removed use of RAW_DATA, added more functionality to RIPE module.
smicallefea320a8533c5
diff --git a/modules/sfp_bingsearch.py b/modules/sfp_bingsearch.pyindex c770ab0d..4b78807d 100644--- a/modules/sfp_bingsearch.py+++ b/modules/sfp_bingsearch.py@@ -55,7 +55,7 @@ class sfp_bingsearch(SpiderFootPlugin):# This is to support the end user in selecting modules based on events# produced.def producedEvents(self):- return [ "LINKED_URL_INTERNAL" ]+ return [ "LINKED_URL_INTERNAL", "SEARCH_ENGINE_WEB_CONTENT" ]# Scrape Bing for content, starting at startUrl and iterating through# results based on options supplied. Will return a dictionary of all pages@@ -143,7 +143,7 @@ class sfp_bingsearch(SpiderFootPlugin):return None# Submit the bing results for analysis- evt = SpiderFootEvent("RAW_DATA", pages[page], self.__name__)+ evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", pages[page], self.__name__)self.notifyListeners(evt)# We can optionally fetch links to our domain found in the searchdiff --git a/modules/sfp_dns.py b/modules/sfp_dns.pyindex bd20497f..4061744a 100644--- a/modules/sfp_dns.py+++ b/modules/sfp_dns.py@@ -27,7 +27,6 @@ class sfp_dns(SpiderFootPlugin):# Default optionsopts = {- 'resolveaffiliate': False, # Get IPs for affiliate domains'reverselookup': True, # Reverse-resolve IPs to names for# more clues."skipcommononwildcard": True,@@ -41,7 +40,6 @@ class sfp_dns(SpiderFootPlugin):# Option descriptionsoptdescs = {'skipcommononwildcard': "If wildcard DNS is detected, look up the first common sub-domain only.",- 'resolveaffiliate': "Obtain IPs for confirmed affiliates?",'reverselookup': "Obtain new URLs and possible affiliates based on reverse-resolved IPs?","commonsubs": "Common sub-domains to try. Prefix with an '@' to iterate through a file containing sub-domains to try (one per line), e.g. @C:\subdomains.txt or @/home/bob/subdomains.txt. Or supply a URL to load the list from there."}@@ -64,9 +62,8 @@ class sfp_dns(SpiderFootPlugin):# What events is this module interested in for inputdef watchedEvents(self):- arr = ['RAW_DATA', 'LINKED_URL_INTERNAL', 'SUBDOMAIN']- if self.opts['resolveaffiliate']:- arr.append('AFFILIATE')+ arr = ['RAW_DNS_RECORDS', 'SEARCH_ENGINE_WEB_CONTENT', 'RAW_RIPE_DATA',+ 'TARGET_WEB_CONTENT', 'LINKED_URL_INTERNAL', 'SUBDOMAIN' ]if self.opts['reverselookup']:arr.append('IP_ADDRESS')return arr@@ -76,7 +73,7 @@ class sfp_dns(SpiderFootPlugin):# produced.def producedEvents(self):return [ "IP_ADDRESS", "SUBDOMAIN", "PROVIDER_MAIL",- "PROVIDER_DNS", "AFFILIATE" ]+ "PROVIDER_DNS", "AFFILIATE", "RAW_DNS_RECORDS" ]# Handle events sent to this moduledef handleEvent(self, event):@@ -84,10 +81,6 @@ class sfp_dns(SpiderFootPlugin):srcModuleName = event.moduleeventData = event.dataaddrs = None- #if eventName == "RAW_DATA":- # parentEvent = event.sourceEvent- #else:- # parentEvent = eventparentEvent = eventsf.debug("Received event, " + eventName + ", from " + srcModuleName)@@ -97,7 +90,8 @@ class sfp_dns(SpiderFootPlugin):self.subresults[eventData] = True- if eventName in [ "RAW_DATA", "LINKED_URL_INTERNAL" ]:+ if eventName in [ "SEARCH_ENGINE_WEB_CONTENT", "TARGET_WEB_CONTENT",+ "LINKED_URL_INTERNAL", "RAW_RIPE_DATA", "RAW_DNS_RECORDS" ]:# If we've received a link or some raw data, extract potential sub-domains# from the data for resolving later.matches = re.findall("([a-zA-Z0-9\-\.]+\." + self.baseDomain + ")", eventData,@@ -115,7 +109,7 @@ class sfp_dns(SpiderFootPlugin):# Nothing left to do with internal links and raw datareturn None- # Handling SUBDOMAIN, AFFILIATE and IP_ADDRESS events..+ # Handling SUBDOMAIN and IP_ADDRESS events..# Don't look up stuff twiceif self.results.has_key(eventData):@@ -187,7 +181,7 @@ class sfp_dns(SpiderFootPlugin):for key in recdata.keys():strdata = unicode(recdata[key].rrset.to_text(), 'utf-8', errors='replace')- evt = SpiderFootEvent("RAW_DATA", strdata, self.__name__)+ evt = SpiderFootEvent("RAW_DNS_DATA", strdata, self.__name__)self.notifyListeners(evt)if recdata.has_key('MX'):diff --git a/modules/sfp_googlesearch.py b/modules/sfp_googlesearch.pyindex 79cce874..148959d3 100644--- a/modules/sfp_googlesearch.py+++ b/modules/sfp_googlesearch.py@@ -55,7 +55,7 @@ class sfp_googlesearch(SpiderFootPlugin):# This is to support the end user in selecting modules based on events# produced.def producedEvents(self):- return [ "LINKED_URL_INTERNAL" ]+ return [ "LINKED_URL_INTERNAL", "SEARCH_ENGINE_WEB_CONTENT" ]# Scrape Google for content, starting at startUrl and iterating through# results based on options supplied. Will return a dictionary of all pages@@ -143,7 +143,7 @@ class sfp_googlesearch(SpiderFootPlugin):return None# Submit the google results for analysis- evt = SpiderFootEvent("RAW_DATA", pages[page], self.__name__)+ evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", pages[page], self.__name__)self.notifyListeners(evt)# We can optionally fetch links to our domain found in the searchdiff --git a/modules/sfp_mail.py b/modules/sfp_mail.pyindex 623ec052..825a3a62 100644--- a/modules/sfp_mail.py+++ b/modules/sfp_mail.py@@ -50,7 +50,7 @@ class sfp_mail(SpiderFootPlugin):# What events is this module interested in for inputdef watchedEvents(self):- return ["RAW_DATA"]+ return ["*"]# What events this module produces# This is to support the end user in selecting modules based on events@@ -65,8 +65,15 @@ class sfp_mail(SpiderFootPlugin):eventData = event.dataparentEvent = event.sourceEvent+ if eventName == "EMAILADDR":+ return None+sf.debug("Received event, " + eventName + ", from " + srcModuleName)+ if type(eventData) not in [ str, unicode ]:+ sf.debug("Unhandled type to find e-mails: " + str(type(eventData)))+ return None+matches = re.findall("([a-zA-Z\.0-9_\-]+@[a-zA-Z\.0-9_\-]+)", eventData)for match in matches:sf.debug("Found possible email: " + match)diff --git a/modules/sfp_pageinfo.py b/modules/sfp_pageinfo.pyindex 410fda3e..ad2bc615 100644--- a/modules/sfp_pageinfo.py+++ b/modules/sfp_pageinfo.py@@ -52,7 +52,7 @@ etc.)"""# What events is this module interested in for inputdef watchedEvents(self):- return ["RAW_DATA"]+ return ["TARGET_WEB_CONTENT"]# What events this module produces# This is to support the end user in selecting modules based on events@@ -64,8 +64,10 @@ etc.)"""# Handle events sent to this moduledef handleEvent(self, event):# We are only interested in the raw data from the spidering module+ # because the spidering module will always provide events with the+ # event.sourceEvent.data set to the URL of the source.if "sfp_spider" not in event.module:- sf.debug("Ignoring RAW_DATA from " + event.module)+ sf.debug("Ignoring web content from " + event.module)return NoneeventName = event.eventTypediff --git a/modules/sfp_portscan_basic.py b/modules/sfp_portscan_basic.pyindex ecc68e17..c4d1239e 100644--- a/modules/sfp_portscan_basic.py+++ b/modules/sfp_portscan_basic.py@@ -123,7 +123,7 @@ class sfp_portscan_basic(SpiderFootPlugin):return self.portResults- # Generate both a RAW_DATA and TCP_PORT_OPEN_BANNER event+ # Generate TCP_PORT_OPEN_BANNER eventdef sendEvent(self, resArray, srcEvent):for cp in resArray:if resArray[cp]:@@ -135,9 +135,6 @@ class sfp_portscan_basic(SpiderFootPlugin):bevt = SpiderFootEvent("TCP_PORT_OPEN_BANNER", resArray[cp],self.__name__, evt)self.notifyListeners(bevt)- revt = SpiderFootEvent("RAW_DATA", resArray[cp],- self.__name__, evt)- self.notifyListeners(revt)# Handle events sent to this modulediff --git a/modules/sfp_ripe.py b/modules/sfp_ripe.pyindex 211ecf32..b50829a0 100644--- a/modules/sfp_ripe.py+++ b/modules/sfp_ripe.py@@ -47,7 +47,7 @@ class sfp_ripe(SpiderFootPlugin):# This is to support the end user in selecting modules based on events# produced.def producedEvents(self):- return [ "AFFILIATE", "NETBLOCK" ]+ return [ "AFFILIATE", "NETBLOCK", "RAW_RIPE_DATA" ]# Handle events sent to this moduledef handleEvent(self, event):@@ -85,7 +85,7 @@ class sfp_ripe(SpiderFootPlugin):self.notifyListeners(evt)# Just send the content off for others to process- evt = SpiderFootEvent("RAW_DATA", res['content'], self.__name__, event)+ evt = SpiderFootEvent("RAW_RIPE_DATA", res['content'], self.__name__, event)self.notifyListeners(evt)return None@@ -115,18 +115,112 @@ class sfp_ripe(SpiderFootPlugin):return Nonekeyword = sf.domainKeyword(self.baseDomain)- res['content'] = res['content'].lower()+ content = res['content'].lower()#print keyword + " and " + self.baseDomain + " in: " + res['content']# Crude and probably prone to a lot of false positives. Need to revisit.- if self.baseDomain in res['content'] or "\"" + keyword in res['content'] \- or keyword +"\"" in res['content'] or keyword +"-" in res['content'] \- or "-"+keyword in res['content']:+ if self.baseDomain in content or "\"" + keyword in content \+ or keyword +"\"" in content or keyword +"-" in content \+ or "-"+keyword in content:sf.info("Owned netblock found: " + prefix)evt = SpiderFootEvent("NETBLOCK", prefix, self.__name__, event)self.notifyListeners(evt)- evt = SpiderFootEvent("RAW_DATA", res['content'], self.__name__, event)+ evt = SpiderFootEvent("RAW_RIPE_DATA", res['content'], self.__name__, event)self.notifyListeners(evt)+ # We now have a netblock owned by our target, we want to find+ # the AS hop before the AS owning this netblock to find the ISP.+ # 1. Parse the AS out of res['content']+ try:+ j = json.loads(res['content'])+ except Exception as e:+ sf.debug("Error processing JSON response.")+ return None+ data = j["data"]["irr_records"][0]+ asn = None+ for rec in data:+ if rec["key"] == "origin":+ asn = rec["value"]+ break++ # 2. Find all the netblocks owned by this AS+ if asn != None:+ res = sf.fetchUrl("http://stat.ripe.net/data/announced-prefixes/data.json?resource=" + \+ "AS" + str(asn), timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])+ if res['content'] == None:+ sf.info("No RIPE info found/available for AS" + asn)+ else:+ evt = SpiderFootEvent("BGP_AS", asn, self.__name__, event)+ self.notifyListeners(evt)+ try:+ j = json.loads(res['content'])+ except Exception as e:+ sf.debug("Error processing JSON response.")+ return None+ data = j["data"]["prefixes"]+ for rec in data:+ pfx = rec["prefix"]+ sf.info("Additional netblock found from same AS: " + pfx)+ evt = SpiderFootEvent("NETBLOCK", pfx, self.__name__, event)+ self.notifyListeners(evt)++ # 3. Find all the AS neighbours (the last hop before our target)+ res = sf.fetchUrl("http://stat.ripe.net/data/asn-neighbours/data.json?resource=" + \+ "AS" + str(asn), timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])+ if res['content'] == None:+ sf.info("No RIPE info found/available for AS" + asn)+ else:+ try:+ j = json.loads(res['content'])+ except Exception as e:+ sf.debug("Error processing JSON response.")+ return None+ data = j["data"]["neighbours"]+ for rec in data:+ nasn = rec['asn']+ res = sf.fetchUrl("http://stat.ripe.net/data/whois/data.json?resource=" + \+ str(nasn), timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])+ if res['content'] == None:+ sf.info("No RIPE info found/available for prefix: " + prefix)+ return None+ try:+ j = json.loads(res['content'])+ except Exception as e:+ sf.debug("Error processing JSON response.")+ return None++ name = None+ for rec in j["data"]["records"]:+ for rrec in rec:+ if rrec['key'] == "descr":+ name = rrec['value']+ break+ if rrec['key'] == "OrgName":+ name = rrec['value']+ break++ if name != None:+ break++ if name != None:+ evt = SpiderFootEvent("PROVIDER_INTERNET", name,+ self.__name__, event)+ self.notifyListeners(evt)+ else:+ # If they don't own the netblock they are serving from, then+ # the netblock owner is their Internet provider.+ try:+ j = json.loads(res['content'])+ except Exception as e:+ sf.debug("Error processing JSON response.")+ return None+ data = j["data"]["irr_records"][0]+ for rec in data:+ if rec['key'] == "descr":+ evt = SpiderFootEvent("PROVIDER_INTERNET", rec['value'],+ self.__name__, event)+ self.notifyListeners(evt)+ break+return Nonedef start(self):@@ -151,7 +245,7 @@ class sfp_ripe(SpiderFootPlugin):self.notifyListeners(evt)# Just send the content off for others to process- evt = SpiderFootEvent("RAW_DATA", res['content'], self.__name__)+ evt = SpiderFootEvent("RAW_RIPE_DATA", res['content'], self.__name__)self.notifyListeners(evt)return Nonediff --git a/modules/sfp_spider.py b/modules/sfp_spider.pyindex 9ddd9f99..4e105700 100644--- a/modules/sfp_spider.py+++ b/modules/sfp_spider.py@@ -183,7 +183,7 @@ class sfp_spider(SpiderFootPlugin):# Notify listening modules about raw data and othersdef contentNotify(self, url, httpresult, parentEvent=None):- event = SpiderFootEvent("RAW_DATA", httpresult['content'],+ event = SpiderFootEvent("TARGET_WEB_CONTENT", httpresult['content'],self.__name__, parentEvent)self.notifyListeners(event)@@ -206,7 +206,7 @@ class sfp_spider(SpiderFootPlugin):# produced.def producedEvents(self):return [ "WEBSERVER_HTTPHEADERS", "HTTP_CODE", "LINKED_URL_INTERNAL",- "LINKED_URL_EXTERNAL" ]+ "LINKED_URL_EXTERNAL", "TARGET_WEB_CONTENT" ]# Some other modules may request we spider thingsdef handleEvent(self, event):diff --git a/modules/sfp_sslcert.py b/modules/sfp_sslcert.pyindex 01338a35..5fb9bef9 100644--- a/modules/sfp_sslcert.py+++ b/modules/sfp_sslcert.py@@ -67,7 +67,7 @@ class sfp_sslcert(SpiderFootPlugin):def producedEvents(self):return [ "SSL_CERTIFICATE_ISSUED", "SSL_CERTIFICATE_ISSUER","SSL_CERTIFICATE_MISMATCH", "SSL_CERTIFICATE_EXPIRED",- "SSL_CERTIFICATE_EXPIRING" ]+ "SSL_CERTIFICATE_EXPIRING", "SSL_CERTIFICATE_RAW" ]# Handle events sent to this moduledef handleEvent(self, event):@@ -107,7 +107,7 @@ class sfp_sslcert(SpiderFootPlugin):# Generate the event for the raw cert (in text form)# Cert raw data text contains a lot of gems..- rawevt = SpiderFootEvent("RAW_DATA", m2cert.as_text(), self.__name__, event)+ rawevt = SpiderFootEvent("SSL_CERTIFICATE_RAW", m2cert.as_text(), self.__name__, event)self.notifyListeners(rawevt)# Generate events for other cert aspectsdiff --git a/modules/sfp_template.py b/modules/sfp_template.pyindex 17fc7f20..cfee93d1 100644--- a/modules/sfp_template.py+++ b/modules/sfp_template.py@@ -64,7 +64,7 @@ class sfp_XXX(SpiderFootPlugin):eventName = event.eventTypesrcModuleName = event.moduleeventData = event.data- # If you are processing RAW_DATA from sfp_spider, this is how you+ # If you are processing TARGET_WEB_CONTENT from sfp_spider, this is how you# would get the source of that raw data (e.g. a URL.)eventSource = event.sourceEvent.datadiff --git a/modules/sfp_webframework.py b/modules/sfp_webframework.pyindex 52dd6546..810f5e81 100644--- a/modules/sfp_webframework.py+++ b/modules/sfp_webframework.py@@ -57,7 +57,7 @@ class sfp_webframework(SpiderFootPlugin):# What events is this module interested in for input# * = be notified about all events.def watchedEvents(self):- return ["RAW_DATA"]+ return ["TARGET_WEB_CONTENT"]# What events this module produces# This is to support the end user in selecting modules based on events@@ -75,7 +75,7 @@ class sfp_webframework(SpiderFootPlugin):if srcModuleName != "sfp_spider":return None- # If you are processing RAW_DATA, this is how you would get the+ # If you are processing TARGET_WEB_CONTENT, this is how you would get the# source of that raw data (e.g. a URL.)eventSource = event.sourceEvent.datadiff --git a/modules/sfp_xref.py b/modules/sfp_xref.pyindex 721b9c1c..0dce6be9 100644--- a/modules/sfp_xref.py+++ b/modules/sfp_xref.py@@ -65,7 +65,7 @@ class sfp_xref(SpiderFootPlugin):# This is to support the end user in selecting modules based on events# produced.def producedEvents(self):- return [ "AFFILIATE" ]+ return [ "AFFILIATE", "AFFILIATE_WEB_CONTENT" ]# Handle events sent to this module# In this module's case, eventData will be the URL or a domain which@@ -133,7 +133,7 @@ class sfp_xref(SpiderFootPlugin):evt1 = SpiderFootEvent("AFFILIATE", url, self.__name__, event)self.notifyListeners(evt1)if self.opts['checkcontent']:- evt2 = SpiderFootEvent("RAW_DATA", res['content'], self.__name__, evt1)+ evt2 = SpiderFootEvent("AFFILIATE_WEB_CONTENT", res['content'], self.__name__, evt1)self.notifyListeners(evt2)return None