Skip to content

Commit 5b88f27

Browse files
committed
Land rapid7#9560, Fix undef method 'gsub' in bavision_cam_login
2 parents d5ab7b1 + 9a293cd commit 5b88f27

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/metasploit/framework/login_scanner/bavision_cameras.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module Metasploit
55
module Framework
66
module LoginScanner
77

8+
class BavisionCamerasException < Exception; end
9+
810
class BavisionCameras < HTTP
911

1012
DEFAULT_PORT = 80
@@ -59,7 +61,13 @@ def digest_auth(user, password, response)
5961
nonce_count = 1
6062
cnonce = Digest::MD5.hexdigest("%x" % (Time.now.to_i + rand(65535)))
6163

62-
response['www-authenticate'] =~ /^(\w+) (.*)/
64+
i = (response['www-authenticate'] =~ /^(\w+) (.*)/)
65+
66+
# The www-authenticate header does not return in the format we like,
67+
# so let's bail.
68+
unless i
69+
raise BavisionCamerasException, 'www-authenticate header is not in the right format'
70+
end
6371

6472
params = {}
6573
$2.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 }
@@ -104,7 +112,7 @@ def attempt_login(credential)
104112

105113
begin
106114
result_opts.merge!(try_digest_auth(credential))
107-
rescue ::Rex::ConnectionError => e
115+
rescue ::Rex::ConnectionError, BavisionCamerasException => e
108116
# Something went wrong during login. 'e' knows what's up.
109117
result_opts.merge!(status: LOGIN_STATUS::UNABLE_TO_CONNECT, proof: e.message)
110118
end

0 commit comments

Comments
 (0)