Skip to content

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

View scan config, create DB on first use.

smicallef77080af1fce7
diff --git a/dyn/HEADER.tmpl b/dyn/HEADER.tmpl
index 4b8eb4ef..e1ad0887 100644
--- a/dyn/HEADER.tmpl
+++ b/dyn/HEADER.tmpl
@@ -48,7 +48,7 @@
% if pageid == "SCANLIST":
class="active"
% endif
-><a href="/"><i class="icon-book"></i>&nbsp;Scans</a></li>
+><a href="/"><i class="icon-list"></i>&nbsp;Scans</a></li>
<li
% if pageid == "SETTINGS":
class="active"
@@ -56,13 +56,28 @@
><a href="/opts"><i class="icon-wrench"></i>&nbsp;Settings</a></li>
</ul>
<ul class="nav pull-right">
- <li><a href="#"><i class="icon-info-sign"></i>&nbsp;About</a></li>
+ <li><a href="#aboutmodal" data-toggle="modal"><i class="icon-info-sign"></i>&nbsp;About</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
+ <div id="aboutmodal" class="modal hide fade">
+ <div class="modal-header">
+ <h3>SpiderFoot 2.0</h3>
+ </div>
+ <div class="modal-body">
+ <p>SpiderFoot is an open source GPL-licensed footprinting tool, designed to be easy to use, fast and extensible.</p>
+ <p>If you have any bugs to report, or requests for enhancements, please contact the support mailing list at <a href=mailto:[email protected]>[email protected]</a>.
+ <br>
+ <p>You are running version <b>2.0.0</b>.</p>
+ </div>
+ <div class="modal-footer">
+ <a href="#" data-dismiss="modal" class="btn">Close</a>
+ </div>
+ </div>
+
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
diff --git a/dyn/newscan.tmpl b/dyn/newscan.tmpl
index 4ce28920..c235f125 100644
--- a/dyn/newscan.tmpl
+++ b/dyn/newscan.tmpl
@@ -35,7 +35,7 @@ Another scan is currently running (${runningScan}). Please either wait for that
<div class="control-group">
<label class="control-label" for="moduletable">Modules</label>
<table class="table table-striped table-condensed" id="moduletable">
- % for item in modules:
+ % for item in sorted(modules):
<tr><td><input type=checkbox id="module_${item}" checked></td><td>${item}</td><td>${modules[item]['descr']}</td></tr>
% endfor
</table>
diff --git a/dyn/scaninfo.tmpl b/dyn/scaninfo.tmpl
index e4913eb4..3a6e540b 100644
--- a/dyn/scaninfo.tmpl
+++ b/dyn/scaninfo.tmpl
@@ -2,10 +2,9 @@
<h2>${name}</h2>
<div class="btn-toolbar">
<div class="btn-group">
- <a class="btn" href="#">Report</a>
- <a class="btn active" href="#" onClick='browseEventList("${id}")'>Browse</a>
- <a class="btn" href="#">Scan Info</a>
- <a class="btn" href="#">Search</a>
+ <a id='btn-browse' class="btn active" href="#" onClick='browseEventList("${id}")'>Browse</a>
+ <a id='btn-info' class="btn" href="#" onClick='viewScanConfig("${id}")'>Scan Info</a>
+ <a id='btn-export' class="btn" href="#">Export</a>
</div>
</div>
@@ -17,10 +16,23 @@ Loading...
</div>
<script type='text/javascript'>
+ function navTo(target) {
+ var targets = [ "btn-browse", "btn-info", "btn-export" ]
+ for (var i = 0; i < targets.length; i++) {
+ if (targets[i] == target) {
+ $("#" + targets[i]).addClass("active");
+ } else {
+ $("#" + targets[i]).removeClass("active");
+ }
+ }
+ }
+
// Summary of event types and counts for a scan
function browseEventList(instanceId) {
// Remove pre-existing tables if they exist
$("#scansummary-content").remove();
+ navTo("btn-browse");
+ $("#loader").show();
sf.fetchData('/scansummary', {'id': instanceId}, function(data) {
var table = "<table id='scansummary-content' class='table table-bordered table-striped'>";
table += "<thead><tr> <th>Type</th> <th>Events</th><th>Last Provided</th></tr></thead><tbody>";
@@ -41,11 +53,12 @@ Loading...
function browseEventData(instanceId, eventType) {
$("#scansummary-content").remove();
$("#loader").show();
+ navTo("btn-browse");
sf.fetchData('/scaneventresults', {'id': instanceId, 'eventType': eventType }, function(data) {
var table = "<table id='scansummary-content' class='table table-bordered table-striped small'>";
table += "<thead><tr> <th>Data Element</th><th>Obtained</th><th>Source</th><th>Module</th></tr></thead><tbody>";
for (var i = 0; i < data.length; i++) {
- table += "<tr><td>" + data[i][1] + "</td><td>" + data[i][0] + "</td><td>" + data[i][2] + "</td><td>" + data[i][3] + "</td></tr>";
+ table += "<tr><td width=75%><pre>" + data[i][1] + "</pre></td><td>" + data[i][0] + "</td><td>" + data[i][2] + "</td><td>" + data[i][3] + "</td></tr>";
}
table += "</tbody></table>"
$("#loader").fadeOut(250);
@@ -53,6 +66,47 @@ Loading...
});
}
+ // View the configuration that was used for this scan
+ function viewScanConfig(instanceId) {
+ $("#scansummary-content").remove();
+ $("#loader").show();
+ navTo("btn-info");
+ sf.fetchData('/scanopts', {'id': instanceId}, function(data) {
+ table = "<div id='scansummary-content'>";
+ table += "<h4>Meta Information</h4>";
+ table += "<table class='table table-bordered table-striped' style='width: 400px'>";
+ table += "<tr><td>Name:</td><td>" + data['meta'][0] + "</td></tr>";
+ table += "<tr><td>Target:</td><td>" + data['meta'][1] + "</td></tr>";
+ table += "<tr><td>Started:</td><td>" + data['meta'][3] + "</td></tr>";
+ table += "<tr><td>Completed:</td><td>" + data['meta'][4] + "</td></tr>";
+ table += "<tr><td>Status:</td><td>" + data['meta'][5] + "</td></tr>";
+ table += "</table>";
+ table += "<h4>Global Settings</h4>";
+ table += "<table class='table table-bordered table-striped' style='width: 400px'>";
+ table += "<thead><tr> <th>Option</th> <th>Value</th></tr></thead><tbody>";
+ for (var key in data['config']) {
+ if (key.indexOf(":") > 0) {
+ continue;
+ }
+ table += "<tr><td>" + key + "</td><td>" + data['config'][key] + "</td></tr>";
+ }
+ table += "</table>";
+ table += "<h4>Module Settings</h4>";
+ table += "<table class='table table-bordered table-striped' style='width: 400px'>";
+ table += "<thead><tr><th>Module</th> <th>Option</th> <th>Value</th></tr></thead><tbody>";
+ for (var key in data['config']) {
+ if (key.indexOf(":") > 0) {
+ bits = key.split(":");
+ table += "<tr><td>" + bits[0] + "</td><td>" + bits[1] + "</td><td>" + data['config'][key] + "</td></tr>";
+ }
+ }
+ table += "</table></div>";
+
+ $("#loader").fadeOut(250);
+ $("#mainbody").append(table);
+ });
+ }
+
browseEventList("${id}");
</script>
diff --git a/dyn/scanlist.tmpl b/dyn/scanlist.tmpl
index 72393fb1..03aa2595 100644
--- a/dyn/scanlist.tmpl
+++ b/dyn/scanlist.tmpl
@@ -25,7 +25,7 @@ Loading...
if (data.length == 0) {
$("#loader").fadeOut(250);
welcome = "<div class='alert alert-info'>";
- welcome += "<h4>Welcome to SpiderFoot!</h4>";
+ welcome += "<h4>Run your first scan!</h4>";
welcome += "There is currently no history of previously run scans. Please click 'New Scan' to initiate a new scan."
welcome += "</div>";
$("#mainbody").append(welcome);
diff --git a/dyn/setup.tmpl b/dyn/setup.tmpl
new file mode 100644
index 00000000..239ce13b
--- /dev/null
+++ b/dyn/setup.tmpl
@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<html lang="en">
+ <script type='text/javascript' src='/static/js/spiderfoot.js'></script>
+ <head>
+ <meta charset="utf-8">
+ <title>SpiderFoot v2.0</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <!-- Le styles -->
+ <link href="/static/css/bootstrap.min.css" rel="stylesheet">
+ <style>
+ body {
+ padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
+ }
+ </style>
+ <link href="/static/css/bootstrap-responsive.css" rel="stylesheet">
+
+ <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+
+ <!-- Le fav and touch icons -->
+ <link rel="shortcut icon" href="/static/ico/favicon.ico">
+ </head>
+
+ <body>
+
+ <div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </a>
+ <a class="brand" href="/">SpiderFoot 2.0: Initial Setup</a>
+ <div class="nav-collapse collapse">
+ <ul class="nav pull-right">
+ <li><a href="#aboutmodal" data-toggle="modal"><i class="icon-info-sign"></i>&nbsp;About</a></li>
+ </ul>
+ </div><!--/.nav-collapse -->
+ </div>
+ </div>
+ </div>
+
+ <div id="aboutmodal" class="modal hide fade">
+ <div class="modal-header">
+ <h3>SpiderFoot 2.0</h3>
+ </div>
+ <div class="modal-body">
+ <p>SpiderFoot is an open source GPL-licensed footprinting tool, designed to be easy to use, fast and extensible.</p>
+ <p>If you have any bugs to report, or requests for enhancements, please contact the support mailing list at <a href=mailto:[email protected]>[email protected]</a>.
+ <br>
+ <p>You are running version <b>2.0.0</b>.</p>
+ </div>
+ <div class="modal-footer">
+ <a href="#" data-dismiss="modal" class="btn">Close</a>
+ </div>
+ </div>
+
+ <!-- Le javascript
+ ================================================== -->
+ <!-- Placed at the end of the document so the pages load faster -->
+ <script src="/static/js/jquery.js"></script>
+ <script src="/static/js/bootstrap.min.js"></script>
+ <div class="container" id="mainbody">
+% if stage == 1:
+ <h3>Welcome to SpiderFoot!</h3>
+ Based on the fact that you have no SpiderFoot database, it would seem that you have just installed SpiderFoot, or have deleted your previous SpiderFoot database.
+ SpiderFoot looks for <b>${config['__database']}</b> in its installed path, <b>${path}</b>.
+ <br><br>
+ <a class='btn btn-danger' href='/create'>Create the SpiderFoot database</a>
+% else:
+<div class="alert alert-success">
+ <h4>Success!</h4>
+The SpiderFoot database has been successfully created. Please now <b>stop and start</b> SpiderFoot to start running scans.
+</div>
+% endif
+
+ </div>
+ </body>
+</html>
+
diff --git a/modules/sfp_spider.py b/modules/sfp_spider.py
index ea087e9d..01e2c27a 100644
--- a/modules/sfp_spider.py
+++ b/modules/sfp_spider.py
@@ -33,7 +33,7 @@ class sfp_spider(SpiderFootPlugin):
'maxlevels': 10, # max number of levels to traverse within a site
'filterfiles': ['png','gif','jpg','jpeg','tiff', 'tif', 'js', 'css',
'pdf','tif','ico','flv', 'mp4', 'mp3', 'avi', 'mpg',
- 'mpeg', 'iso', 'dat', 'mov'], # Extensions to not fetch
+ 'mpeg', 'iso', 'dat', 'mov', 'swf'], # Extensions to not fetch
'filterusers': True, # Don't follow /~user directories
'noexternal': True, # Should links to external sites be ignored? (**dangerous if False**)
'nosubs': False # Should links to subdomains be ignored?
diff --git a/modules/sfp_stor_db.py b/modules/sfp_stor_db.py
index 85e80bee..47f84359 100644
--- a/modules/sfp_stor_db.py
+++ b/modules/sfp_stor_db.py
@@ -26,7 +26,7 @@ class sfp_stor_db(SpiderFootPlugin):
# These must always be set
'__debug': True,
'__debugfilter': '',
- 'maxstorage': 0 # max bytes for any piece of info stored (0 = unlimited)
+ 'maxstorage': 1024 # max bytes for any piece of info stored (0 = unlimited)
}
# URL this instance is working on
@@ -53,6 +53,7 @@ class sfp_stor_db(SpiderFootPlugin):
# Handle events sent to this module
def handleEvent(self, srcModuleName, eventName, eventSource, eventData):
+ print "OPT: " + str(self.opts['maxstorage'])
if self.opts['maxstorage'] != 0 and len(eventData) > self.opts['maxstorage']:
sfdb.scanEventStore(self.opts['__guid__'], eventName, eventSource,
eventData[0:self.opts['maxstorage']], srcModuleName)
diff --git a/sf.py b/sf.py
index ce3884da..e1ee62cb 100755
--- a/sf.py
+++ b/sf.py
@@ -15,7 +15,7 @@ import time
import cherrypy
import os
from sflib import SpiderFoot
-from sfwebui import SpiderFootWebUi
+from sfwebui import SpiderFootWebUi, SpiderFootWebUiMini
# 'Global' configuration options
# These can be overriden on a per-module basis, and some will
@@ -75,4 +75,10 @@ if __name__ == '__main__':
'tools.staticdir.dir': os.path.join(currentDir, 'static')
}}
- cherrypy.quickstart(SpiderFootWebUi(sfConfig), config=conf)
+ # Try starting the web server. If it fails due to a database being
+ # missing, start a smaller web server just for setting up the DB.
+ try:
+ cherrypy.quickstart(SpiderFootWebUi(sfConfig), config=conf)
+ except BaseException as e:
+ cherrypy.quickstart(SpiderFootWebUiMini(sfConfig), config=conf)
+
diff --git a/sfdb.py b/sfdb.py
index 56f1bf8b..fe316d0e 100644
--- a/sfdb.py
+++ b/sfdb.py
@@ -28,7 +28,7 @@ class SpiderFootDb:
# read and write to such a file.
dbh = sqlite3.connect(opts['__database'], timeout=10)
if dbh == None:
- sf.fatal("Could not connect to internal database. Check that " + \
+ sf.error("Could not connect to internal database. Check that " + \
opts['__database'] + " exists and is readable and writable.")
dbh.text_factory = str
@@ -42,7 +42,7 @@ class SpiderFootDb:
try:
self.dbh.execute('SELECT COUNT(*) FROM tbl_scan_config')
except sqlite3.Error:
- sf.fatal("Found spiderfoot.db but it doesn't appear to be in " \
+ sf.error("Found spiderfoot.db but it doesn't appear to be in " \
"the expected state - ensure the schema is created.")
return
@@ -110,7 +110,8 @@ class SpiderFootDb:
# Return info about a scan instance (name, target, created, started,
# ended, status) - don't need this yet - untested
def scanInstanceGet(self, instanceId):
- qry = "SELECT name, seed_target, created, started, ended, status \
+ qry = "SELECT name, seed_target, ROUND(created/1000) AS created, \
+ ROUND(started/1000) AS started, ROUND(ended/1000) AS ended, status \
FROM tbl_scan_instance WHERE guid = ?"
qvars = [instanceId]
try:
@@ -136,7 +137,7 @@ class SpiderFootDb:
# Obtain the data for a scan and event type
def scanResultEvent(self, instanceId, eventType):
- qry = "SELECT ROUND(generated/1000) as generated, event_data, event_source, \
+ qry = "SELECT ROUND(generated/1000) AS generated, event_data, event_source, \
event_data_source FROM tbl_scan_results WHERE scan_instance_id = ? AND \
event = ?"
qvars = [instanceId, eventType]
@@ -231,8 +232,7 @@ class SpiderFootDb:
self.conn.commit()
# Retreive configuration data for a scan component
- # don't need this yet
- def scanConfigGet(self, instanceId, component):
+ def scanConfigGet(self, instanceId):
qry = "SELECT component, opt, val FROM tbl_scan_config \
WHERE scan_instance_id = ?"
qvars = [instanceId]
diff --git a/sfdbsetup.py b/sfdbsetup.py
new file mode 100644
index 00000000..4d195471
--- /dev/null
+++ b/sfdbsetup.py
@@ -0,0 +1,94 @@
+#-------------------------------------------------------------------------------
+# Name: sfdbsetup
+# Purpose: Create a new SpiderFoot database.
+#
+# Author: Steve Micallef <[email protected]>
+#
+# Created: 15/02/2013
+# Copyright: (c) Steve Micallef 2013
+# Licence: GPL
+#-------------------------------------------------------------------------------
+
+import sqlite3
+import sys
+
+class SpiderFootDbInit:
+ def __init__(self, opts):
+
+ # connect() will create the database file if it doesn't exist, but
+ # at least we can use this opportunity to ensure we have permissions to
+ # read and write to such a file.
+ dbh = sqlite3.connect(opts['__database'], timeout=10)
+ if dbh == None:
+ sf.error("Could not initialize internal database. Check that " + \
+ opts['__database'] + " is readable and writable.")
+ dbh.text_factory = str
+ self.conn = dbh
+ self.dbh = dbh.cursor()
+ return
+
+ # Close the database handle
+ def close(self):
+ self.dbh.close()
+
+ def create(self):
+ queries = [
+ "CREATE TABLE tbl_event_types ( \
+ event VARCHAR NOT NULL PRIMARY KEY, \
+ event_descr VARCHAR NOT NULL \
+ )",
+ "CREATE TABLE tbl_config ( \
+ scope VARCHAR NOT NULL, \
+ opt VARCHAR NOT NULL, \
+ val VARCHAR NOT NULL, \
+ PRIMARY KEY (scope, opt) \
+ )",
+ "CREATE TABLE tbl_scan_instance ( \
+ guid VARCHAR NOT NULL PRIMARY KEY, \
+ name VARCHAR NOT NULL, \
+ seed_target VARCHAR NOT NULL, \
+ created INT DEFAULT 0, \
+ started INT DEFAULT 0, \
+ ended INT DEFAULT 0, \
+ status VARCHAR NOT NULL \
+ )",
+ "CREATE TABLE tbl_scan_config ( \
+ scan_instance_id VARCHAR NOT NULL REFERENCES tbl_scan_instance(guid), \
+ component VARCHAR NOT NULL, \
+ opt VARCHAR NOT NULL, \
+ val VARCHAR NOT NULL \
+ )",
+ "CREATE TABLE tbl_scan_results ( \
+ scan_instance_id VARCHAR NOT NULL REFERENCES tbl_scan_instance(guid), \
+ generated INT NOT NULL, \
+ event VARCHAR NOT NULL REFERENCES tbl_event_types(event), \
+ event_source VARCHAR NOT NULL, \
+ event_data VARCHAR NOT NULL, \
+ event_data_source VARCHAR NOT NULL \
+ )",
+ "CREATE INDEX idx_scan_results_event ON tbl_scan_results (scan_instance_id, event)",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('AFFILIATE', 'Affiliate')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('EMAILADDR', 'Email Address')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('IP_ADDRESS', 'IP Address')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('SUBDOMAIN', 'Sub-domain')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('SIMILARDOMAIN', 'Similar Domain')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('URL', 'URL')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('WEBCONTENT', 'Web Content')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('WEBCONTENT_FORM', 'Web Content (Form)')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('WEBCONTENT_HASFLASH', 'Web Content (Uses Flash)')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('WEBCONTENT_JAVASCRIPT', 'Web Content (Uses Javascript)')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('WEBCONTENT_STATIC', 'Web Content (Purely Static)')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('WEBCONTENT_PASSWORD', 'Web Content (Accepts Passwords)')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('WEBCONTENT_UPLOAD', 'Web Content (Accepts Uploads)')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('WEBSERVER_BANNER', 'Web Server')",
+ "INSERT INTO tbl_event_types (event, event_descr) VALUES ('WEBSERVER_HTTPHEADERS', 'HTTP Headers')"
+ ]
+
+ try:
+ for qry in queries:
+ self.dbh.execute(qry)
+ self.conn.commit()
+ except sqlite3.Error as e:
+ raise BaseException("SQL error encountered when setting up database: " +
+ e.args[0])
+
diff --git a/sflib.py b/sflib.py
index 949ffbc6..17b32422 100644
--- a/sflib.py
+++ b/sflib.py
@@ -35,7 +35,7 @@ class SpiderFoot:
def error(self, error):
if self.handle == None:
print '[Error] ' + error
- raise Exception(error)
+ raise BaseException(error)
else:
#self.handle.error(error)
print 'should not be here'
@@ -44,7 +44,7 @@ class SpiderFoot:
def fatal(self, error):
if self.handle == None:
print '[Fatal] ' + error
- raise BaseException("Fatal Error Encountered.")
+ raise BaseException("Fatal Error Encountered: " + error)
exit(-1)
else:
#self.handle.error(error)
diff --git a/sfwebui.py b/sfwebui.py
index bd413640..b997380c 100644
--- a/sfwebui.py
+++ b/sfwebui.py
@@ -12,12 +12,14 @@ import json
import threading
import cherrypy
import cgi
+import os
import time
import urllib2
from copy import deepcopy
from mako.lookup import TemplateLookup
from mako.template import Template
from sfdb import SpiderFootDb
+from sfdbsetup import SpiderFootDbInit
from sflib import SpiderFoot
# Data providers called by front-end javascript
@@ -36,14 +38,14 @@ class SpiderFootDataProvider:
data = dbh.scanInstanceList()
retdata = []
for row in data:
- created = time.strftime("%d/%m/%Y", time.localtime(row[3]))
+ created = time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(row[3]))
if row[4] != 0:
- started = time.strftime("%d/%m/%Y", time.localtime(row[4]))
+ started = time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(row[4]))
else:
started = "Not yet"
if row[5] != 0:
- finished = time.strftime("%d/%m/%Y", time.localtime(row[5]))
+ finished = time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(row[5]))
else:
finished = "Not yet"
retdata.append([row[0], row[1], row[2], created, started, finished, row[6], row[7]])
@@ -82,6 +84,7 @@ class SpiderFootDataProvider:
# Save the config current set for this scan
sf = SpiderFoot(sfConfig)
+ sfConfig['_modulesenabled'] = moduleList
dbh.scanConfigSet(sfConfig['__guid__'], sf.configSerialize(sfConfig))
print "Scan [" + sfConfig['__guid__'] + "] initiated."
@@ -153,6 +156,7 @@ class SpiderFootWebUi:
dp = None
lookup = TemplateLookup(directories=[''])
defaultConfig = dict()
+ config = dict()
def __init__(self, config):
self.defaultConfig = deepcopy(config)
@@ -165,6 +169,29 @@ class SpiderFootWebUi:
sf = SpiderFoot(config)
self.config = sf.configUnserialize(dbh.configGet(), config)
+ # DATA PROVIDERS (need to migrate all the ones from SpiderFootDataProvider
+ # to here)
+
+ # Configuration used for a scan
+ def scanopts(self, id):
+ ret = dict()
+ dbh = SpiderFootDb(self.config)
+ ret['config'] = dbh.scanConfigGet(id)
+ sf = SpiderFoot(self.config)
+ meta = dbh.scanInstanceGet(id)
+ if meta[3] != 0:
+ started = time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(meta[3]))
+ else:
+ started = "Not yet"
+
+ if meta[4] != 0:
+ finished = time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(meta[4]))
+ else:
+ finished = "Not yet"
+ ret['meta'] = [meta[0], meta[1], meta[2], started, finished, meta[5]]
+ return json.dumps(ret)
+ scanopts.exposed = True
+
#
# USER INTERFACE PAGES
#
@@ -182,6 +209,12 @@ class SpiderFootWebUi:
return templ.render(pageid='SCANLIST')
index.exposed = True
+ # Include this in case the user is clicking reload after creating
+ # the DB and restarting.
+ def create(self):
+ return self.index()
+ create.exposed = True
+
# Information about a selected scan
def scaninfo(self, id):
dbh = SpiderFootDb(self.config)
@@ -199,6 +232,7 @@ class SpiderFootWebUi:
return templ.render(opts=self.config, pageid='SETTINGS')
opts.exposed = True
+ # Generic error, but not exposed as not called directly
def error(self, message):
templ = Template(filename='dyn/error.tmpl', lookup=self.lookup)
return templ.render(message=message)
@@ -299,3 +333,31 @@ class SpiderFootWebUi:
return templ.render(pageid='SCANLIST',stoppedscan=True)
stopscan.exposed = True
+
+# Special class used when SpiderFoot is started without a
+# database pre-existing. This will step the user through
+# the creation of one.
+class SpiderFootWebUiMini:
+ lookup = TemplateLookup(directories=[''])
+
+ def __init__(self, config):
+ self.config = config
+
+ # Main page listing scans available
+ def index(self):
+ # Look for referenced templates in the current directory only
+ templ = Template(filename='dyn/setup.tmpl', lookup=self.lookup)
+ return templ.render(stage=1, config=self.config, path=os.path.dirname(__file__))
+ index.exposed = True
+
+ # Create the database
+ def create(self):
+ try:
+ dbh = SpiderFootDbInit(self.config)
+ dbh.create()
+ templ = Template(filename='dyn/setup.tmpl', lookup=self.lookup)
+ return templ.render(stage=2)
+ except BaseException as e:
+ return "There was an error creating the database or it already exists.<br><br>Please check database permissions and try restarting SpiderFoot. If all else fails, report this as a bug."
+ create.exposed = True
+