Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix reporting log when there's nulls by using a safe string cast #197

Merged
merged 1 commit into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
data/empire.db
data/empire-chain.pem
data/empire-priv.key
data/credentials.csv
data/master.log
data/sessions.csv
data/obfuscated_module_source/*.ps1
data/misc/ToObfuscate.ps1
data/misc/Obfuscated.ps1
empire.debug
*.pyc
downloads/*
.vscode/*
.idea/*
*.txt
LastTask*
data/obfuscated_module_source/*.ps1
data/misc/ToObfuscate.ps1
data/misc/Obfuscated.ps1
setup/xar*/
setup/bomutils/
.venv
.DS_Store
venv/
addons/
.gitignore
11 changes: 8 additions & 3 deletions lib/common/empire.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
from zlib_wrapper import compress
from zlib_wrapper import decompress

def xstr(s):
"""Safely cast to a string with a handler for None"""
if s is None:
return ''
return str(s)

# custom exceptions used for nested menu navigation
class NavMain(Exception):
"""
Expand Down Expand Up @@ -138,7 +144,6 @@ def get_db_connection(self):
self.lock.release()
return self.conn


def handle_event(self, signal, sender):
"""
Whenver an event is received from the dispatcher, log it to the DB,
Expand Down Expand Up @@ -1002,12 +1007,12 @@ def do_report(self, line):
for n in range(len(row)):
if isinstance(row[n], bytes):
row[n] = row[n].decode('UTF-8')
f.write('\n' + row[0] + ' - ' + row[3] + ' (' + row[2] + ')> ' + str(row[5]) + '\n' + str(row[6]) + '\n' + str(row[7]) + '\n')
f.write('\n' + xstr(row[0]) + ' - ' + xstr(row[3]) + ' (' + xstr(row[2]) + ')> ' + xstr(row[5]) + '\n' + xstr(row[6]) + '\n' + xstr(row[7]) + '\n')
f.close()
cur.close()
finally:
self.lock.release()

def complete_usemodule(self, text, line, begidx, endidx, language=None):
"Tab-complete an Empire module path."

Expand Down