Skip to content

Commit f24bfe7

Browse files
RageLtManbusterb
authored andcommitted
Import Powershell::exec_in_place
Allow passing exec_in_place parameter to cmd_psh_payload in order to execute raw powershell without the commandline wrappers of comspec or calling the powershell binary itself. This is useful in contexts such as the web delivery mechanism or recent powershell sessions as it does not require the creation of a new PSH instance.
1 parent 36b989e commit f24bfe7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/msf/core/exploit/powershell.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def initialize(info = {})
1313
OptBool.new('Powershell::strip_whitespace', [true, 'Strip whitespace', false]),
1414
OptBool.new('Powershell::sub_vars', [true, 'Substitute variable names', false]),
1515
OptBool.new('Powershell::sub_funcs', [true, 'Substitute function names', false]),
16+
OptBool.new('Powershell::exec_in_place', [true, 'Produce PSH without executable wrapper', false]),
1617
OptEnum.new('Powershell::method', [true, 'Payload delivery method', 'reflection', %w(net reflection old msil)]),
1718
], self.class)
1819
end
@@ -190,6 +191,7 @@ def cmd_psh_payload(pay, payload_arch, opts = {})
190191
opts[:persist] ||= datastore['Powershell::persist']
191192
opts[:prepend_sleep] ||= datastore['Powershell::prepend_sleep']
192193
opts[:method] ||= datastore['Powershell::method']
194+
opts[:exec_in_place] ||= datastore['Powershell::exec_in_place']
193195

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

modules/exploits/multi/script/web_delivery.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def on_request_uri(cli, _request)
7171
data = cmd_psh_payload(payload.encoded,
7272
payload_instance.arch.first,
7373
remove_comspec: true,
74-
use_single_quotes: true
74+
exec_in_place: true
7575
)
7676
else
7777
data = %Q(#{payload.encoded} )

0 commit comments

Comments
 (0)