SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Bug fixes and minor improvements.
Steve Micallefe52166e8302f
diff --git a/modules/sfp_censys.py b/modules/sfp_censys.pyindex 11ffc270..68019b8d 100644--- a/modules/sfp_censys.py+++ b/modules/sfp_censys.py@@ -139,43 +139,46 @@ class sfp_censys(SpiderFootPlugin):if rec is not None:self.sf.debug("Found results in Censys.io")# 2016-12-24T07:25:35+00:00'- created_dt = datetime.strptime(rec.get('updated_at'), '%Y-%m-%dT%H:%M:%S+00:00')- created_ts = int(time.mktime(created_dt.timetuple()))- age_limit_ts = int(time.time()) - (86400 * self.opts['age_limit_days'])- if self.opts['age_limit_days'] > 0 and created_ts < age_limit_ts:- self.sf.debug("Record found but too old, skipping.")- continue- if 'location' in rec:- dat = rec['location'].get('country')- if dat:- e = SpiderFootEvent("GEOINFO", dat, self.__name__, event)+ try:+ created_dt = datetime.strptime(rec.get('updated_at'), '%Y-%m-%dT%H:%M:%S+00:00')+ created_ts = int(time.mktime(created_dt.timetuple()))+ age_limit_ts = int(time.time()) - (86400 * self.opts['age_limit_days'])+ if self.opts['age_limit_days'] > 0 and created_ts < age_limit_ts:+ self.sf.debug("Record found but too old, skipping.")+ continue+ if 'location' in rec:+ dat = rec['location'].get('country')+ if dat:+ e = SpiderFootEvent("GEOINFO", dat, self.__name__, event)+ self.notifyListeners(e)++ if 'headers' in rec:+ dat = rec['headers']+ e = SpiderFootEvent("WEBSERVER_HTTPHEADERS", dat, self.__name__, event)self.notifyListeners(e)- if 'headers' in rec:- dat = rec['headers']- e = SpiderFootEvent("WEBSERVER_HTTPHEADERS", dat, self.__name__, event)- self.notifyListeners(e)-- if 'autonomous_system' in rec:- dat = str(rec['autonomous_system']['asn'])- e = SpiderFootEvent("BGP_AS_MEMBER", dat, self.__name__, event)- self.notifyListeners(e)- dat = rec['autonomous_system']['routed_prefix']- e = SpiderFootEvent("NETBLOCK_MEMBER", dat, self.__name__, event)- self.notifyListeners(e)-- if 'protocols' in rec:- for p in rec['protocols']:- if 'ip' not in rec:- continue- dat = rec['ip'] + ":" + p.split("/")[0]- e = SpiderFootEvent("TCP_PORT_OPEN", dat, self.__name__, event)+ if 'autonomous_system' in rec:+ dat = str(rec['autonomous_system']['asn'])+ e = SpiderFootEvent("BGP_AS_MEMBER", dat, self.__name__, event)self.notifyListeners(e)-- if 'metadata' in rec:- if 'os_description' in rec['metadata']:- dat = rec['metadata']['os_description']- e = SpiderFootEvent("OPERATING_SYSTEM", dat, self.__name__, event)+ dat = rec['autonomous_system']['routed_prefix']+ e = SpiderFootEvent("NETBLOCK_MEMBER", dat, self.__name__, event)self.notifyListeners(e)-++ if 'protocols' in rec:+ for p in rec['protocols']:+ if 'ip' not in rec:+ continue+ dat = rec['ip'] + ":" + p.split("/")[0]+ e = SpiderFootEvent("TCP_PORT_OPEN", dat, self.__name__, event)+ self.notifyListeners(e)++ if 'metadata' in rec:+ if 'os_description' in rec['metadata']:+ dat = rec['metadata']['os_description']+ 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)+# End of sfp_censys classdiff --git a/modules/sfp_dnsresolve.py b/modules/sfp_dnsresolve.pyindex e83c886a..0eabe399 100644--- a/modules/sfp_dnsresolve.py+++ b/modules/sfp_dnsresolve.py@@ -15,7 +15,6 @@ import socketimport reimport dnsimport urllib2-import encodingsfrom netaddr import IPAddress, IPNetworkfrom sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEventdiff --git a/modules/sfp_github.py b/modules/sfp_github.pyindex 3f42ff7a..e7908c42 100644--- a/modules/sfp_github.py+++ b/modules/sfp_github.py@@ -28,11 +28,11 @@ class sfp_github(SpiderFootPlugin):'namesonly': "Match repositories by name only, not by their descriptions. Helps reduce false positives."}- results = dict()+ results = Nonedef setup(self, sfc, userOpts=dict()):self.sf = sfc- self.results = dict()+ self.results = self.tempStorage()for opt in userOpts.keys():self.opts[opt] = userOpts[opt]@@ -152,7 +152,7 @@ class sfp_github(SpiderFootPlugin):failed = Trueif not failed:- if ret['total_count'] == "0" or len(ret['items']) == 0:+ if ret.get('total_count', "0") == "0" or len(ret['items']) == 0:self.sf.debug("No Github information for " + name)failed = True@@ -185,7 +185,7 @@ class sfp_github(SpiderFootPlugin):failed = Trueif not failed:- if ret['total_count'] == "0" or len(ret['items']) == 0:+ if ret.get('total_count', "0") == "0" or len(ret['items']) == 0:self.sf.debug("No Github information for " + name)failed = True@@ -210,6 +210,11 @@ class sfp_github(SpiderFootPlugin):name, False)continue+ if 'items' not in repret:+ self.sf.error("Unable to process empty response from Github for: " + \+ name, False)+ continue+for item in repret:repo_info = self.buildRepoInfo(item)if repo_info != None:diff --git a/modules/sfp_securitytrails.py b/modules/sfp_securitytrails.pyindex c3e022eb..f5b16ddf 100644--- a/modules/sfp_securitytrails.py+++ b/modules/sfp_securitytrails.py@@ -25,14 +25,16 @@ class sfp_securitytrails(SpiderFootPlugin):opts = {"api_key": "","verify": True,- "cohostsamedomain": False+ "cohostsamedomain": False,+ 'maxcohost': 100}# Option descriptionsoptdescs = {"api_key": "SecurityTrails API key.","verify": "Verify co-hosts are valid by checking if they still resolve to the shared IP.",- "cohostsamedomain": "Treat co-hosted sites on the same target domain as co-hosting?"+ "cohostsamedomain": "Treat co-hosted sites on the same target domain as co-hosting?",+ 'maxcohost': "Stop reporting co-hosted sites after this many are found, as it would likely indicate web hosting."}# Be sure to completely clear any class variables in setup()@@ -40,10 +42,12 @@ class sfp_securitytrails(SpiderFootPlugin):results = dict()errorState = False+ cohostcount = 0def setup(self, sfc, userOpts=dict()):self.sf = sfcself.results = dict()+ self.cohostcount = 0# Clear / reset any other class member variables here# or you risk them persisting between threads.@@ -170,6 +174,9 @@ class sfp_securitytrails(SpiderFootPlugin):self.notifyListeners(e)hosters.append(dat)if "hostname" in r:+ if self.cohostcount > self.opts['maxcohost']:+ continue+h = r['hostname']if not self.opts['cohostsamedomain']:if self.getTarget().matches(h, includeParents=True):@@ -178,11 +185,12 @@ class sfp_securitytrails(SpiderFootPlugin):if h not in myres and h != ip:if self.opts['verify'] and not self.validateIP(h, ip):- self.sf.debug("Host " + h + " no longer resolves to " + ip)+ self.sf.debug("Host no longer resolves to our IP.")continuemyres.append(h.lower())e = SpiderFootEvent("CO_HOSTED_SITE", h, self.__name__, event)self.notifyListeners(e)+ self.cohostcount += 1if eventName in [ "EMAILADDR"]:email = eventDatadiff --git a/modules/sfp_spider.py b/modules/sfp_spider.pyindex c5aa449a..562ce973 100644--- a/modules/sfp_spider.py+++ b/modules/sfp_spider.py@@ -31,6 +31,7 @@ class sfp_spider(SpiderFootPlugin):'mpeg', 'iso', 'dat', 'mov', 'swf', 'rar', 'exe', 'zip','bin', 'bz2', 'xsl', 'doc', 'docx', 'ppt', 'pptx', 'xls','xlsx', 'csv'],+ 'filtermime': ['image/'],'filterusers': True, # Don't follow /~user directories'nosubs': False, # Should links to subdomains be ignored?'reportduplicates': False,@@ -46,6 +47,7 @@ class sfp_spider(SpiderFootPlugin):'maxpages': "Maximum number of pages to fetch per starting point identified.",'maxlevels': "Maximum levels to traverse per starting point (e.g. hostname or link identified by another module) identified.",'filterfiles': "File extensions to ignore (don't fetch them.)",+ 'filtermime': "MIME types to ignore.",'filterusers': "Skip spidering of /~user directories?",'nosubs': "Skip spidering of subdomains of the target?",'reportduplicates': "Report links every time one is found, even if found before?",@@ -194,9 +196,20 @@ class sfp_spider(SpiderFootPlugin):# Notify listening modules about raw data and othersdef contentNotify(self, url, httpresult, parentEvent=None):- event = SpiderFootEvent("TARGET_WEB_CONTENT", httpresult['content'],- self.__name__, parentEvent)- self.notifyListeners(event)+ sendcontent = True+ if httpresult.get('headers'):+ ctype = httpresult['headers'].get('content-type')+ if not ctype:+ sendcontent = True+ else:+ for mt in self.opts['filtermime']:+ if ctype.startswith(mt):+ sendcontent = False++ if sendcontent:+ event = SpiderFootEvent("TARGET_WEB_CONTENT", httpresult['content'],+ self.__name__, parentEvent)+ self.notifyListeners(event)event = SpiderFootEvent("WEBSERVER_HTTPHEADERS", httpresult['headers'],self.__name__, parentEvent)diff --git a/modules/sfp_viewdns.py b/modules/sfp_viewdns.pyindex 2e1f5438..9e7ee616 100644--- a/modules/sfp_viewdns.py+++ b/modules/sfp_viewdns.py@@ -119,7 +119,7 @@ class sfp_viewdns(SpiderFootPlugin):self.sf.error("Error querying ViewDNS.info: " + r.get("error", "Unknown"), False)return None- if len(r.get(responsekey), list()) == pagesize:+ if len(r.get(responsekey, list())) == pagesize:if accum:accum.extend(r.get(responsekey))else:diff --git a/sfdb.py b/sfdb.pyindex 18ded106..c4c45600 100644--- a/sfdb.py+++ b/sfdb.py@@ -174,7 +174,7 @@ class SpiderFootDb:"INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('PROVIDER_MAIL', 'Email Gateway (DNS ''MX'' Records)', 0, 'ENTITY')","INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('PROVIDER_HOSTING', 'Hosting Provider', 0, 'ENTITY')","INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('PUBLIC_CODE_REPO', 'Public Code Repository', 0, 'ENTITY')",- "INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('RAW_RIR_DATA', 'Raw Data from RIRs', 1, 'DATA')",+ "INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('RAW_RIR_DATA', 'Raw Data from RIRs/APIs', 1, 'DATA')","INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('RAW_DNS_RECORDS', 'Raw DNS Records', 1, 'DATA')","INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('RAW_FILE_META_DATA', 'Raw File Meta Data', 1, 'DATA')","INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('SEARCH_ENGINE_WEB_CONTENT', 'Search Engine''s Web Content', 1, 'DATA')",