Skip to content

Commit d7a6edb

Browse files
committed
Land rapid7#7939, Override empty? for the weird ones
2 parents 272d184 + 4f13bde commit d7a6edb

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

lib/metasploit/framework/community_string_collection.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ def each
5959
end
6060
end
6161

62+
def empty?
63+
prepended_creds.empty? && !pass_file.present? && !password.present?
64+
end
65+
6266
# Add {Credential credentials} that will be yielded by {#each}
6367
#
6468
# @see prepended_creds

lib/metasploit/framework/credential_collection.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,15 @@ def each
207207

208208
# Returns true when #each will have no results to iterate
209209
def empty?
210-
hasUser = username.present? || user_file.present? || userpass_file.present? || !additional_publics.empty?
211-
hasPass = password.present? || pass_file.present? || userpass_file.present? ||!additional_privates.empty? || blank_passwords
212-
prepended_creds.empty? && !hasUser || (hasUser && !hasPass)
210+
prepended_creds.empty? && !has_users? || (has_users? && !has_privates?)
211+
end
212+
213+
def has_users?
214+
username.present? || user_file.present? || userpass_file.present? || !additional_publics.empty?
215+
end
216+
217+
def has_privates?
218+
password.present? || pass_file.present? || userpass_file.present? || !additional_privates.empty? || blank_passwords
213219
end
214220

215221
private

modules/auxiliary/scanner/ssh/ssh_login_pubkey.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ def initialize(opts={})
265265
valid!
266266
end
267267

268+
# Override CredentialCollection#has_privates?
269+
def has_privates?
270+
!@key_data.empty?
271+
end
272+
268273
def realm
269274
nil
270275
end

0 commit comments

Comments
 (0)