Skip to content

Commit d68b62c

Browse files
committed
Make canary value (URI) configurable
1 parent 2dca182 commit d68b62c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

modules/auxiliary/scanner/http/allegro_rompager_misfortune_cookie.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def initialize(info = {})
4343

4444
register_advanced_options(
4545
[
46-
OptString.new('STATUS_CODES_REGEX', [true, 'Ensure that canary pages and probe responses have status codes that match this regex', '^4\d{3}$'])
46+
OptString.new('CANARY_URI', [false, 'Try overwriting the requested URI with this canary value (empty for random)']),
47+
OptString.new('STATUS_CODES_REGEX', [true, 'Ensure that canary pages and probe responses have status codes that match this regex', '^4\d{2}$'])
4748
], self.class
4849
)
4950
end
@@ -88,8 +89,15 @@ def check_response_fingerprint(res, fallback_status)
8889

8990
def find_canary
9091
vprint_status("#{peer} locating suitable canary URI")
91-
0.upto(4) do
92-
canary = target_uri.path.to_s + '/' + Rex::Text.rand_text_alpha(16)
92+
canaries = []
93+
if datastore['CANARY_URI']
94+
canaries << datastore['CANARY_URI']
95+
else
96+
# several random URIs in the hopes that one, generally the first, will be usable
97+
0.upto(4) { canaries << '/' + Rex::Text.rand_text_alpha(16) }
98+
end
99+
100+
canaries.each do |canary|
93101
res = send_request_raw(
94102
'uri' => normalize_uri(canary),
95103
'method' => 'GET',
@@ -120,7 +128,7 @@ def test_misfortune
120128
# find a usable canary URI (one that returns an acceptable status code already)
121129
if canary = find_canary
122130
canary_value, canary_code = canary
123-
vprint_status("#{peer} canary URI #{canary_value} with code #{canary_code}")
131+
vprint_status("#{peer} found canary URI #{canary_value} with code #{canary_code}")
124132
else
125133
vprint_error("#{peer} Unable to find a suitable canary URI")
126134
return Exploit::CheckCode::Unknown

0 commit comments

Comments
 (0)