Skip to content

Commit a444444

Browse files
committed
Land rapid7#8256. Handle blank creds in smb login scanner.
2 parents 85845b3 + 1d52e26 commit a444444

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ GEM
350350
rspec-mocks (~> 3.5.0)
351351
rspec-support (~> 3.5.0)
352352
rspec-support (3.5.0)
353-
ruby_smb (0.0.10)
353+
ruby_smb (0.0.12)
354354
bindata
355355
rubyntlm
356356
windows_error

lib/metasploit/framework/login_scanner/smb.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ def attempt_login(credential)
9494

9595
begin
9696

97-
realm = credential.realm || ""
98-
client = RubySMB::Client.new(self.dispatcher, username: credential.public, password: credential.private, domain: realm)
97+
realm = credential.realm || ""
98+
username = credential.public || ""
99+
password = credential.private || ""
100+
client = RubySMB::Client.new(self.dispatcher, username: username, password: password, domain: realm)
99101
status_code = client.login
100102

101103
# Windows SMB will return an error code during Session
@@ -125,11 +127,13 @@ def attempt_login(credential)
125127
else
126128
status = Metasploit::Model::Login::Status::INCORRECT
127129
end
128-
rescue ::Rex::ConnectionError => e
130+
rescue ::Rex::ConnectionError, Errno::EINVAL => e
129131
status = Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
130132
proof = e
131133
rescue RubySMB::Error::UnexpectedStatusCode => e
132134
status = Metasploit::Model::Login::Status::INCORRECT
135+
ensure
136+
client.disconnect!
133137
end
134138

135139
if status == Metasploit::Model::Login::Status::SUCCESSFUL && credential.public.empty?

0 commit comments

Comments
 (0)