@@ -238,13 +238,10 @@ def hash_login(self, domain, username, ntlm_hash):
238238 self .logger .fail (f"{ self .domain } \\ { self .username } :{ process_secret (self .nthash )} { e !s} " )
239239 return False
240240
241- def execute (self , payload = None , get_output = True , shell_type = "cmd" ):
241+ def execute (self , payload = None , get_output = False , shell_type = "cmd" ):
242242 if not payload :
243243 payload = self .args .execute
244244
245- if self .args .no_output :
246- get_output = False
247-
248245 try :
249246 result = self .conn .execute_cmd (payload , encoding = self .args .codec ) if shell_type == "cmd" else self .conn .execute_ps (payload )
250247 except Exception as e :
@@ -260,13 +257,16 @@ def execute(self, payload=None, get_output=True, shell_type="cmd"):
260257 else :
261258 self .logger .fail (f"Execute command failed, error: { e !s} " )
262259 else :
260+ if get_output :
261+ return result [0 ]
263262 self .logger .success (f"Executed command (shell type: { shell_type } )" )
264- buf = StringIO ( result [ 0 ]). readlines () if get_output else ""
265- for line in buf :
266- self .logger .highlight (line .strip ())
263+ if not self . args . no_output :
264+ for line in StringIO ( result [ 0 ]). readlines () :
265+ self .logger .highlight (line .strip ())
267266
268- def ps_execute (self ):
269- self .execute (payload = self .args .ps_execute , get_output = True , shell_type = "powershell" )
267+ def ps_execute (self , payload = None , get_output = False ):
268+ command = payload if payload else self .args .ps_execute
269+ self .execute (payload = command , get_output = get_output , shell_type = "powershell" )
270270
271271 # Dos attack prevent:
272272 # if someboby executed "reg save HKLM\sam C:\windows\temp\sam" before, but didn't remove "C:\windows\temp\sam" file,
0 commit comments