Skip to content

Commit a073c2d

Browse files
authored
Merge pull request Pennyw0rth#1182 from azoxlpf/fix/mssql-attribute-error
fix: avoid AttributeError when MSSQL command output is None
2 parents 600abd6 + 1b4900d commit a073c2d

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

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)