Skip to content

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

Authentication and SSL support.

Steve079b0578d708
diff --git a/THANKYOU b/THANKYOU
index 207a63d3..b9a8c413 100644
--- a/THANKYOU
+++ b/THANKYOU
@@ -33,3 +33,6 @@ bug fixes or new functionality. Thank you!
- Michael Pellon (https://github.com/mpellon)
- Providing a Dockerfile
+
+- HackershubNL (https://github.com/HackershubNL)
+ - Contributions towards authentication functionality
diff --git a/sf.py b/sf.py
index 85dfbaac..654efac4 100755
--- a/sf.py
+++ b/sf.py
@@ -47,7 +47,10 @@ for mod in deps:
sys.exit(-1)
import os
+import os.path
import cherrypy
+import random
+from cherrypy.lib import auth_digest
from sflib import SpiderFoot
from sfwebui import SpiderFootWebUi
@@ -152,6 +155,31 @@ if __name__ == '__main__':
'tools.staticdir.dir': os.path.join(currentDir, 'static')
}}
+ if os.path.isfile(sf.myPath() + '/passwd'):
+ secrets = dict()
+ pw = file(sf.myPath() + '/passwd', 'r')
+ for line in pw.readlines():
+ u, p = line.strip().split(":")
+ if None in [u, p]:
+ print "Incorrect format of passwd file, must be username:password on each line."
+ sys.exit(-1)
+ secrets[u] = p
+
+ print "Enabling authentication based on supplied passwd file."
+ conf['/'] = {
+ 'tools.auth_digest.on': True,
+ 'tools.auth_digest.realm': sfConfig['__webaddr'],
+ 'tools.auth_digest.get_ha1': auth_digest.get_ha1_dict_plain(secrets),
+ 'tools.auth_digest.key': random.randint(0, 99999999)
+ }
+
+ if os.path.isfile(sf.myPath() + '/spiderfoot.key') and \
+ os.path.isfile(sf.myPath() + '/spiderfoot.crt'):
+ print "Enabling SSL based on supplied key and certificate file."
+ cherrypy.server.ssl_module = 'builtin'
+ cherrypy.server.ssl_certificate = sf.myPath() + '/spiderfoot.crt'
+ cherrypy.server.ssl_private_key = sf.myPath() + '/spiderfoot.key'
+
# 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.
cherrypy.quickstart(SpiderFootWebUi(sfConfig), script_name=sfConfig['__docroot'], config=conf)