Skip to content

Commit 47b1320

Browse files
RageLtManbusterb
authored andcommitted
Add options to cmd_psh_payload
Fill in validated datastore options for generating custom PSH payloads
1 parent fb8e025 commit 47b1320

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/msf/core/exploit/powershell.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ 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::encode_final_payload', [true, 'Encode final payload for -EncodedCommand', false]),
18+
OptBool.new('Powershell::encode_inner_payload', [true, 'Encode inner payload for -EncodedCommand', false]),
19+
OptBool.new('Powershell::use_single_quotes', [true, 'Wraps the -Command argument in single quotes', false]),
20+
OptBool.new('Powershell::no_equals', [true, 'Pad base64 until no "=" remains', false]),
1721
OptEnum.new('Powershell::method', [true, 'Payload delivery method', 'reflection', %w(net reflection old msil)]),
1822
], self.class)
1923
end
@@ -188,11 +192,12 @@ def run_hidden_psh(ps_code, payload_arch, encoded)
188192
#
189193
# @return [String] Powershell command line with payload
190194
def cmd_psh_payload(pay, payload_arch, opts = {})
191-
options.validate(datastore)
192-
opts[:persist] ||= datastore['Powershell::persist']
193-
opts[:prepend_sleep] ||= datastore['Powershell::prepend_sleep']
194-
opts[:method] ||= datastore['Powershell::method']
195-
opts[:exec_in_place] ||= datastore['Powershell::exec_in_place']
195+
options.validate(datastore)
196+
197+
[ :persist, :prepend_sleep, :exec_in_place, :encode_final_payload,
198+
:encode_inner_payload, :use_single_quotes, :no_equals, :method ].map { |opt|
199+
opts[opt] ||= datastore["Powershell::#{opt}"]
200+
}
196201

197202
unless opts.key? :shorten
198203
opts[:shorten] = (datastore['Powershell::method'] != 'old')

0 commit comments

Comments
 (0)