From 7994564f250436b5ed51c07a9f0ef578c5faf939 Mon Sep 17 00:00:00 2001 From: Erin Bleiweiss Date: Thu, 13 Sep 2018 12:48:17 -0500 Subject: [PATCH] Add db manager method to delete payload --- lib/msf/core/db_manager/payload.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/msf/core/db_manager/payload.rb b/lib/msf/core/db_manager/payload.rb index c8c2bc2f7a..c960234474 100644 --- a/lib/msf/core/db_manager/payload.rb +++ b/lib/msf/core/db_manager/payload.rb @@ -32,7 +32,22 @@ module Msf::DBManager::Payload end def delete_payload(opts) - 'MOCK: Payload deleted!' + raise ArgumentError.new("The following options are required: :uuids") if opts[:uuids].nil? + + ::ActiveRecord::Base.connection_pool.with_connection do + deleted = [] + opts[:uuids].each do |uuid| + payload = Mdm::Payload.find_by(uuid: uuid) + begin + deleted << payload.destroy + rescue # refs suck + elog("Forcibly deleting #{payload.address}") + deleted << payload.delete + end + end + + return deleted + end end end