SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
sfwebui: Add support for CORS
Brendan Coles66fb59321510
diff --git a/requirements.txt b/requirements.txtindex 82c62942..bb947a08 100644--- a/requirements.txt+++ b/requirements.txt@@ -2,6 +2,7 @@ adblockparser>=0.7dnspython>=1.16.0exifread>=2.1.2CherryPy>=18.0+cherrypy-cors>=1.6Mako>=1.0.4beautifulsoup4>=4.4.1lxml>=3.4.4diff --git a/sf.py b/sf.pyindex 1ebae90c..93a67063 100755--- a/sf.py+++ b/sf.py@@ -24,6 +24,7 @@ from copy import deepcopyfrom logging import handlersimport cherrypy+import cherrypy_corsfrom cherrypy.lib import auth_digestfrom sflib import SpiderFoot@@ -451,6 +452,10 @@ def start_web_server(sfWebUiConfig, sfConfig):web_port = sfWebUiConfig.get('port', 5001)web_root = sfWebUiConfig.get('root', '/')+ # Place your whitelisted CORS origins here+ # Example: cors_origins = ['http://example.com']+ cors_origins = []+cherrypy.config.update({'log.screen': False,'server.socket_host': web_host,@@ -516,11 +521,7 @@ def start_web_server(sfWebUiConfig, sfConfig):warn_msg += "********************************************************************\n"log.warning(warn_msg)- if web_host == "0.0.0.0": # nosec- url = f"http://<IP of this host>:{web_port}{web_root}"- else:- url = f"http://{web_host}:{web_port}{web_root}"-+ using_ssl = Falsekey_path = sf.dataPath() + '/spiderfoot.key'crt_path = sf.dataPath() + '/spiderfoot.crt'if os.path.isfile(key_path) and os.path.isfile(crt_path):@@ -536,8 +537,28 @@ def start_web_server(sfWebUiConfig, sfConfig):cherrypy.server.ssl_module = 'builtin'cherrypy.server.ssl_certificate = crt_pathcherrypy.server.ssl_private_key = key_path+ using_ssl = True++ if using_ssl:+ url = "https://"+ cors_origins.append(f"https://{web_host}:{web_port}")+ else:+ url = "http://"+ cors_origins.append(f"http://{web_host}:{web_port}")- url = url.replace("http://", "https://")+ if web_host == "0.0.0.0": # nosec+ url = f"{url}<IP of this host>"+ else:+ url = f"{url}{web_host}"++ url = f"{url}:{web_port}{web_root}"++ cherrypy_cors.install()+ cherrypy.config.update({+ 'cors.expose.on': True,+ 'cors.expose.origins': cors_origins,+ 'cors.preflight.origins': cors_origins+ })print("")print("*************************************************************")