SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Loads of bug fixes and better error handling.
Steve Micallef195db5f61222
diff --git a/modules/sfp_abusech.py b/modules/sfp_abusech.pyindex edb31ab1..eb76201a 100644--- a/modules/sfp_abusech.py+++ b/modules/sfp_abusech.py@@ -27,17 +27,11 @@ malchecks = {'checks': ['ip', 'netblock'],'url': 'https://zeustracker.abuse.ch/blocklist.php?download=badips'},- 'abuse.ch Feodo Tracker (Domain)': {- 'id': 'abusefeododomain',- 'type': 'list',- 'checks': ['domain'],- 'url': 'https://feodotracker.abuse.ch/blocklist/?download=domainblocklist'- },'abuse.ch Feodo Tracker (IP)': {'id': 'abusefeodoip','type': 'list','checks': ['ip', 'netblock'],- 'url': 'https://feodotracker.abuse.ch/blocklist/?download=ipblocklist'+ 'url': 'https://feodotracker.abuse.ch/downloads/ipblocklist.txt'},'abuse.ch SSL Blacklist (IP)': {'id': 'abusesslblip',diff --git a/modules/sfp_censys.py b/modules/sfp_censys.pyindex 68019b8d..c790058b 100644--- a/modules/sfp_censys.py+++ b/modules/sfp_censys.py@@ -136,7 +136,16 @@ class sfp_censys(SpiderFootPlugin):qtype = "host"rec = self.query(addr, qtype)+ self.sf.debug("Censys raw data: " + str(rec))if rec is not None:+ if 'error' in rec and 'error_type' == "unknown":+ self.sf.debug("Censys returned no data for " + addr)+ continue++ if 'error' in rec:+ self.sf.error("Censys returned an unexpected error: " + rec['error_type'], False)+ continue+self.sf.debug("Found results in Censys.io")# 2016-12-24T07:25:35+00:00'try:@@ -179,6 +188,6 @@ class sfp_censys(SpiderFootPlugin):e = SpiderFootEvent("OPERATING_SYSTEM", dat, self.__name__, event)self.notifyListeners(e)except BaseException as e:- self.sf.error("Error encountered processing record for " + eventData, False)+ self.sf.error("Error encountered processing record for " + eventData + " (" + str(e) + ")", False)# End of sfp_censys classdiff --git a/modules/sfp_clearbit.py b/modules/sfp_clearbit.pyindex 2bbd7066..fb7cfa21 100644--- a/modules/sfp_clearbit.py+++ b/modules/sfp_clearbit.py@@ -32,11 +32,13 @@ class sfp_clearbit(SpiderFootPlugin):# Be sure to completely clear any class variables in setup()# or you run the risk of data persisting between scan runs.- results = dict()+ results = None+ errorState = Falsedef setup(self, sfc, userOpts=dict()):self.sf = sfcself.results = dict()+ self.errorState = False# Clear / reset any other class member variables here# or you risk them persisting between threads.@@ -84,6 +86,14 @@ class sfp_clearbit(SpiderFootPlugin):srcModuleName = event.moduleeventData = event.data+ if self.errorState:+ return None++ if self.opts['api_key'] == "":+ self.sf.error("You enabled sfp_clearbit but did not set an API key!", False)+ self.errorState = True+ return None+self.sf.debug("Received event, " + eventName + ", from " + srcModuleName)# Don't look up stuff twicediff --git a/modules/sfp_commoncrawl.py b/modules/sfp_commoncrawl.pyindex f95af947..434c98a4 100644--- a/modules/sfp_commoncrawl.py+++ b/modules/sfp_commoncrawl.py@@ -23,7 +23,7 @@ class sfp_commoncrawl(SpiderFootPlugin):# Default optionsopts = {- "indexes": 3+ "indexes": 6}# Option descriptions@@ -49,7 +49,7 @@ class sfp_commoncrawl(SpiderFootPlugin):for index in self.indexBase:url = "https://index.commoncrawl.org/" + index + \"-index?url=" + target + "/*&output=json"- res = self.sf.fetchUrl(url , timeout=self.opts['_fetchtimeout'],+ res = self.sf.fetchUrl(url , timeout=60,useragent="SpiderFoot")if res['code'] in [ "400", "401", "402", "403", "404" ]:@@ -68,7 +68,7 @@ class sfp_commoncrawl(SpiderFootPlugin):def getLatestIndexes(self):url = "https://commoncrawl.s3.amazonaws.com/cc-index/collections/index.html"- res = self.sf.fetchUrl(url , timeout=self.opts['_fetchtimeout'],+ res = self.sf.fetchUrl(url , timeout=60,useragent="SpiderFoot")if res['code'] in [ "400", "401", "402", "403", "404" ]:diff --git a/modules/sfp_cymon.py b/modules/sfp_cymon.pyindex e037ea3c..fe616ec7 100644--- a/modules/sfp_cymon.py+++ b/modules/sfp_cymon.py@@ -104,6 +104,10 @@ class sfp_cymon(SpiderFootPlugin):self.sf.info("No Cymon.io info found for " + qry)return None+ if len(res['content']) == 0:+ self.sf.info("No Cymon.io info found for " + qry)+ return None+try:info = json.loads(res['content'])except Exception as e:diff --git a/modules/sfp_email.py b/modules/sfp_email.pyindex db717254..63a9724e 100644--- a/modules/sfp_email.py+++ b/modules/sfp_email.py@@ -70,7 +70,7 @@ class sfp_email(SpiderFootPlugin):self.sf.debug("Unable to convert list/dict to string: " + str(e))return None- pat = re.compile("([\%a-zA-Z\.0-9_\-]+@[a-zA-Z\.0-9\-]+\.[a-zA-Z\.0-9\-]+)")+ pat = re.compile("([\%a-zA-Z\.0-9_\-\+]+@[a-zA-Z\.0-9\-]+\.[a-zA-Z\.0-9\-]+)")matches = re.findall(pat, eventData)myres = list()for match in matches:diff --git a/modules/sfp_github.py b/modules/sfp_github.pyindex ccbde285..8572c838 100644--- a/modules/sfp_github.py+++ b/modules/sfp_github.py@@ -52,13 +52,13 @@ class sfp_github(SpiderFootPlugin):repo_info = None# Get repos matching the name- if item['name'] == None:+ if item.get('name') == None:self.sf.debug("Incomplete Github information found (name).")return None- if item['html_url'] == None:+ if item.get('html_url') == None:self.sf.debug("Incomplete Github information found (url).")return None- if item['description'] == None:+ if item.get('description') == None:self.sf.debug("Incomplete Github information found (description).")return None@@ -192,7 +192,7 @@ class sfp_github(SpiderFootPlugin):if not failed:# For each user matching the name, get their reposfor item in ret['items']:- if item['repos_url'] == None:+ if item.get('repos_url') == None:self.sf.debug("Incomplete Github information found (repos_url).")continue@@ -202,20 +202,24 @@ class sfp_github(SpiderFootPlugin):if res['content'] == None:self.sf.error("Unable to fetch " + url, False)- continue+ continue- repret = json.loads(res['content'])- if repret == None:- self.sf.error("Unable to process empty response from Github for: " + \- name, False)+ try:+ repret = json.loads(res['content'])+ except BaseException as e:+ self.sf.error("Invalid JSON returned from Github.", False)continue- if 'items' not in repret:+ if repret == None:self.sf.error("Unable to process empty response from Github for: " + \name, False)continuefor item in repret:+ if type(item) != dict:+ self.sf.error("Encountered an unexpected response from Github.", False)+ continue+repo_info = self.buildRepoInfo(item)if repo_info != None:if self.opts['namesonly'] and name not in item['name']:diff --git a/modules/sfp_ipstack.py b/modules/sfp_ipstack.pyindex c1961c5a..4a1afad2 100644--- a/modules/sfp_ipstack.py+++ b/modules/sfp_ipstack.py@@ -31,6 +31,7 @@ class sfp_ipstack(SpiderFootPlugin):def setup(self, sfc, userOpts=dict()):self.sf = sfcself.results = dict()+ self.errorState = Falsefor opt in userOpts.keys():self.opts[opt] = userOpts[opt]@@ -56,6 +57,11 @@ class sfp_ipstack(SpiderFootPlugin):if self.errorState:return None+ if self.opts['api_key'] == "":+ self.sf.error("You enabled sfp_ipstack but did not set an API key!", False)+ self.errorState = True+ return None+# Don't look up stuff twiceif eventData in self.results:self.sf.debug("Skipping " + eventData + " as already mapped.")diff --git a/modules/sfp_isc.py b/modules/sfp_isc.pyindex 64b4105b..dea4e41c 100644--- a/modules/sfp_isc.py+++ b/modules/sfp_isc.py@@ -94,7 +94,7 @@ class sfp_isc(SpiderFootPlugin):cid = malchecks[check]['id']if id == cid and malchecks[check]['type'] == "query":url = unicode(malchecks[check]['url'])- res = self.sf.fetchUrl(url.format(target), timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])+ res = self.sf.fetchUrl(url.format(target), timeout=30, useragent=self.opts['_useragent'])if res['content'] is None:self.sf.error("Unable to fetch " + url.format(target), False)return None@@ -119,7 +119,7 @@ class sfp_isc(SpiderFootPlugin):url = malchecks[check]['url']data['content'] = self.sf.cacheGet("sfmal_" + cid, self.opts.get('cacheperiod', 0))if data['content'] is None:- data = self.sf.fetchUrl(url, timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])+ data = self.sf.fetchUrl(url, timeout=30, useragent=self.opts['_useragent'])if data['content'] is None:self.sf.error("Unable to fetch " + url, False)return Nonediff --git a/modules/sfp_pulsedive.py b/modules/sfp_pulsedive.pyindex c9a2da79..55811a45 100644--- a/modules/sfp_pulsedive.py+++ b/modules/sfp_pulsedive.py@@ -65,15 +65,14 @@ class sfp_pulsedive(SpiderFootPlugin):# What events this module producesdef producedEvents(self):return ["MALICIOUS_INTERNET_NAME", "MALICIOUS_IPADDR",- "MALICIOUS_AFFILIATE_IPADDR" ]+ "MALICIOUS_AFFILIATE_IPADDR", "MALICIOUS_NETBLOCK" ]def query(self, qry):ret = Noneurl = "https://pulsedive.com/api/info.php?indicator=" + qry + \"&key=" + self.opts['api_key']- res = self.sf.fetchUrl(url, timeout=self.opts['_fetchtimeout'],- useragent="SpiderFoot")+ res = self.sf.fetchUrl(url, timeout=30, useragent="SpiderFoot")if res['code'] == "403":self.sf.error("Pulsedive API key seems to have been rejected or you have exceeded usage limits for the month.", False)diff --git a/modules/sfp_ripe.py b/modules/sfp_ripe.pyindex aae5f326..8469fc5d 100644--- a/modules/sfp_ripe.py+++ b/modules/sfp_ripe.py@@ -311,7 +311,7 @@ class sfp_ripe(SpiderFootPlugin):self.sf.debug("Could not identify BGP AS for " + eventData)return None- if self.ownsAs(asn):+ if eventName == "NETBLOCK_OWNER" and self.ownsAs(asn):asevt = SpiderFootEvent("BGP_AS_OWNER", asn, self.__name__, event)self.notifyListeners(asevt)evt = SpiderFootEvent("RAW_RIR_DATA", self.lastContent, self.__name__,@@ -337,20 +337,9 @@ class sfp_ripe(SpiderFootPlugin):self.sf.debug("Could not identify BGP AS for " + prefix)return None- if self.ownsAs(asn):- # For now we skip IPv6 addresses- if ":" in prefix:- return None- self.sf.info("Owned netblock found: " + prefix + "(" + asn + ")")- evt = SpiderFootEvent("NETBLOCK_OWNER", prefix, self.__name__, event)- self.notifyListeners(evt)- evt = SpiderFootEvent("RAW_RIR_DATA", self.lastContent, self.__name__,- event)- self.notifyListeners(evt)- else:- self.sf.info("Netblock found: " + prefix + "(" + asn + ")")- evt = SpiderFootEvent("NETBLOCK_MEMBER", prefix, self.__name__, event)- self.notifyListeners(evt)+ self.sf.info("Netblock found: " + prefix + "(" + asn + ")")+ evt = SpiderFootEvent("NETBLOCK_MEMBER", prefix, self.__name__, event)+ self.notifyListeners(evt)return Nonediff --git a/modules/sfp_riskiq.py b/modules/sfp_riskiq.pyindex fd2a0c99..824a3107 100644--- a/modules/sfp_riskiq.py+++ b/modules/sfp_riskiq.py@@ -123,7 +123,10 @@ class sfp_riskiq(SpiderFootPlugin):return Nonetry:- return json.loads(res['content'])['results']+ ret = json.loads(res['content'])+ if 'results' not in ret:+ self.sf.info("No RiskIQ info found for " + qry)+ return Noneexcept BaseException as e:self.sf.error("Invalid JSON returned by RiskIQ.", False)return None@@ -211,7 +214,7 @@ class sfp_riskiq(SpiderFootPlugin):for co in cohosts:if eventName == "IP_ADDRESS" and (self.opts['verify'] and not self.validateIP(co, eventData)):- self.sf.debug("Host " + co + " no longer resolves to " + eventData)+ self.sf.debug("Host no longer resolves to our IP.")continueif not self.opts['cohostsamedomain']:diff --git a/modules/sfp_viewdns.py b/modules/sfp_viewdns.pyindex 515efaf7..b7edfdd6 100644--- a/modules/sfp_viewdns.py+++ b/modules/sfp_viewdns.py@@ -37,11 +37,13 @@ class sfp_viewdns(SpiderFootPlugin):results = dict()errorState = False+ accum = list()cohostcount = 0def setup(self, sfc, userOpts=dict()):self.sf = sfcself.results = dict()+ self.accum = list()self.cohostcount = 0# Clear / reset any other class member variables here@@ -76,7 +78,7 @@ class sfp_viewdns(SpiderFootPlugin):return False# Search ViewDNS.info- def query(self, qry, querytype, page=1, accum=list()):+ def query(self, qry, querytype, page=1):info = Noneif querytype == "reverseip":@@ -120,14 +122,11 @@ class sfp_viewdns(SpiderFootPlugin):return Noneif len(r.get(responsekey, list())) == pagesize:- if accum:- accum.extend(r.get(responsekey))- else:- accum = r.get(responsekey)- return self.query(qry, querytype, page+1, accum)+ self.sf.debug("Looping at ViewDNS page " + str(page))+ self.accum.extend(r.get(responsekey))+ self.query(qry, querytype, page+1)# We are at the last or only page- accum.extend(r.get(responsekey, []))- return accum+ self.accum.extend(r.get(responsekey, []))except Exception as e:self.sf.error("Error processing JSON response from ViewDNS.info: " + str(e), False)return None@@ -170,7 +169,9 @@ class sfp_viewdns(SpiderFootPlugin):self.sf.debug("DNS provider found but not related to target, skipping")return None- rec = self.query(eventData, ident)+ self.accum = list()+ self.query(eventData, ident)+ rec = self.accummyres = list()if rec is not None:for r in rec:@@ -192,7 +193,7 @@ class sfp_viewdns(SpiderFootPlugin):self.cohostcount += 1if eventName == "IP_ADDRESS" and self.opts['verify']:if not self.validateIP(h, eventData):- self.sf.debug("Host " + h + " no longer resolves to " + eventData)+ self.sf.debug("Host no longer resolves to our IP.")continuee = SpiderFootEvent("CO_HOSTED_SITE", h, self.__name__, event)self.notifyListeners(e)diff --git a/modules/sfp_whois.py b/modules/sfp_whois.pyindex 3ac9a596..29ef5776 100644--- a/modules/sfp_whois.py+++ b/modules/sfp_whois.py@@ -77,7 +77,7 @@ class sfp_whois(SpiderFootPlugin):if whoisdata:data = str(whoisdata)if not data:- self.sf.error("Unable to perform WHOIS on " + eventData + ": " + str(e), False)+ self.sf.error("Unable to perform WHOIS on " + eventData, False)return Noneexcept BaseException as e:self.sf.error("Unable to perform WHOIS on " + eventData + ": " + str(e), False)diff --git a/modules/sfp_whoisology.py b/modules/sfp_whoisology.pyindex a772e301..97e2e7b7 100644--- a/modules/sfp_whoisology.py+++ b/modules/sfp_whoisology.py@@ -76,12 +76,15 @@ class sfp_whoisology(SpiderFootPlugin):try:info = json.loads(res['content'])- if len(info.get("domains", list())) == 0:+ if info.get("domains") == None:self.sf.error("Error querying Whoisology: " + info.get("status_reason", "Unknown"), False)- self.errorState = True+ return None++ if len(info.get("domains", [])) == 0:+ self.sf.debug("No data found in Whoisology for " + qry)return Noneelse:- return info.get('domains', [])+ return info.get('domains')except Exception as e:self.sf.error("Error processing JSON response from Whoisology: " + str(e), False)return None