Skip to content

Commit 1b4900d

Browse files
committed
always return str from MSSQLEXEC.execute
1 parent 19f979c commit 1b4900d

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

nxc/protocols/mssql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def execute(self, payload=None, get_output=False):
323323
self.logger.fail(f"Error during command execution: {self.conn.lastError}")
324324
else:
325325
self.logger.success("Executed command via mssqlexec")
326-
for line in (output or "").splitlines():
326+
for line in output.splitlines():
327327
self.logger.highlight(line.strip())
328328
return output
329329

nxc/protocols/mssql/mssqlexec.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ def __init__(self, connection, logger):
1010
self.backuped_options = {}
1111

1212
def execute(self, command):
13-
result = None
13+
result = ""
1414

1515
self.backup_and_enable("advanced options")
1616
self.backup_and_enable("xp_cmdshell")
1717

1818
try:
1919
cmd = f"exec master..xp_cmdshell '{command}'"
2020
self.logger.debug(f"Attempting to execute query: {cmd}")
21-
result = self.mssql_conn.sql_query(cmd)
22-
self.logger.debug(f"Raw results from query: {result}")
23-
if result:
24-
result = "\n".join(line["output"] for line in result if line["output"] != "NULL")
21+
raw = self.mssql_conn.sql_query(cmd)
22+
self.logger.debug(f"Raw results from query: {raw}")
23+
if raw:
24+
result = "\n".join(line["output"] for line in raw if line["output"] != "NULL")
2525
self.logger.debug(f"Concatenated result together for easier parsing: {result}")
2626
# if you prepend SilentlyContinue it will still output the error, but it will still continue on (so it's not silent...)
2727
if "Preparing modules for first use" in result and "Completed" not in result:

0 commit comments

Comments
 (0)