Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

Bug fixes

smicallefdb527f8064ea
diff --git a/dyn/scanlist.tmpl b/dyn/scanlist.tmpl
index d5adb75e..92b2d8c6 100644
--- a/dyn/scanlist.tmpl
+++ b/dyn/scanlist.tmpl
@@ -26,7 +26,7 @@
return;
}
var table = "<table class='table table-bordered table-striped'>";
- table += "<thead><tr> <th>Name</th> <th>Target</th> <th>Started</th> <th>Finished</th> <th>Status</th> <th>Events</th><th>Action</th> </tr></thead><tbody>";
+ table += "<thead><tr> <th>Name</th> <th>Target</th> <th>Started</th> <th >Finished</th> <th style='text-align: center'>Status</th> <th style='text-align: center'>Elements</th><th style='text-align: center'>Action</th> </tr></thead><tbody>";
for (var i = 0; i < data.length; i++) {
table += "<tr><td><a href=/scaninfo?id=" + data[i][0] + ">" + data[i][1] + "</a></td>";
table += "<td>" + data[i][2] + "&nbsp;&nbsp;<a target='_new' href='" + data[i][2] + "'><i class='icon-share icon-gray'></a></td>";
@@ -46,7 +46,7 @@
status = "badge-important";
}
table += "<td style='text-align: center'><span class='badge " + status + "'>" + data[i][6] + "</span></td>";
- table += "<td>" + data[i][7] + "</td>";
+ table += "<td style='text-align: center'>" + data[i][7] + "</td>";
table += "<td style='text-align: center'>";
if (data[i][6] == "RUNNING" || data[i][6] == "STARTING" || data[i][6] == "STARTED") {
table += "<a href=/stopscan?id=" + data[i][0] +"><i class='icon-stop icon-gray'></a></td>";
diff --git a/modules/sfp_dns.py b/modules/sfp_dns.py
index 96bae47b..a15ba624 100644
--- a/modules/sfp_dns.py
+++ b/modules/sfp_dns.py
@@ -72,7 +72,10 @@ class sfp_dns(SpiderFootPlugin):
try:
if eventName != 'IP_ADDRESS':
- addrs = socket.gethostbyname_ex(eventData)
+ if '://' in eventData:
+ addrs = socket.gethostbyname_ex(sf.urlFQDN(eventData))
+ else:
+ addrs = socket.gethostbyname_ex(eventData)
else:
addrs = socket.gethostbyaddr(eventData)
except socket.error as e:
diff --git a/modules/sfp_similar.py b/modules/sfp_similar.py
index c3f41577..50c51103 100644
--- a/modules/sfp_similar.py
+++ b/modules/sfp_similar.py
@@ -190,6 +190,9 @@ class sfp_similar(SpiderFootPlugin):
# Store the result internally and notify listening modules
def storeResult(self, source, result):
+ if result == self.baseDomain:
+ return
+
sf.info("Found a similar domain: " + result)
self.results.append(result)
diff --git a/modules/sfp_stor_db.py b/modules/sfp_stor_db.py
index 4fc3a799..12aa87bd 100644
--- a/modules/sfp_stor_db.py
+++ b/modules/sfp_stor_db.py
@@ -52,8 +52,15 @@ class sfp_stor_db(SpiderFootPlugin):
# Handle events sent to this module
def handleEvent(self, srcModuleName, eventName, eventSource, eventData):
+ # If we get passed a dict or list, convert it to a string first, as
+ # those types do not have a unicode converter.
+ if type(eventData) not in [unicode, str]:
+ eventData = str(eventData)
+
# Convert to a string in case we get passed integers or other things
- eventData = str(eventData)
+ if type(eventData) is not unicode:
+ eventData = unicode(eventData, 'utf-8', errors='ignore')
+
if self.opts['maxstorage'] != 0:
if len(eventData) > self.opts['maxstorage']:
sf.debug("Truncated " + eventName + " data due to storage limitation")
diff --git a/modules/sfp_xref.py b/modules/sfp_xref.py
index 4b79d3fb..f633a00e 100644
--- a/modules/sfp_xref.py
+++ b/modules/sfp_xref.py
@@ -82,12 +82,11 @@ class sfp_xref(SpiderFootPlugin):
else:
url = eventData
- sf.info("Testing for affiliation: " + url)
-
if url in self.fetched:
sf.debug("Ignoring " + url + " as already tested")
return
+ sf.info("Testing for affiliation: " + url)
res = sf.fetchUrl(url)
self.fetched.append(url)
diff --git a/sfdb.py b/sfdb.py
index 6c7b266b..fd99d1c2 100644
--- a/sfdb.py
+++ b/sfdb.py
@@ -293,7 +293,7 @@ class SpiderFootDb:
event_data, event_data_source) \
VALUES (?, ?, ?, ?, ?, ?)"
qvals = [instanceId, time.time() * 1000, eventName, eventSource,
- eventData.__str__(), eventDataSource]
+ eventData, eventDataSource]
#print "STORING: " + str(qvals)
@@ -325,3 +325,16 @@ class SpiderFootDb:
return self.dbh.fetchall()
except sqlite3.Error as e:
sf.error("SQL error encountered when fetching scan list: " + e.args[0])
+
+ # History of data from the scan
+ def scanResultHistory(self, instanceId):
+ qry = "SELECT STRFTIME('%H:%M %w', ROUND(generated/1000), 'unixepoch') AS hourmin, \
+ event, COUNT(*) FROM tbl_scan_results \
+ WHERE scan_instance_id = ? GROUP BY hourmin, event"
+ qvars = [instanceId]
+ try:
+ self.dbh.execute(qry, qvars)
+ return self.dbh.fetchall()
+ except sqlite3.Error as e:
+ sf.error("SQL error encountered when fetching scan history: " + e.args[0])
+
diff --git a/sflib.py b/sflib.py
index e5d02d56..748bfb3d 100644
--- a/sflib.py
+++ b/sflib.py
@@ -48,7 +48,7 @@ class SpiderFoot:
print '[Error] ' + error
else:
self._dblog("ERROR", error)
- if not exception:
+ if exception:
raise BaseException("Internal Error Encountered: " + error)
def fatal(self, error):
@@ -261,6 +261,12 @@ class SpiderFoot:
self.debug('base url of ' + url + ' is: ' + bits.group(1))
return bits.group(1).lower()
+ # Extract the FQDN from a URL
+ def urlFQDN(self, url):
+ baseurl = self.urlBaseUrl(url)
+ # http://abc.com will split to ['http:', '', 'abc.com']
+ return baseurl.split('/')[2].lower()
+
# Extract the keyword (the domain without the TLD or any subdomains)
# from a domain. Crude for now.. just gets the first word.
def domainKeyword(self, domain):
@@ -470,7 +476,7 @@ class SpiderFootPlugin(object):
#print "Notifications blocked for " + eventName + " to " + listener.__module__
return None
- if eventData == None or len(str(eventData)) == 0:
+ if eventData == None or (type(eventData) is unicode and len(eventData) == 0):
#print "No data to send for " + eventName + " to " + listener.__module__
return None
diff --git a/sfscan.py b/sfscan.py
index a1a05953..c9e2b38f 100644
--- a/sfscan.py
+++ b/sfscan.py
@@ -140,7 +140,8 @@ class SpiderFootScanner:
self.status = "FINISHED"
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
- self.sf.error("Unhandled exception encountered during scan. Please report this as a bug: " + \
+ self.sf.error("Unhandled exception encountered during scan. " + \
+ "Please report this as a bug: " + \
repr(traceback.format_exception(exc_type, exc_value, exc_traceback)), False)
self.sf.status("Scan [" + self.config['__guid__'] + "] failed: " + str(e))
dbh.scanInstanceSet(self.config['__guid__'], None, time.time() * 1000, 'ERROR-FAILED')
diff --git a/sfwebui.py b/sfwebui.py
index 399a2669..9c1fa107 100644
--- a/sfwebui.py
+++ b/sfwebui.py
@@ -274,6 +274,13 @@ class SpiderFootWebUi:
return json.dumps(retdata, ensure_ascii=False)
scaneventresults.exposed = True
+ # Historical data for the scan, graphs will be rendered in JS
+ def scanhistory(self, id):
+ dbh = SpiderFootDb(self.config)
+ data = dbh.scanResultHistory(id)
+ return json.dumps(data, ensure_ascii=False)
+ scanhistory.exposed = True
+
# Special class used when SpiderFoot is started without a
# database pre-existing. This will step the user through
# the creation of one.