@@ -109,10 +109,19 @@ def gen_xml(self, command):
109109 random .shuffle (idleSettings )
110110 randomized_idleSettings = "\n " .join (idleSettings )
111111
112- 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" ]
113- random_cmd_arg = ["/c" , "/C" , "/Q /c" , "/F:ON /c" , "/T:fg /c" , "/T:fg /Q /C" , "/F:ON /Q /C" ]
112+ random_cmd_path = [
113+ "cmd" ,
114+ "cmd.exe" ,
115+ "C:\\ Windows\\ System32\\ cmd" ,
116+ "C:\\ Windows\\ System32\\ cmd.exe" ,
117+ "C:\\ Windows\\ System32\\ ..\\ System32\\ cmd" ,
118+ "C:\\ Windows\\ System32\\ ..\\ System32\\ cmd.exe" ,
119+ "C:\\ Windows\\ ..\\ Windows\\ System32\\ cmd"
120+ "C:\\ Windows\\ ..\\ Windows\\ System32\\ cmd.exe" ,
121+ ]
114122 cmd_path = random .choice (random_cmd_path )
115- cmd_args = f"{ random .choice (random_cmd_arg )} { command } "
123+ random_cmd_arg = ["/c" , "/C" , "/Q /c" , "/F:ON /c" , "/T:fg /c" , "/T:fg /Q /C" , "/F:ON /Q /C" ]
124+ full_command = f"{ random .choice (random_cmd_arg )} { command } "
116125
117126 xml = f"""<?xml version="1.0" encoding="UTF-16"?>
118127 <Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
@@ -145,10 +154,10 @@ def gen_xml(self, command):
145154 self .__output_filename = os .path .join (file_location , gen_random_string (8 ))
146155 else :
147156 self .__output_filename = os .path .join (file_location , self .output_filename )
148- argument_xml = f" <Arguments>{ cmd_args } > { self .__output_filename } 2>&1</Arguments>"
157+ argument_xml = f" <Arguments>{ full_command } > { self .__output_filename } 2>&1</Arguments>"
149158
150159 elif self .__retOutput is False :
151- argument_xml = f" <Arguments>{ cmd_args } </Arguments>"
160+ argument_xml = f" <Arguments>{ full_command } </Arguments>"
152161
153162 self .logger .debug ("Generated argument XML: " + argument_xml )
154163 xml += argument_xml
@@ -169,6 +178,7 @@ def execute_handler(self, command):
169178
170179 dce .set_credentials (* self .__rpctransport .get_credentials ())
171180 dce .connect ()
181+
172182 xml = self .gen_xml (command )
173183 self .logger .debug (f"Task XML: { xml } " )
174184 self .logger .info (f"Creating task \\ { self .task_name } " )
@@ -197,6 +207,7 @@ def execute_handler(self, command):
197207
198208 self .logger .info (f"Deleting task \\ { self .task_name } " )
199209 tsch .hSchRpcDelete (dce , f"\\ { self .task_name } " )
210+
200211 if self .__retOutput :
201212 smbConnection = self .__rpctransport .get_smb_connection ()
202213 tries = 1
0 commit comments