Add db manager method to delete payload

master
Erin Bleiweiss 2018-09-13 12:48:17 -05:00
parent f6f3ef1194
commit 7994564f25
No known key found for this signature in database
GPG Key ID: F69B2138BD594660
1 changed files with 16 additions and 1 deletions

View File

@ -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