@@ -312,7 +312,6 @@ def print_host_info(self):
312312 signing = colored (f"signing:{ self .signing } " , host_info_colors [0 ], attrs = ["bold" ]) if self .signing else colored (f"signing:{ self .signing } " , host_info_colors [1 ], attrs = ["bold" ])
313313 smbv1 = colored (f"SMBv1:{ self .smbv1 } " , host_info_colors [2 ], attrs = ["bold" ]) if self .smbv1 else colored (f"SMBv1:{ self .smbv1 } " , host_info_colors [3 ], attrs = ["bold" ])
314314 self .logger .display (f"{ self .server_os } { f' x{ self .os_arch } ' if self .os_arch else '' } (name:{ self .hostname } ) (domain:{ self .targetDomain } ) ({ signing } ) ({ smbv1 } )" )
315- return True
316315
317316 def kerberos_login (self , domain , username , password = "" , ntlm_hash = "" , aesKey = "" , kdcHost = "" , useCache = False ):
318317 self .logger .debug (f"KDC set to: { kdcHost } " )
@@ -619,7 +618,20 @@ def gen_relay_list(self):
619618 relay_list .write (self .host + "\n " )
620619
621620 @requires_admin
622- def execute (self , payload = None , get_output = False , methods = None ):
621+ def execute (self , payload = None , get_output = False , methods = None ) -> str :
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+ str: The output of the command
634+ """
623635 if self .args .exec_method :
624636 methods = [self .args .exec_method ]
625637 if not methods :
@@ -753,7 +765,7 @@ def execute(self, payload=None, get_output=False, methods=None):
753765
754766 if "This script contains malicious content" in output :
755767 self .logger .fail ("Command execution blocked by AMSI" )
756- return None
768+ return ""
757769
758770 if (self .args .execute or self .args .ps_execute ):
759771 self .logger .success (f"Executed command via { current_method } " )
@@ -764,14 +776,29 @@ def execute(self, payload=None, get_output=False, methods=None):
764776 return output
765777 else :
766778 self .logger .fail (f"Execute command failed with { current_method } " )
767- return False
779+ return ""
768780
769781 @requires_admin
770- 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+ """
771798 payload = self .args .ps_execute if not payload and self .args .ps_execute else payload
772799 if not payload :
773800 self .logger .error ("No command to execute specified!" )
774- return None
801+ return []
775802
776803 response = []
777804 obfs = obfs if obfs else self .args .obfs
0 commit comments