From 38284d5eaa08852973bcc691f991176802da674a Mon Sep 17 00:00:00 2001 From: soh_cah_toa Date: Sun, 26 May 2013 23:26:58 -0400 Subject: [PATCH] Implemented DELETE handler for removing DNS rules. --- extensions/dns/rest/dns.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/extensions/dns/rest/dns.rb b/extensions/dns/rest/dns.rb index a98cd62c9..026cf9deb 100644 --- a/extensions/dns/rest/dns.rb +++ b/extensions/dns/rest/dns.rb @@ -89,7 +89,23 @@ module DNS print_error e.message halt 400 rescue Exception => e - print_error "Invalid JSON input passed to endpoint /api/dns/rule" + print_error 'Invalid JSON input passed to endpoint /api/dns/rule' + halt 400 + end + end + + # Removes a rule given its id + delete '/rule/:id' do + begin + id = params[:id] + + unless BeEF::Filters.alphanums_only?(id) + raise StandardError, 'Invalid id passed to endpoint /api/dns/rule/:id' + end + + BeEF::Extension::DNS::DNS.instance.remove_rule(id) + rescue StandardError => e + print_error e.message halt 400 end end