Search for creds at the query level
parent
c6a5a139ae
commit
d6eaa4a7c7
|
@ -4,6 +4,7 @@ module Msf::DBManager::Cred
|
||||||
query = nil
|
query = nil
|
||||||
::ActiveRecord::Base.connection_pool.with_connection {
|
::ActiveRecord::Base.connection_pool.with_connection {
|
||||||
wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework)
|
wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework)
|
||||||
|
search_term = opts.delete(:search_term)
|
||||||
# If :id exists we're looking for a specific record, skip the other stuff
|
# If :id exists we're looking for a specific record, skip the other stuff
|
||||||
if opts[:id].present?
|
if opts[:id].present?
|
||||||
return Metasploit::Credential::Core.where(id: opts[:id])
|
return Metasploit::Credential::Core.where(id: opts[:id])
|
||||||
|
@ -40,6 +41,15 @@ module Msf::DBManager::Cred
|
||||||
# filter based on host, port, or service name
|
# filter based on host, port, or service name
|
||||||
query = query.where(Metasploit::Credential::Login[:id].not_eq(nil))
|
query = query.where(Metasploit::Credential::Login[:id].not_eq(nil))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if search_term && !search_term.empty?
|
||||||
|
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
|
||||||
|
query = query.where(column_search_conditions)
|
||||||
|
end
|
||||||
}
|
}
|
||||||
query
|
query
|
||||||
end
|
end
|
||||||
|
|
|
@ -471,10 +471,10 @@ class Creds
|
||||||
tbl << row
|
tbl << row
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if mode == :delete
|
end
|
||||||
result = framework.db.delete_credentials(ids: matched_cred_ids)
|
if mode == :delete
|
||||||
delete_count = result.size
|
result = framework.db.delete_credentials(ids: matched_cred_ids)
|
||||||
end
|
delete_count = result.size
|
||||||
end
|
end
|
||||||
|
|
||||||
if output_file.nil?
|
if output_file.nil?
|
||||||
|
|
Loading…
Reference in New Issue