From 8e441883500ba17cf11464e17950f55a2f859003 Mon Sep 17 00:00:00 2001 From: Harmj0y Date: Fri, 1 Apr 2016 15:51:58 -0400 Subject: [PATCH] Fix for path errors in some cases for ./setup/setup_database.py --- setup/setup_database.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/setup/setup_database.py b/setup/setup_database.py index 764a291..e300908 100755 --- a/setup/setup_database.py +++ b/setup/setup_database.py @@ -56,17 +56,27 @@ DEFAULT_CERT_PATH = '' DEFAULT_PORT = 8080 # the installation path for Empire, defaults to auto-calculating it -INSTALL_PATH = "/".join(os.getcwd().split("/")[0:-1])+"/" +# set manually if issues arise +currentPath = os.path.dirname(os.path.realpath(__file__)) +empireIndex = currentPath.rfind("Empire") +if empireIndex < 0: + empireIndex = currentPath.rfind("empire") +if empireIndex < 0: + INSTALL_PATH = "/".join(os.getcwd().split("/")[0:-1])+"/" +else: + endIndex = currentPath.find("/", empireIndex) + endIndex = None if endIndex < 0 else endIndex + INSTALL_PATH = currentPath[0:endIndex] + "/" # the version version to appear as SERVER_VERSION = "Microsoft-IIS/7.5" # an IP white list to ONLY accept clients from -# format is 192.168.1.1,192.168.1.10-192.168.1.100,10.0.0.0/8 +# format is "192.168.1.1,192.168.1.10-192.168.1.100,10.0.0.0/8" IP_WHITELIST = "" # an IP black list to reject accept clients from -# format is 192.168.1.1,192.168.1.10-192.168.1.100,10.0.0.0/8 +# format is "192.168.1.1,192.168.1.10-192.168.1.100,10.0.0.0/8" IP_BLACKLIST = "" # number of times an agent will call back without an answer prior to exiting @@ -86,8 +96,8 @@ API_PERMANENT_TOKEN = ''.join(random.choice(string.ascii_lowercase + string.digi # ################################################### - -conn = sqlite3.connect('../data/empire.db') +dbPath = INSTALL_PATH + "data/empire.db" +conn = sqlite3.connect(dbPath) c = conn.cursor()