Skip to content

Commit 1a3fe02

Browse files
author
RageLtMan
committed
Psexec via PSH related fixes
Implement removal of comspec and use of the noninteractive option in powershell payloads. This is the Msf side of #6 for rex-powershell. Testing: In-house testing on 2016 standard edition and win10, 201707 revs.
1 parent 9775df1 commit 1a3fe02

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/msf/core/exploit/powershell.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ def initialize(info = {})
1414
OptBool.new('Powershell::sub_vars', [true, 'Substitute variable names', false]),
1515
OptBool.new('Powershell::sub_funcs', [true, 'Substitute function names', false]),
1616
OptBool.new('Powershell::exec_in_place', [true, 'Produce PSH without executable wrapper', false]),
17+
OptBool.new('Powershell::remove_comspec', [true, 'Produce script calling powershell directly', false]),
18+
OptBool.new('Powershell::noninteractive', [true, 'Execute powershell without interaction', true]),
1719
OptBool.new('Powershell::encode_final_payload', [true, 'Encode final payload for -EncodedCommand', false]),
1820
OptBool.new('Powershell::encode_inner_payload', [true, 'Encode inner payload for -EncodedCommand', false]),
1921
OptBool.new('Powershell::use_single_quotes', [true, 'Wraps the -Command argument in single quotes', false]),
@@ -220,9 +222,8 @@ def run_hidden_psh(ps_code, payload_arch, encoded)
220222
#
221223
# @return [String] Powershell command line with payload
222224
def cmd_psh_payload(pay, payload_arch, opts = {})
223-
options.validate(datastore)
224-
225-
%i[persist prepend_sleep exec_in_place encode_final_payload encode_inner_payload use_single_quotes no_equals method].map do |opt|
225+
%i[persist prepend_sleep exec_in_place encode_final_payload encode_inner_payload
226+
remove_comspec noninteractive use_single_quotes no_equals method].map do |opt|
226227
opts[opt] ||= datastore["Powershell::#{opt}"]
227228
end
228229

0 commit comments

Comments
 (0)