0 | 0 |
--- a/empire
|
1 | 1 |
+++ b/empire
|
2 | |
@@ -9,6 +9,23 @@ import hashlib
|
|
2 |
@@ -9,6 +9,22 @@ import hashlib
|
3 | 3 |
from OpenSSL import SSL
|
4 | 4 |
import ssl
|
5 | 5 |
import ast
|
|
8 | 8 |
+# database old path
|
9 | 9 |
+DB_OLD_PATH = "/usr/share/powershell-empire/data"
|
10 | 10 |
+# database new path
|
11 | |
+DB_PATH = os.path.expanduser("~/.powershell-empire")
|
|
11 |
+DB_PATH = os.path.expanduser("~/.local/powershell-empire")
|
12 | 12 |
+# Handle database creation / switch before import lib.common
|
13 | 13 |
+if not os.path.isfile(os.path.join(DB_PATH, "empire.db")):
|
14 | |
+ if not os.path.exists(DB_PATH):
|
15 | |
+ os.mkdir(DB_PATH)
|
|
14 |
+ os.makedirs(DB_PATH, exist_ok=True)
|
16 | 15 |
+ if os.path.exists(os.path.join(DB_OLD_PATH, "empire.db")):
|
17 | 16 |
+ if os.getuid() == 0:
|
18 | 17 |
+ shutil.move((os.path.join(DB_OLD_PATH, "empire.db")), os.path.join(DB_PATH, "empire.db"))
|
|
23 | 22 |
|
24 | 23 |
# Empire imports
|
25 | 24 |
from lib.common import empire, helpers
|
26 | |
@@ -45,7 +62,7 @@ def database_connect():
|
|
25 |
@@ -45,7 +61,7 @@ def database_connect():
|
27 | 26 |
"""
|
28 | 27 |
try:
|
29 | 28 |
# set the database connectiont to autocommit w/ isolation level
|
|
47 | 46 |
try:
|
48 | 47 |
# set the database connectiont to autocommit w/ isolation level
|
49 | 48 |
- conn = sqlite3.connect('./data/empire.db', check_same_thread=False)
|
50 | |
+ conn = sqlite3.connect(os.path.expanduser('~/.powershell-empire/empire.db'),
|
|
49 |
+ conn = sqlite3.connect(os.path.expanduser('~/.local/powershell-empire/empire.db'),
|
51 | 50 |
+ check_same_thread=False)
|
52 | 51 |
conn.text_factory = str
|
53 | 52 |
conn.isolation_level = None
|
|
59 | 58 |
try:
|
60 | 59 |
# set the database connectiont to autocommit w/ isolation level
|
61 | 60 |
- self.conn = sqlite3.connect('./data/empire.db', check_same_thread=False)
|
62 | |
+ self.conn = sqlite3.connect(os.path.expanduser('~/.powershell-empire/empire.db'),
|
|
61 |
+ self.conn = sqlite3.connect(os.path.expanduser('~/.local/powershell-empire/empire.db'),
|
63 | 62 |
+ check_same_thread=False)
|
64 | 63 |
self.conn.text_factory = str
|
65 | 64 |
self.conn.isolation_level = None
|
|
71 | 70 |
"""
|
72 | 71 |
|
73 | 72 |
- conn = sqlite3.connect('./data/empire.db', check_same_thread=False)
|
74 | |
+ conn = sqlite3.connect(os.path.expanduser('~/.powershell-empire/empire.db'), check_same_thread=False)
|
|
73 |
+ conn = sqlite3.connect(os.path.expanduser('~/.local/powershell-empire/empire.db'), check_same_thread=False)
|
75 | 74 |
conn.isolation_level = None
|
76 | 75 |
|
77 | 76 |
cur = conn.cursor()
|
|
80 | 79 |
"""
|
81 | 80 |
try:
|
82 | 81 |
- conn = sqlite3.connect('./data/empire.db', check_same_thread=False)
|
83 | |
+ conn = sqlite3.connect(os.path.expanduser('~/.powershell-empire/empire.db'), check_same_thread=False)
|
|
82 |
+ conn = sqlite3.connect(os.path.expanduser('~/.local/powershell-empire/empire.db'), check_same_thread=False)
|
84 | 83 |
conn.isolation_level = None
|
85 | 84 |
conn.row_factory = dict_factory
|
86 | 85 |
cur = conn.cursor()
|
|
91 | 90 |
###################################################
|
92 | 91 |
|
93 | 92 |
-conn = sqlite3.connect('%s/data/empire.db'%INSTALL_PATH)
|
94 | |
+conn = sqlite3.connect(os.path.expanduser('~/.powershell-empire/empire.db'))
|
|
93 |
+conn = sqlite3.connect(os.path.expanduser('~/.local/powershell-empire/empire.db'))
|
95 | 94 |
|
96 | 95 |
c = conn.cursor()
|
97 | 96 |
|