diff --git a/lib/rex/powershell/command.rb b/lib/rex/powershell/command.rb index 0e9bffa..1191109 100644 --- a/lib/rex/powershell/command.rb +++ b/lib/rex/powershell/command.rb @@ -208,8 +208,14 @@ def self.generate_psh_args(opts) # detect the execution environment and spawn the appropriate # powershell executable for the payload architecture. # + # ARM64 note: [IntPtr]::Size cannot tell an ARM64 process apart from an x64 + # one, so PROCESSOR_ARCHITECTURE (and PROCESSOR_ARCHITEW6432 for a 32-bit + # process on Windows-on-ARM) is consulted first. A payload_arch of + # 'aarch64' targets the native ARM64 powershell.exe under System32 + # (reached via sysnative when the current process is 32-bit). + # # @param ps_code [String] Powershell code - # @param payload_arch [String] The payload architecture 'x86'/'x86_64' + # @param payload_arch [String] The payload architecture 'x86'/'x86_64'/'aarch64' # @param encoded [Boolean] Indicates whether ps_code is encoded or not # @param opts [Hash] The options for generate_psh_args # @@ -240,20 +246,51 @@ def self.run_hidden_psh(ps_code, payload_arch, encoded, opts={}) EOS process_start_info.gsub!("\n", ';') - archictecure_detection = <