diff --git a/lib/msf/core/db_manager/cred.rb b/lib/msf/core/db_manager/cred.rb index 0266afc39a..0b9c87d575 100644 --- a/lib/msf/core/db_manager/cred.rb +++ b/lib/msf/core/db_manager/cred.rb @@ -31,6 +31,10 @@ module Msf::DBManager::Cred query = query.where(Mdm::Service[:port].in(opts[:ports])) end + if opts[:realm].present? + query = query.where('"metasploit_credential_realms"."value" = ?', opts[:realm]) + end + if opts[:user].present? query = query.where('"metasploit_credential_publics"."username" = ?', opts[:user]) end diff --git a/lib/msf/ui/console/command_dispatcher/creds.rb b/lib/msf/ui/console/command_dispatcher/creds.rb index cac9a512d7..b34029f2f9 100644 --- a/lib/msf/ui/console/command_dispatcher/creds.rb +++ b/lib/msf/ui/console/command_dispatcher/creds.rb @@ -149,6 +149,7 @@ class Creds print_line " -u,--user List users that match this text" print_line " -t,--type List creds of the specified type: password, ntlm, hash or any valid JtR format" print_line " -O,--origins List creds that match these origins" + print_line " --realm List creds that match this realm" print_line " -R,--rhosts Set RHOSTS from the results of the search" print_line " -v,--verbose Don't truncate long password hashes" @@ -387,6 +388,8 @@ class Creds opts[:search_term] = search_term when '-v', '--verbose' truncate = false + when '--realm' + opts[:realm] = args.shift else # Anything that wasn't an option is a host to search for unless (arg_host_range(arg, host_ranges))