Skip to content

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

GEXF exports should have color too..

smicallef94b4e37a48de
diff --git a/sflib.py b/sflib.py
index 941a749d..17cabb29 100644
--- a/sflib.py
+++ b/sflib.py
@@ -147,7 +147,9 @@ class SpiderFoot:
# Convert supplied raw data into GEXF format (e.g. for Gephi)
# GEXF produced by PyGEXF doesn't work with SigmaJS because
# SJS needs coordinates for each node.
- def buildGraphGexf(self, title, data, flt=list()):
+ # flt is a list of event types to include, if not set everything is
+ # included.
+ def buildGraphGexf(self, root, title, data, flt=[]):
mapping = self.buildGraphData(data, flt)
g = gexf.Gexf(title, title)
graph = g.addGraph("undirected", "static", "SpiderFoot Export")
@@ -157,17 +159,25 @@ class SpiderFoot:
ncounter = 0
for pair in mapping:
(dst, src) = pair
+ col = ["0", "0", "0"]
+
# Leave out this special case
- if dst == "ROOT":
+ if dst == "ROOT" or src == "ROOT":
continue
if dst not in nodelist:
ncounter = ncounter + 1
- graph.addNode(str(ncounter), unicode(dst, errors="replace"))
+ if dst in root:
+ col = ["255", "0", "0"]
+ graph.addNode(str(ncounter), unicode(dst, errors="replace"),
+ r=col[0], g=col[1], b=col[2])
nodelist[dst] = ncounter
if src not in nodelist:
ncounter = ncounter + 1
- graph.addNode(str(ncounter), unicode(src, errors="replace"))
+ if src in root:
+ col = ["255", "0", "0"]
+ graph.addNode(str(ncounter), unicode(src, errors="replace"),
+ r=col[0], g=col[1], b=col[2])
nodelist[src] = ncounter
ecounter = ecounter + 1
@@ -196,7 +206,7 @@ class SpiderFoot:
continue
if dst not in nodelist:
ncounter = ncounter + 1
- if dst == root:
+ if dst in root:
col = "#f00"
ret['nodes'].append({'id': str(ncounter),
'label': unicode(dst, errors="replace"),
@@ -208,7 +218,7 @@ class SpiderFoot:
nodelist[dst] = ncounter
if src not in nodelist:
- if src == root:
+ if src in root:
col = "#f00"
ncounter = ncounter + 1
ret['nodes'].append({'id': str(ncounter),
diff --git a/sfwebui.py b/sfwebui.py
index 16f9aa5f..2258c921 100644
--- a/sfwebui.py
+++ b/sfwebui.py
@@ -178,14 +178,14 @@ class SpiderFootWebUi:
sf = SpiderFoot(self.config)
data = dbh.scanResultEvent(id)
scan = dbh.scanInstanceGet(id)
+ root = scan[1]
if gexf != "0":
cherrypy.response.headers['Content-Disposition'] = "attachment; filename=SpiderFoot.gexf"
cherrypy.response.headers['Content-Type'] = "application/gexf"
cherrypy.response.headers['Pragma'] = "no-cache"
- return sf.buildGraphGexf("SpiderFoot Export", data)
+ return sf.buildGraphGexf([root], "SpiderFoot Export", data)
else:
- root = scan[1]
- return sf.buildGraphJson(root, data)
+ return sf.buildGraphJson([root], data)
scanviz.exposed = True
@@ -195,18 +195,19 @@ class SpiderFootWebUi:
dbh = SpiderFootDb(self.config)
sf = SpiderFoot(self.config)
data = list()
+ roots = list()
for id in ids.split(','):
data = data + dbh.scanResultEvent(id)
+ roots.append(dbh.scanInstanceGet(id)[1])
if gexf != "0":
cherrypy.response.headers['Content-Disposition'] = "attachment; filename=SpiderFoot.gexf"
cherrypy.response.headers['Content-Type'] = "application/gexf"
cherrypy.response.headers['Pragma'] = "no-cache"
- return sf.buildGraphGexf("SpiderFoot Export", data)
+ return sf.buildGraphGexf(roots, "SpiderFoot Export", data)
else:
# Not implemented yet
return None
- #return sf.buildGraphJson(data)
scanvizmulti.exposed = True