From 16e800a7c41e274a823313fc4fb3f509a6aea0af Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Wed, 13 Feb 2019 05:03:45 -0600 Subject: [PATCH] Implement deregistering an option by alias Rather than having to 'unregister' both 'RHOST' and 'RHOSTS' for modules using a network-connecting mixin, this allows just unregistering one option by exposing the alias key lookup to the module options library and allowing it to remove the datastore options for the module from validation. Noted while testing #11108 that the module's unregister options were incomplete, and there were a few more like it. This allows modules operating in this style to work without modifications. --- lib/msf/core/data_store.rb | 2 -- lib/msf/core/module/options.rb | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/msf/core/data_store.rb b/lib/msf/core/data_store.rb index c8f36aef493d..01558d9da22d 100644 --- a/lib/msf/core/data_store.rb +++ b/lib/msf/core/data_store.rb @@ -306,8 +306,6 @@ def each(&block) list.each(&block) end -protected - # # Case-insensitive key lookup # diff --git a/lib/msf/core/module/options.rb b/lib/msf/core/module/options.rb index 244d5000e426..05178822519d 100644 --- a/lib/msf/core/module/options.rb +++ b/lib/msf/core/module/options.rb @@ -29,8 +29,12 @@ def validate # def deregister_options(*names) names.each { |name| - self.options.remove_option(name) + real_name = self.datastore.find_key_case(name) self.datastore.delete(name) + self.options.remove_option(name) + if real_name != name + self.options.remove_option(real_name) + end } end @@ -62,4 +66,4 @@ def register_options(options, owner = self.class) self.datastore.import_options(self.options, 'self', true) import_defaults(false) end -end \ No newline at end of file +end