@@ -43,7 +43,8 @@ def initialize(info = {})
43
43
44
44
register_advanced_options (
45
45
[
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}$' ] )
47
48
] , self . class
48
49
)
49
50
end
@@ -88,8 +89,15 @@ def check_response_fingerprint(res, fallback_status)
88
89
89
90
def find_canary
90
91
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 |
93
101
res = send_request_raw (
94
102
'uri' => normalize_uri ( canary ) ,
95
103
'method' => 'GET' ,
@@ -120,7 +128,7 @@ def test_misfortune
120
128
# find a usable canary URI (one that returns an acceptable status code already)
121
129
if canary = find_canary
122
130
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 } " )
124
132
else
125
133
vprint_error ( "#{ peer } Unable to find a suitable canary URI" )
126
134
return Exploit ::CheckCode ::Unknown
0 commit comments