diff --git a/lib/msf/core/db_manager/cred.rb b/lib/msf/core/db_manager/cred.rb index d082390a7a..f15b4e5135 100644 --- a/lib/msf/core/db_manager/cred.rb +++ b/lib/msf/core/db_manager/cred.rb @@ -11,7 +11,7 @@ module Msf::DBManager::Cred end query = Metasploit::Credential::Core.where( workspace_id: wspace.id ) - query = query.includes(:private, :public, :logins).references(:private, :public, :logins) + query = query.includes(:private, :public, :logins, :realm).references(:private, :public, :logins, :realm) query = query.includes(logins: [ :service, { service: :host } ]) if opts[:type].present? @@ -46,8 +46,8 @@ module Msf::DBManager::Cred core_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Metasploit::Credential::Core, search_term, ['created_at', 'updated_at']) public_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Metasploit::Credential::Public, search_term, ['created_at', 'updated_at']) private_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Metasploit::Credential::Private, search_term, ['created_at', 'updated_at']) - column_search_conditions = core_search_conditions.or(public_search_conditions).or(private_search_conditions) - Metasploit::Credential::Core.where(column_search_conditions).includes(:private, :public).references(:private, :public).count + realm_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Metasploit::Credential::Realm, search_term, ['created_at', 'updated_at']) + column_search_conditions = core_search_conditions.or(public_search_conditions).or(private_search_conditions).or(realm_search_conditions) query = query.where(column_search_conditions) end } diff --git a/lib/msf/ui/console/command_dispatcher/creds.rb b/lib/msf/ui/console/command_dispatcher/creds.rb index c281846fe4..4f982d2ecf 100644 --- a/lib/msf/ui/console/command_dispatcher/creds.rb +++ b/lib/msf/ui/console/command_dispatcher/creds.rb @@ -172,6 +172,7 @@ class Creds print_line " -t,--type List creds that match the following types: #{allowed_cred_types.join(',')}" print_line " -O,--origins List creds that match these origins" print_line " -R,--rhosts Set RHOSTS from the results of the search" + print_line " -S,--search-term Search across all fields using regex" print_line print_line "Examples, listing:"