From a2548fe92d1e229c1fba3afb78982c8ceb0634b4 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Tue, 8 Jan 2019 15:21:14 -0600 Subject: [PATCH] Only lookup db connections by name Matching on all attributes was causing issues when the connection criteria would change for a db service at a host that already existed. It would find the existing connection and load that outdated connection and fail to connect. The new functionality will save a new, valid connection with a randomly generated name, unless the -n flag is specified to overwrite an existing connection. --- lib/msf/ui/console/command_dispatcher/db.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/msf/ui/console/command_dispatcher/db.rb b/lib/msf/ui/console/command_dispatcher/db.rb index 50ad0687c7..5e2cefc024 100644 --- a/lib/msf/ui/console/command_dispatcher/db.rb +++ b/lib/msf/ui/console/command_dispatcher/db.rb @@ -1766,7 +1766,7 @@ class Db when '-l', '--list-services' list_saved_data_services return - when '-n', '--name' + when '-n', '--name' name = args.shift if name =~ /\/|\[|\]/ print_error "Provided name contains an invalid character. Aborting connection." @@ -2174,7 +2174,6 @@ class Db conf.each_pair do |k,v| name = k.split('/').last rv = name if name == search_criteria - rv = name if v.values.include?(search_criteria) end rv end