Skip to content

Commit aef8c70

Browse files
committed
Filter creds by type
1 parent 1f4d62a commit aef8c70

File tree

1 file changed

+16
-0
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+16
-0
lines changed

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,13 +676,15 @@ def cmd_creds_help
676676
print_line " -p,--port <portspec> List creds with logins on services matching this port spec"
677677
print_line " -s <svc names> List creds matching comma-separated service names"
678678
print_line " -u,--user <regex> List users that match this regex"
679+
print_line " -t,--type <type> List creds that match the following types: (password,ntlm,hash)"
679680

680681
print_line
681682
print_line "Examples, listing:"
682683
print_line " creds # Default, returns all credentials"
683684
print_line " creds 1.2.3.4/24 # nmap host specification"
684685
print_line " creds -p 22-25,445 # nmap port specification"
685686
print_line " creds -s ssh,smb # All creds associated with a login on SSH or SMB services"
687+
print_line " creds -t ntlm # All NTLM creds"
686688
print_line
687689

688690
print_line
@@ -822,6 +824,17 @@ def creds_search(*args)
822824
pass_regex = Regexp.compile(pass)
823825
end
824826

827+
if ptype
828+
type = case ptype
829+
when 'password'
830+
Metasploit::Credential::Password
831+
when 'hash'
832+
Metasploit::Credential::PasswordHash
833+
when 'ntlm'
834+
Metasploit::Credential::NTLMHash
835+
end
836+
end
837+
825838
# normalize
826839
ports = port_ranges.flatten.uniq
827840
svcs.flatten!
@@ -839,6 +852,9 @@ def creds_search(*args)
839852

840853
query.each do |core|
841854

855+
# Exclude creds that don't match the given type
856+
next if type.present? && !core.private.kind_of?(type)
857+
842858
# Exclude creds that don't match the given user
843859
if user_regex.present? && !core.public.username.match(user_regex)
844860
next

0 commit comments

Comments
 (0)