Skip to content

Commit 3ad24b4

Browse files
authored
Land rapid7#19241, Remove uri unescape usage
2 parents fa80ced + eb81a78 commit 3ad24b4

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

modules/auxiliary/gather/ie_sandbox_findfiles.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ def on_request_uri(cli, request)
129129

130130
case request.uri
131131
when /^\/found\/\?f=/
132-
f = URI.unescape(request.uri.gsub('/found/?f=', ''))
132+
f = URI.decode_www_form(request.uri.split("/found/?").last).assoc('f').last
133133
report_note(host: cli.peerhost, type: 'ie.filenames', data: f)
134134
print_good("Found file " + f)
135135
send_response(cli, '')
136136
when /^\/notfound\/\?f=/
137-
f = URI.unescape(request.uri.gsub('/notfound/?f=', ''))
137+
f = URI.decode_www_form(request.uri.split("/notfound/?").last).assoc('f').last
138138
print_error("The file " + f + " does not exist")
139139
send_response(cli, '')
140140
when "/"

modules/auxiliary/scanner/http/rails_mass_assignment.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def initialize(info = {})
4444
def run_host(ip)
4545
case datastore['METHOD']
4646
when 'POST'
47-
parsed_data = queryparse(URI.unescape(datastore['DATA']))
47+
parsed_data = queryparse(URI.decode_www_form_component(datastore['DATA']))
4848
when 'GET'
49-
parsed_data = queryparse(URI.unescape(datastore['QUERY']))
49+
parsed_data = queryparse(URI.decode_www_form_component(datastore['QUERY']))
5050
end
5151
data_base_params = get_base_params(parsed_data)
5252

modules/auxiliary/scanner/sap/sap_icm_urlscan.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def check_urlprefixes
172172
url_enc = line.sub(/^PREFIX=/, '')
173173
# Remove CASE and VHOST
174174
url_enc = url_enc.sub(/&CASE=.*/, '')
175-
url_dec = URI.unescape(url_enc).sub(/;/, '')
175+
url_dec = CGI.unescape(url_enc).sub(/;/, '')
176176
urls << url_dec.strip
177177
end
178178
end

modules/exploits/multi/http/dexter_casinoloader_exec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def database_get_field(table, column, row)
7878
}
7979
})
8080
if res and !res.get_cookies.empty? and res.get_cookies.start_with?('response=')
81-
return Rex::Text.decode_base64(URI.unescape(res.get_cookies['response='.length..-1]))[1..-3]
81+
return Rex::Text.decode_base64(URI.decode_uri_component(res.get_cookies['response='.length..-1]))[1..-3]
8282
end
8383
return false
8484
end
@@ -95,7 +95,7 @@ def check
9595
})
9696

9797
if res and !res.get_cookies.empty? and res.get_cookies.start_with?('response=') and
98-
Rex::Text.decode_base64(URI.unescape(res.get_cookies['response='.length..-1])) == '$' + testvalue + ';#' and database_get_field('users', 'name', 0) != false
98+
Rex::Text.decode_base64(URI.decode_uri_component(res.get_cookies['response='.length..-1])) == '$' + testvalue + ';#' and database_get_field('users', 'name', 0) != false
9999
return Exploit::CheckCode::Vulnerable
100100
end
101101
return Exploit::CheckCode::Safe

modules/post/multi/gather/lastpass_creds.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,12 @@ def extract_credentials(account_map)
330330
unless ieffcreds.blank?
331331
ieffcreds.each do |creds|
332332
if creds[1].blank? # No master password found
333-
account_map[account][browser]['lp_creds'][URI.unescape(creds[0])] = { 'lp_password' => nil }
333+
account_map[account][browser]['lp_creds'][URI.decode_uri_component(creds[0])] = { 'lp_password' => nil }
334334
else
335-
sha256_hex_email = OpenSSL::Digest::SHA256.hexdigest(URI.unescape(creds[0]))
335+
sha256_hex_email = OpenSSL::Digest::SHA256.hexdigest(URI.decode_uri_component(creds[0]))
336336
sha256_binary_email = [sha256_hex_email].pack 'H*' # Do hex2bin
337-
creds[1] = decrypt_data(sha256_binary_email, URI.unescape(creds[1]))
338-
account_map[account][browser]['lp_creds'][URI.unescape(creds[0])] = { 'lp_password' => creds[1] }
337+
creds[1] = decrypt_data(sha256_binary_email, URI.decode_uri_component(creds[1]))
338+
account_map[account][browser]['lp_creds'][URI.decode_uri_component(creds[0])] = { 'lp_password' => creds[1] }
339339
end
340340
end
341341
end
@@ -551,7 +551,7 @@ def decrypt_local_vault_key(account, browser_map)
551551
# Use the cookie to obtain the encryption key to decrypt the vault key
552552
uri = URI('https://lastpass.com/login_check.php')
553553
request = Net::HTTP::Post.new(uri)
554-
request.set_form_data('wxsessid' => URI.unescape(session_cookie_value), 'uuid' => browser_map['lp_2fa'])
554+
request.set_form_data('wxsessid' => URI.decode_uri_component(session_cookie_value), 'uuid' => browser_map['lp_2fa'])
555555
request.content_type = 'application/x-www-form-urlencoded; charset=UTF-8'
556556
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }
557557

0 commit comments

Comments
 (0)