@@ -618,7 +618,20 @@ def gen_relay_list(self):
618618 relay_list .write (self .host + "\n " )
619619
620620 @requires_admin
621- def execute (self , payload = None , get_output = False , methods = None ):
621+ def execute (self , payload = None , get_output = False , methods = None ) -> list :
622+ """
623+ Executes a command on the target host using CMD.exe and the specified method(s).
624+
625+ Args:
626+ ----
627+ payload (str): The command to execute
628+ get_output (bool): Whether to get the output of the command (can be useful for AV evasion)
629+ methods (list): The method(s) to use for command execution
630+
631+ Returns:
632+ -------
633+ list: A list containing the lines of the output of the command
634+ """
622635 if self .args .exec_method :
623636 methods = [self .args .exec_method ]
624637 if not methods :
@@ -752,7 +765,7 @@ def execute(self, payload=None, get_output=False, methods=None):
752765
753766 if "This script contains malicious content" in output :
754767 self .logger .fail ("Command execution blocked by AMSI" )
755- return None
768+ return []
756769
757770 if (self .args .execute or self .args .ps_execute ):
758771 self .logger .success (f"Executed command via { current_method } " )
@@ -763,14 +776,29 @@ def execute(self, payload=None, get_output=False, methods=None):
763776 return output
764777 else :
765778 self .logger .fail (f"Execute command failed with { current_method } " )
766- return False
779+ return []
767780
768781 @requires_admin
769- def ps_execute (self , payload = None , get_output = False , methods = None , force_ps32 = False , obfs = False , encode = False ):
782+ def ps_execute (self , payload = None , get_output = False , methods = None , force_ps32 = False , obfs = False , encode = False ) -> list :
783+ """
784+ Wrapper for executing a PowerShell command on the target host. This still uses the execute() method internally, but
785+ creates a PowerShell command together with possible AMSI bypasses and other options.
786+
787+ Args:
788+ ----
789+ payload (str): The PowerShell command to execute OR the path to a file containing PowerShell commands
790+ get_output (bool): Whether to get the output of the command (can be useful for AV evasion)
791+ methods (list): The method(s) to use for command execution
792+ force_ps32 (bool): Whether to force 32-bit PowerShell
793+
794+ Returns:
795+ -------
796+ list: A list containing the lines of the output of the command
797+ """
770798 payload = self .args .ps_execute if not payload and self .args .ps_execute else payload
771799 if not payload :
772800 self .logger .error ("No command to execute specified!" )
773- return None
801+ return []
774802
775803 response = []
776804 obfs = obfs if obfs else self .args .obfs
0 commit comments