@@ -40,6 +40,12 @@ def initialize(info = {})
40
40
OptString . new ( 'TARGETURI' , [ true , 'URI to test' , '/' ] )
41
41
] , Exploit ::Remote ::HttpClient
42
42
)
43
+
44
+ register_advanced_options (
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}$' ] )
47
+ ] , self . class
48
+ )
43
49
end
44
50
45
51
def check_host ( _ip )
@@ -62,6 +68,10 @@ def run_host(ip)
62
68
end
63
69
end
64
70
71
+ def setup
72
+ @status_codes_regex = Regexp . new ( datastore [ 'STATUS_CODES_REGEX' ] )
73
+ end
74
+
65
75
# Fingerprints the provided HTTP response and returns
66
76
# Exploit::CheckCode::Appears if it is a vulnerable version of RomPager,
67
77
# otherwise returns the provided fall-back status.
@@ -86,9 +96,9 @@ def find_canary
86
96
'headers' => headers
87
97
)
88
98
# in most cases, the canary URI will not exist and will return a 404, but
89
- # if everything under TARGETURI is protected by auth, that may be fine
90
- # too
91
- return canary if res && ( res . code == 401 || res . code == 404 )
99
+ # if everything under TARGETURI is protected by auth, a 401 may be OK too.
100
+ # but, regardless, respect the configuration set for this module
101
+ return canary if res && res . code . to_s =~ @status_codes_regex
92
102
end
93
103
nil
94
104
end
@@ -107,7 +117,7 @@ def headers
107
117
# overwrote RomPager's concept of the requested URI, indicating that it is
108
118
# vulnerable.
109
119
def test_misfortune
110
- # find a usable canary URI (one that returns a 404 already)
120
+ # find a usable canary URI (one that returns an acceptable status code already)
111
121
unless ( canary_value = find_canary )
112
122
vprint_error ( "#{ peer } Unable to find a suitable canary URI" )
113
123
return Exploit ::CheckCode ::Unknown
@@ -129,7 +139,7 @@ def test_misfortune
129
139
return Exploit ::CheckCode ::Unknown
130
140
end
131
141
132
- unless res . code == 404
142
+ unless res . code . to_s =~ @status_codes_regex
133
143
vprint_status ( "#{ full_uri } unexpected HTTP code #{ res . code } response" )
134
144
return check_response_fingerprint ( res , Exploit ::CheckCode ::Detected )
135
145
end
0 commit comments