diff --git a/lib/msf/core/db_manager/cred.rb b/lib/msf/core/db_manager/cred.rb index c816cf1ff8..ad23f14a14 100644 --- a/lib/msf/core/db_manager/cred.rb +++ b/lib/msf/core/db_manager/cred.rb @@ -262,7 +262,9 @@ module Msf::DBManager::Cred end id = opts.delete(:id) - Metasploit::Credential::Core.update(id, opts) + cred = Metasploit::Credential::Core.find(id) + cred.update!(opts) + return cred } end diff --git a/lib/msf/core/db_manager/host.rb b/lib/msf/core/db_manager/host.rb index bce68a40f3..d96037be40 100644 --- a/lib/msf/core/db_manager/host.rb +++ b/lib/msf/core/db_manager/host.rb @@ -283,7 +283,9 @@ module Msf::DBManager::Host opts[:workspace] = wspace if wspace id = opts.delete(:id) - Mdm::Host.update(id, opts) + host = Mdm::Host.find(id) + host.update!(opts) + return host } end diff --git a/lib/msf/core/db_manager/login.rb b/lib/msf/core/db_manager/login.rb index e8c603809c..eefbe66f7e 100644 --- a/lib/msf/core/db_manager/login.rb +++ b/lib/msf/core/db_manager/login.rb @@ -10,7 +10,9 @@ module Msf::DBManager::Login wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework, false) opts[:workspace] = wspace if wspace id = opts.delete(:id) - Metasploit::Credential::Login.update(id, opts) + login = Metasploit::Credential::Login.find(id) + login.update!(opts) + return login } end diff --git a/lib/msf/core/db_manager/loot.rb b/lib/msf/core/db_manager/loot.rb index 0109c2f854..e0cb0b983d 100644 --- a/lib/msf/core/db_manager/loot.rb +++ b/lib/msf/core/db_manager/loot.rb @@ -102,7 +102,9 @@ module Msf::DBManager::Loot opts[:workspace] = wspace if wspace id = opts.delete(:id) - Mdm::Loot.update(id, opts) + loot = Mdm::Loot.find(id) + loot.update!(opts) + return loot } end @@ -128,4 +130,4 @@ module Msf::DBManager::Loot return deleted } end -end \ No newline at end of file +end diff --git a/lib/msf/core/db_manager/note.rb b/lib/msf/core/db_manager/note.rb index 0177691852..906e299790 100644 --- a/lib/msf/core/db_manager/note.rb +++ b/lib/msf/core/db_manager/note.rb @@ -200,7 +200,9 @@ module Msf::DBManager::Note opts[:workspace] = wspace if wspace id = opts.delete(:id) - Mdm::Note.update(id, opts) + note = Mdm::Note.find(id) + note.update!(opts) + return note } end diff --git a/lib/msf/core/db_manager/service.rb b/lib/msf/core/db_manager/service.rb index 852b72442c..7bab5c7663 100644 --- a/lib/msf/core/db_manager/service.rb +++ b/lib/msf/core/db_manager/service.rb @@ -170,7 +170,9 @@ module Msf::DBManager::Service ::ActiveRecord::Base.connection_pool.with_connection { id = opts.delete(:id) - Mdm::Service.update(id, opts) + service = Mdm::Service.find(id) + service.update!(opts) + return service } end end diff --git a/lib/msf/core/db_manager/session.rb b/lib/msf/core/db_manager/session.rb index 379ee6a22d..382b138c8a 100644 --- a/lib/msf/core/db_manager/session.rb +++ b/lib/msf/core/db_manager/session.rb @@ -188,7 +188,9 @@ module Msf::DBManager::Session ::ActiveRecord::Base.connection_pool.with_connection { id = opts.delete(:id) - ::Mdm::Session.update(id, opts) + session = ::Mdm::Session.find(id) + session.update!(opts) + return session } end diff --git a/lib/msf/core/db_manager/user.rb b/lib/msf/core/db_manager/user.rb index 073cbb87bc..3374c1c953 100644 --- a/lib/msf/core/db_manager/user.rb +++ b/lib/msf/core/db_manager/user.rb @@ -75,7 +75,9 @@ module Msf::DBManager::User def update_user(opts) ::ActiveRecord::Base.connection_pool.with_connection { id = opts.delete(:id) - Mdm::User.update(id, opts) + user = Mdm::User.find(id) + user.update!(opts) + return user } end @@ -133,7 +135,9 @@ module Msf::DBManager::User token_length = opts[:token_length] || MIN_TOKEN_LENGTH # NOTE: repurposing persistence_token in the database as the API token - Mdm::User.update(opts[:id], {persistence_token: SecureRandom.hex(token_length)}).persistence_token + user = Mdm::User.find(opts[:id]) + user.update!({persistence_token: SecureRandom.hex(token_length)}) + user.persistence_token end end diff --git a/lib/msf/core/db_manager/vuln_detail.rb b/lib/msf/core/db_manager/vuln_detail.rb index 7d3e52eccc..78ef2943c2 100644 --- a/lib/msf/core/db_manager/vuln_detail.rb +++ b/lib/msf/core/db_manager/vuln_detail.rb @@ -25,7 +25,9 @@ module Msf::DBManager::VulnDetail def update_vuln_details(details) ::ActiveRecord::Base.connection_pool.with_connection { criteria = details.delete(:key) || {} - ::Mdm::VulnDetail.update(key, details) + vuln_detail = ::Mdm::VulnDetail.find(key) + vuln_detail.update!(criteria) + return vuln_detail } end -end \ No newline at end of file +end diff --git a/lib/msf/core/db_manager/workspace.rb b/lib/msf/core/db_manager/workspace.rb index 1a3117a159..ea236923b0 100644 --- a/lib/msf/core/db_manager/workspace.rb +++ b/lib/msf/core/db_manager/workspace.rb @@ -99,7 +99,7 @@ module Msf::DBManager::Workspace ::ActiveRecord::Base.connection_pool.with_connection { ws_to_update = workspaces({ id: opts.delete(:id) }).first default_renamed = true if ws_to_update.name == DEFAULT_WORKSPACE_NAME - updated_ws = Mdm::Workspace.update(ws_to_update.id, opts) + updated_ws = ws_to_update.update!(opts) add_workspace({ name: DEFAULT_WORKSPACE_NAME }) if default_renamed updated_ws }