Skip to content

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

py2exe compatibility..

smicallef329a8afae32d
diff --git a/sf.py b/sf.py
index edd3b2f2..7a1c55bb 100755
--- a/sf.py
+++ b/sf.py
@@ -45,7 +45,7 @@ if __name__ == '__main__':
sfModules = dict()
# Go through each module in the modules directory with a .py extension
- for filename in os.listdir(os.path.dirname(__file__) + '/modules/'):
+ for filename in os.listdir(sf.myPath() + '/modules/'):
if filename.startswith("sfp_") and filename.endswith(".py"):
# Skip the module template and debugging modules
if filename == "sfp_template.py" or filename == 'sfp_stor_print.py':
@@ -81,7 +81,7 @@ if __name__ == '__main__':
})
# Enable access to static files via the web directory
- currentDir = os.path.dirname(os.path.abspath(__file__))
+ currentDir = os.path.abspath(sf.myPath())
conf = { '/static': {
'tools.staticdir.on': True,
'tools.staticdir.dir': os.path.join(currentDir, 'static')
diff --git a/sflib.py b/sflib.py
index b9d02814..e7d7279f 100644
--- a/sflib.py
+++ b/sflib.py
@@ -13,6 +13,7 @@
import inspect
import hashlib
import re
+import os
import sys
import time
import urllib2
@@ -88,6 +89,17 @@ class SpiderFoot:
self._dblog("DEBUG", message, mod.__name__)
return
+ def myPath(self):
+ """ This will get us the program's directory,
+ even if we are frozen using py2exe"""
+
+ # Determine whether we've been compiled by py2exe
+ if hasattr(sys, "frozen"):
+ return os.path.dirname(unicode(sys.executable, sys.getfilesystemencoding( )))
+
+ return os.path.dirname(unicode(__file__, sys.getfilesystemencoding( )))
+
+
#
# Configuration process
#
diff --git a/sfwebui.py b/sfwebui.py
index 9ca57224..c2fcf238 100644
--- a/sfwebui.py
+++ b/sfwebui.py
@@ -303,9 +303,10 @@ class SpiderFootWebUiMini:
# Main page listing scans available
def index(self):
+ sf = SpiderFoot(self.config)
# 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__))
+ return templ.render(stage=1, config=self.config, path=os.path.dirname(sf.myPath()))
index.exposed = True
# Create the database