SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
sfwebui: Add CSP header
Brendan Coles4c8a49d913aa
diff --git a/dyn/HEADER.tmpl b/dyn/HEADER.tmplindex 5b1798a2..1067ef44 100644--- a/dyn/HEADER.tmpl+++ b/dyn/HEADER.tmpl@@ -1,7 +1,5 @@<!DOCTYPE html><html lang="en">- <script type='text/javascript' src='${docroot}/static/js/spiderfoot.js'></script>- <script type='text/javascript' src='${docroot}/static/js/viz.js'></script><head><meta charset="utf-8"><title>SpiderFoot v3.1-DEV</title>@@ -10,27 +8,11 @@<meta name="author" content=""><link rel="icon" type="image/png" href="${docroot}/static/img/spiderfoot-icon.png">- <!-- Le styles -->+ <script type='text/javascript' src='${docroot}/static/js/spiderfoot.js'></script>+ <script type='text/javascript' src='${docroot}/static/js/viz.js'></script>+<link href="${docroot}/static/css/bootstrap.min.css" rel="stylesheet"><link href="${docroot}/static/css/spiderfoot.css" rel="stylesheet">- <style>- body {- padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */- }- .navbar-brand {- image-rendering: -o-crisp-edges; /* Opera */- image-rendering: -webkit-optimize-contrast;/* Webkit (non-standard naming) */- image-rendering: crisp-edges;- -ms-interpolation-mode: nearest-neighbor; /* IE (non-standard property) */- }- .brand-logo {- display: block;- float: left;- padding-top: 5px;- padding-right: 20px;- }-- </style><link href="${docroot}/static/css/bootstrap-responsive.css" rel="stylesheet"></head>@@ -92,16 +74,12 @@</div></div>- <!-- Le javascript- ================================================== --><!-- Placed at the end of the document so the pages load faster --><script src="${docroot}/static/js/jquery.min.js"></script><script src="${docroot}/static/js/bootstrap.min.js"></script><script src="${docroot}/static/js/jquery.tablesorter.min.js"></script><script src="${docroot}/static/js/d3.min.js"></script>- <script type='text/javascript'>- sf.updateTooltips();- </script>+ <script type='text/javascript'>sf.updateTooltips();</script><div class="container" id="mainbody">diff --git a/dyn/newscan.tmpl b/dyn/newscan.tmplindex 12fbb459..f04b2e26 100644--- a/dyn/newscan.tmpl+++ b/dyn/newscan.tmpl@@ -1,46 +1,5 @@<%include file="HEADER.tmpl"/>-<script type='text/javascript'>- tabs = [ "use", "type", "module" ];- activeTab = "use";-- function submitForm() {- list = "";- $("[id^="+activeTab+"_]").each(function() {- if ($(this).is(":checked")) {- list += $(this).attr('id') + ",";- }- });-- $("#"+activeTab+"list").val(list);- for (i = 0; i < tabs.length; tabs++) {- if (tabs[i] != activeTab) {- $("#"+tabs[i]+"list").val("");- }- }- }-- function switchTab(tabname) {- $("#"+activeTab+"table").hide();- $("#"+activeTab+"tab").removeClass("active");- $("#"+tabname+"table").show();- $("#"+tabname+"tab").addClass("active");- activeTab = tabname;- if (activeTab == "use") {- $("#selectors").hide();- } else {- $("#selectors").show();- }- }-- function selectAll() {- $("[id^="+activeTab+"_]").prop("checked", true);- }-- function deselectAll() {- $("[id^="+activeTab+"_]").prop("checked", false);- }--</script>+<script src="${docroot}/static/js/spiderfoot.newscan.js"></script><h2>New Scan</h2><form class="form" action='${docroot}/startscan' method='POST'><div class="control-group">@@ -123,18 +82,4 @@</div></div></form>-<script type='text/javascript'>-$('#scantarget').popover({ 'html': true, 'animation': true, 'trigger': 'focus'});-if ("${selectedmods}" != "") {- switchTab("module");-- $("input[id^=module_]").each(function(id, obj) {- if ("${selectedmods}".indexOf(obj.id.replace("module_", "")) >= 0) {- $("#" + obj.id).attr("checked", true);- } else {- $("#" + obj.id).attr("checked", false);- }- });-}-</script><%include file="FOOTER.tmpl"/>diff --git a/dyn/opts.tmpl b/dyn/opts.tmplindex c8bc2f2d..c3582939 100644--- a/dyn/opts.tmpl+++ b/dyn/opts.tmpl@@ -1,37 +1,5 @@<%include file="HEADER.tmpl"/>-<script type='text/javascript'>- activeTab = "global";- function saveSettings() {- var retarr = {}- $(":input").each(function(i) {- retarr[$(this).attr('id')] = $(this).val();- });-- $("#allopts").val(JSON.stringify(retarr));- }-- function clearSettings() {- $("#allopts").val("RESET");- }-- function switchTab(tab) {- $("#optsect_"+activeTab).hide();- $("#optsect_"+tab).show();- $("#tab_"+activeTab).removeClass("active");- $("#tab_"+tab).addClass("active");- activeTab = tab;- }-- function getFile(elemId) {- var elem = document.getElementById(elemId);- if(elem && document.createEvent) {- var evt = document.createEvent("MouseEvents");- evt.initEvent("click", true, false);- elem.dispatchEvent(evt);- }- }--</script>+ <script type='text/javascript' src='${docroot}/static/js/spiderfoot.opts.js'></script><h2>Settings</h2>% if updated:<div class="alert alert-success">diff --git a/sfwebui.py b/sfwebui.pyindex a47f30d9..b9d14640 100644--- a/sfwebui.py+++ b/sfwebui.py@@ -61,7 +61,7 @@ class SpiderFootWebUi:'request.error_response': self.error_page})- secure_headers = SecureHeaders()+ secure_headers = SecureHeaders(csp="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'")cherrypy.config.update({"tools.response_headers.on": True,diff --git a/static/css/spiderfoot.css b/static/css/spiderfoot.cssindex fef2584a..61d4f19f 100644--- a/static/css/spiderfoot.css+++ b/static/css/spiderfoot.css@@ -1,3 +1,21 @@+body {+ padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */+}++.navbar-brand {+ image-rendering: -o-crisp-edges; /* Opera */+ image-rendering: -webkit-optimize-contrast;/* Webkit (non-standard naming) */+ image-rendering: crisp-edges;+ -ms-interpolation-mode: nearest-neighbor; /* IE (non-standard property) */+}++.brand-logo {+ display: block;+ float: left;+ padding-top: 5px;+ padding-right: 20px;+}+table.tablesorter thead tr .header {cursor: pointer;background-image: url(../img/sortbg.gif);diff --git a/static/js/spiderfoot.newscan.js b/static/js/spiderfoot.newscan.jsnew file mode 100644index 00000000..cd2c1947--- /dev/null+++ b/static/js/spiderfoot.newscan.js@@ -0,0 +1,53 @@+ tabs = [ "use", "type", "module" ];+ activeTab = "use";++ function submitForm() {+ list = "";+ $("[id^="+activeTab+"_]").each(function() {+ if ($(this).is(":checked")) {+ list += $(this).attr('id') + ",";+ }+ });++ $("#"+activeTab+"list").val(list);+ for (i = 0; i < tabs.length; tabs++) {+ if (tabs[i] != activeTab) {+ $("#"+tabs[i]+"list").val("");+ }+ }+ }++ function switchTab(tabname) {+ $("#"+activeTab+"table").hide();+ $("#"+activeTab+"tab").removeClass("active");+ $("#"+tabname+"table").show();+ $("#"+tabname+"tab").addClass("active");+ activeTab = tabname;+ if (activeTab == "use") {+ $("#selectors").hide();+ } else {+ $("#selectors").show();+ }+ }++ function selectAll() {+ $("[id^="+activeTab+"_]").prop("checked", true);+ }++ function deselectAll() {+ $("[id^="+activeTab+"_]").prop("checked", false);+ }++ $('#scantarget').popover({ 'html': true, 'animation': true, 'trigger': 'focus'});+ if ("${selectedmods}" != "") {+ switchTab("module");++ $("input[id^=module_]").each(function(id, obj) {+ if ("${selectedmods}".indexOf(obj.id.replace("module_", "")) >= 0) {+ $("#" + obj.id).attr("checked", true);+ } else {+ $("#" + obj.id).attr("checked", false);+ }+ });+ }+diff --git a/static/js/spiderfoot.opts.js b/static/js/spiderfoot.opts.jsnew file mode 100644index 00000000..be349987--- /dev/null+++ b/static/js/spiderfoot.opts.js@@ -0,0 +1,30 @@+activeTab = "global";+function saveSettings() {+ var retarr = {}+ $(":input").each(function(i) {+ retarr[$(this).attr('id')] = $(this).val();+ });++ $("#allopts").val(JSON.stringify(retarr));+}++function clearSettings() {+ $("#allopts").val("RESET");+}++function switchTab(tab) {+ $("#optsect_"+activeTab).hide();+ $("#optsect_"+tab).show();+ $("#tab_"+activeTab).removeClass("active");+ $("#tab_"+tab).addClass("active");+ activeTab = tab;+}++function getFile(elemId) {+ var elem = document.getElementById(elemId);+ if(elem && document.createEvent) {+ var evt = document.createEvent("MouseEvents");+ evt.initEvent("click", true, false);+ elem.dispatchEvent(evt);+ }+}