From 33ecbe207abc1007c46acdfbbc6667d62603658a Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Fri, 15 Aug 2025 13:02:49 -0400 Subject: [PATCH] Formatting --- nxc/protocols/smb/atexec.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/nxc/protocols/smb/atexec.py b/nxc/protocols/smb/atexec.py index 502aa8c5..21e25f9d 100755 --- a/nxc/protocols/smb/atexec.py +++ b/nxc/protocols/smb/atexec.py @@ -109,10 +109,19 @@ class TSCH_EXEC: random.shuffle(idleSettings) randomized_idleSettings = "\n".join(idleSettings) - random_cmd_path = ["C:\\Windows\\System32\\cmd", "C:\\Windows\\System32\\cmd.exe", "C:\\Windows\\System32\\cmd.exe", "cmd.exe", "C:\\Windows\\System32\\..\\System32\\cmd.exe", "C:\\Windows\\System32\\..\\System32\\cmd", "C:\\Windows\\..\\Windows\\System32\\cmd.exe", "C:\\Windows\\..\\Windows\\System32\\cmd"] - random_cmd_arg = ["/c", "/C", "/Q /c", "/F:ON /c", "/T:fg /c", "/T:fg /Q /C", "/F:ON /Q /C"] + random_cmd_path = [ + "cmd", + "cmd.exe", + "C:\\Windows\\System32\\cmd", + "C:\\Windows\\System32\\cmd.exe", + "C:\\Windows\\System32\\..\\System32\\cmd", + "C:\\Windows\\System32\\..\\System32\\cmd.exe", + "C:\\Windows\\..\\Windows\\System32\\cmd" + "C:\\Windows\\..\\Windows\\System32\\cmd.exe", + ] cmd_path = random.choice(random_cmd_path) - cmd_args = f"{random.choice(random_cmd_arg)} {command}" + random_cmd_arg = ["/c", "/C", "/Q /c", "/F:ON /c", "/T:fg /c", "/T:fg /Q /C", "/F:ON /Q /C"] + full_command = f"{random.choice(random_cmd_arg)} {command}" xml = f""" @@ -145,10 +154,10 @@ class TSCH_EXEC: self.__output_filename = os.path.join(file_location, gen_random_string(8)) else: self.__output_filename = os.path.join(file_location, self.output_filename) - argument_xml = f" {cmd_args} > {self.__output_filename} 2>&1" + argument_xml = f" {full_command} > {self.__output_filename} 2>&1" elif self.__retOutput is False: - argument_xml = f" {cmd_args}" + argument_xml = f" {full_command}" self.logger.debug("Generated argument XML: " + argument_xml) xml += argument_xml @@ -169,6 +178,7 @@ class TSCH_EXEC: dce.set_credentials(*self.__rpctransport.get_credentials()) dce.connect() + xml = self.gen_xml(command) self.logger.debug(f"Task XML: {xml}") self.logger.info(f"Creating task \\{self.task_name}") @@ -197,6 +207,7 @@ class TSCH_EXEC: self.logger.info(f"Deleting task \\{self.task_name}") tsch.hSchRpcDelete(dce, f"\\{self.task_name}") + if self.__retOutput: smbConnection = self.__rpctransport.get_smb_connection() tries = 1