Skip to content

Commit 1f6defd

Browse files
committed
Use more correct check codes
1 parent 9e76e0b commit 1f6defd

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

modules/auxiliary/scanner/http/allegro_rompager_misfortune_cookie.rb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,26 @@ def check_host(_ip)
5151
end
5252

5353
def run_host(ip)
54-
case check_host(ip)
54+
status = check_host(ip)
55+
case status
5556
when Exploit::CheckCode::Appears
56-
print_good("#{peer} is vulnerable")
5757
when Exploit::CheckCode::Detected
58-
print_good("#{peer} uses a vulnerable version")
58+
when Exploit::CheckCode::Vulnerable
59+
print_good("#{peer} #{status.last}")
5960
else
6061
vprint_status("#{peer} is not vulnerable")
6162
end
6263
end
6364

65+
# Fingerprints the provided HTTP response and returns
66+
# Exploit::CheckCode::Appears if it is a vulnerable version of RomPager,
67+
# otherwise returns the provided fall-back status.
6468
def check_response_fingerprint(res, fallback_status)
6569
fp = http_fingerprint(response: res)
6670
if /RomPager\/(?<version>[\d\.]+)/ =~ fp
6771
vprint_status("#{peer} is RomPager #{version}")
6872
if Gem::Version.new(version) < Gem::Version.new('4.34')
69-
return Exploit::CheckCode::Detected
73+
return Exploit::CheckCode::Appears
7074
end
7175
end
7276
fallback_status
@@ -84,7 +88,7 @@ def find_canary
8488
# in most cases, the canary URI will not exist and will return a 404, but
8589
# if everything under TARGETURI is protected by auth, that may be fine
8690
# too
87-
return canary if res.code == 401 || res.code == 404
91+
return canary if res && (res.code == 401 || res.code == 404)
8892
end
8993
nil
9094
end
@@ -127,27 +131,27 @@ def test_misfortune
127131

128132
unless res.code == 404
129133
vprint_status("#{full_uri} unexpected HTTP code #{res.code} response")
130-
return check_response_fingerprint(res, Exploit::CheckCode::Unknown)
134+
return check_response_fingerprint(res, Exploit::CheckCode::Detected)
131135
end
132136

133137
unless res.body
134138
vprint_status("#{full_uri} HTTP code #{res.code} had no body")
135-
return check_response_fingerprint(res, Exploit::CheckCode::Unknown)
139+
return check_response_fingerprint(res, Exploit::CheckCode::Detected)
136140
end
137141

138142
# If that canary *value* shows up in the *body*, then there are two possibilities:
139143
#
140144
# 1) If the canary cookie *name* is also in the *body*, it is likely that
141145
# the endpoint is puppeting back our request to some extent and therefore
142146
# it is expected that the canary cookie *value* would also be there.
143-
# return Exploit::CheckCode::Unknown
147+
# return Exploit::CheckCode::Detected
144148
#
145149
# 2) If the canary cookie *name* is *not* in the *body*, return
146-
# Exploit::CheckCode::Appears
150+
# Exploit::CheckCode::Vulnerable
147151
if res.body.include?(canary_value)
148152
if res.body.include?(canary_cookie_name)
149153
vprint_status("#{full_uri} HTTP code #{res.code} response contained test cookie name #{canary_cookie_name}")
150-
return check_response_fingerprint(res, Exploit::CheckCode::Unknown)
154+
return check_response_fingerprint(res, Exploit::CheckCode::Detected)
151155
else
152156
vprint_good("#{full_uri} HTTP code #{res.code} response contained canary cookie value #{canary_value} as URI")
153157
report_vuln(
@@ -156,7 +160,7 @@ def test_misfortune
156160
name: name,
157161
refs: references
158162
)
159-
return Exploit::CheckCode::Appears
163+
return Exploit::CheckCode::Vulnerable
160164
end
161165
end
162166

0 commit comments

Comments
 (0)