Codebase list powershell-empire / 8ccbbfd
Refresh debian/patches Sophie Brun 3 years ago
2 changed file(s) with 24 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
11 Date: Fri, 27 Dec 2019 09:25:49 +0100
22 Subject: change-database-location
33
4 Last-Update: 2020-07-21
4 Last-Update: 2020-10-19
55 ---
66 empire | 18 +++++++++++++++++-
77 lib/common/__init__.py | 4 +++-
88 lib/common/agents.py | 21 +++++++++++----------
9 lib/common/empire.py | 7 ++++---
9 lib/common/empire.py | 9 +++++----
1010 lib/common/helpers.py | 6 +++---
1111 setup/reset.sh | 20 ++++++++++----------
1212 setup/setup_database.py | 2 +-
13 7 files changed, 49 insertions(+), 29 deletions(-)
13 7 files changed, 50 insertions(+), 30 deletions(-)
1414
1515 diff --git a/empire b/empire
16 index ab00b63..ef3f678 100755
16 index 8178180..1245e29 100755
1717 --- a/empire
1818 +++ b/empire
19 @@ -21,6 +21,22 @@ from time import sleep
20
19 @@ -22,6 +22,22 @@ from time import sleep
2120 from flask import Flask, request, jsonify, make_response, abort, url_for, g
2221 from flask.json import JSONEncoder
22 from flask_socketio import SocketIO, emit
2323 +import shutil
2424 +
2525 +# database old path
3939
4040 # Empire imports
4141 from lib.common import empire, helpers, users
42 @@ -85,7 +101,7 @@ def database_connect():
42 @@ -87,7 +103,7 @@ def database_connect():
4343 sqlite3.register_adapter(datetime, adapt_datetime)
4444 sqlite3.register_converter("timestamp", convert_timestamp)
4545 # set the database connectiont to autocommit w/ isolation level
7171 conn.isolation_level = None
7272 return conn
7373 diff --git a/lib/common/agents.py b/lib/common/agents.py
74 index 51b24a3..9d495e8 100644
74 index 829eab8..a57baa0 100644
7575 --- a/lib/common/agents.py
7676 +++ b/lib/common/agents.py
77 @@ -87,6 +87,7 @@ class Agents(object):
77 @@ -89,6 +89,7 @@ class Agents(object):
7878 # pull out the controller objects
7979 self.mainMenu = MainMenu
8080 self.installPath = self.mainMenu.installPath
8282 self.args = args
8383
8484 # internal agent dictionary for the client's session key, funcions, and URI sets
85 @@ -254,13 +255,13 @@ class Agents(object):
85 @@ -267,13 +268,13 @@ class Agents(object):
8686 parts = path.split("\\")
8787
8888 # construct the appropriate save path
9898 if not os.path.abspath(save_path + "/" + filename).startswith(safePath):
9999 message = "[!] WARNING: agent {} attempted skywalker exploit!\n[!] attempted overwrite of {} with data {}".format(sessionID, path, data)
100100 signal = json.dumps({
101 @@ -320,7 +321,7 @@ class Agents(object):
101 @@ -333,7 +334,7 @@ class Agents(object):
102102 parts = path.split("/")
103103
104104 # construct the appropriate save path
107107 filename = parts[-1]
108108
109109 # decompress data if coming from a python agent:
110 @@ -341,7 +342,7 @@ class Agents(object):
110 @@ -354,7 +355,7 @@ class Agents(object):
111111 try:
112112 self.lock.acquire()
113113 # fix for 'skywalker' exploit by @zeroSteiner
116116 if not os.path.abspath(save_path + "/" + filename).startswith(safePath):
117117 message = "[!] WARNING: agent {} attempted skywalker exploit!\n[!] attempted overwrite of {} with data {}".format(sessionID, path, data)
118118 signal = json.dumps({
119 @@ -381,7 +382,7 @@ class Agents(object):
119 @@ -394,7 +395,7 @@ class Agents(object):
120120 if isinstance(data, bytes):
121121 data = data.decode('UTF-8')
122122 name = self.get_agent_name_db(sessionID)
125125
126126 try:
127127 self.lock.acquire()
128 @@ -1008,8 +1009,8 @@ class Agents(object):
128 @@ -1021,8 +1022,8 @@ class Agents(object):
129129 try:
130130 self.lock.acquire()
131131 # rename the logging/downloads folder
136136 retVal = True
137137
138138 # check if the folder is already used
139 @@ -1177,7 +1178,7 @@ class Agents(object):
139 @@ -1191,7 +1192,7 @@ class Agents(object):
140140
141141 # write out the last tasked script to "LastTask" if in debug mode
142142 if self.args and self.args.debug:
145145 f.write(task)
146146 f.close()
147147 return pk
148 @@ -2010,8 +2011,8 @@ class Agents(object):
148 @@ -2039,8 +2040,8 @@ class Agents(object):
149149 elif responseName == "TASK_CMD_JOB":
150150 #check if this is the powershell keylogging task, if so, write output to file instead of screen
151151 if keyLogTaskID and keyLogTaskID == taskID:
157157 message = "[!] WARNING: agent {} attempted skywalker exploit!".format(self.sessionID)
158158 signal = json.dumps({
159159 diff --git a/lib/common/empire.py b/lib/common/empire.py
160 index cf7dcf3..156e035 100755
160 index 0355e51..56374a2 100755
161161 --- a/lib/common/empire.py
162162 +++ b/lib/common/empire.py
163 @@ -185,7 +185,7 @@ class MainMenu(cmd.Cmd):
163 @@ -191,7 +191,7 @@ class MainMenu(cmd.Cmd):
164164
165165 # if --debug X is passed, log out all dispatcher signals
166166 if self.args.debug:
169169 debug_file.write("%s %s : %s\n" % (helpers.get_datetime(), sender, signal))
170170
171171 if self.args.debug == '2':
172 @@ -331,11 +331,12 @@ class MainMenu(cmd.Cmd):
173
172 @@ -346,11 +346,12 @@ class MainMenu(cmd.Cmd):
173
174174 def database_connect(self):
175175 """
176176 - Connect to the default database at ./data/empire.db.
177177 + Connect to the default database at ~/.local/powershell-empire/empire.db.
178178 """
179179 try:
180 # set the database connectiont to autocommit w/ isolation level
180 - # set the database connection to autocommit w/ isolation level
181181 - self.conn = sqlite3.connect('./data/empire.db', check_same_thread=False)
182 + # set the database connectiont to autocommit w/ isolation level
182183 + self.conn = sqlite3.connect(os.path.expanduser('~/.local/powershell-empire/empire.db'),
183184 + check_same_thread=False)
184185 self.conn.text_factory = str
185186 self.conn.isolation_level = None
186187 return self.conn
187188 diff --git a/lib/common/helpers.py b/lib/common/helpers.py
188 index c91a842..df7736b 100644
189 index f6bdb21..5d0349e 100644
189190 --- a/lib/common/helpers.py
190191 +++ b/lib/common/helpers.py
191192 @@ -273,7 +273,7 @@ def strip_powershell_comments(data):
515515 -
516516 -exec(agent)
517517 diff --git a/lib/listeners/dbx.py b/lib/listeners/dbx.py
518 index f434516..4851684 100755
518 index fbea59f..04f4517 100755
519519 --- a/lib/listeners/dbx.py
520520 +++ b/lib/listeners/dbx.py
521521 @@ -412,7 +412,7 @@ class Listener(object):