diff --git a/lib/msf/core/exploit/powershell.rb b/lib/msf/core/exploit/powershell.rb index 7ac22050a3..1a4a3b66f1 100644 --- a/lib/msf/core/exploit/powershell.rb +++ b/lib/msf/core/exploit/powershell.rb @@ -61,6 +61,20 @@ module Exploit::Powershell return new_subs end + # + # Return an encoded powershell script + # Will invoke PSH modifiers as enabled + # + def encode_script(script_in, eof = nil) + # Build script object + psh = PshScript.new(script_in) + # Invoke enabled modifiers + datastore.select {|k,v| k =~ /^PSH::(strip|sub)/ and v == 'true' }.keys.map do |k| + mod_method = k.split('::').last.intern + psh.send(mod_method) + end + return psh.encode_code(eof) + end # # Return a gzip compressed powershell script # Will invoke PSH modifiers as enabled @@ -80,7 +94,7 @@ module Exploit::Powershell # Runs powershell in hidden window raising interactive proc msg # def run_hidden_psh(ps_code,ps_bin='powershell.exe') - ps_args = "-w hidden -nop -e #{ compress_script(ps_code) }" + ps_args = "-w hidden -nop -e #{ps_code}" ps_wrapper = <