From ebf8694f5253d2d7819a68235947c5bea50972fa Mon Sep 17 00:00:00 2001 From: passbe Date: Wed, 27 Jul 2011 00:22:58 +0000 Subject: [PATCH] Added BeEF::Core::Configuration.clear(). Swaped module 'target_new' back to 'target'. git-svn-id: https://beef.googlecode.com/svn/trunk@1116 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- core/main/configuration.rb | 14 ++++++++++++++ core/module.rb | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/main/configuration.rb b/core/main/configuration.rb index bb53f05b7..be77d4a4b 100644 --- a/core/main/configuration.rb +++ b/core/main/configuration.rb @@ -78,6 +78,20 @@ module Core return true end + # + # Clears the given key hash + # + def clear(key) + subkeys = key.split('.') + return false if subkeys.length == 0 + lastkey = subkeys.pop + hash = @config + subkeys.each{|v| + hash = hash[v] + } + return (hash.delete(lastkey) == nil) ? false : true + end + # # load extensions configurations # diff --git a/core/module.rb b/core/module.rb index 629be2c23..aa00bcdad 100644 --- a/core/module.rb +++ b/core/module.rb @@ -90,7 +90,7 @@ module Module # 4+ = As above but with extra parameters. # Please note this rating system has no correlation to the return constant value BeEF::Core::Constants::CommandModule::* def self.support(mod, opts) - target_config = BeEF::Core::Configuration.instance.get('beef.module.'+mod+'.target_new') + target_config = BeEF::Core::Configuration.instance.get('beef.module.'+mod+'.target') if target_config and opts.kind_of? Hash if opts.key?('browser') results = [] @@ -217,7 +217,8 @@ module Module print_error "Module \"#{mod}\" configuration has invalid target status defined \"#{k}\"" end } - BeEF::Core::Configuration.instance.set("beef.module.#{mod}.target_new", targets) + BeEF::Core::Configuration.instance.clear("beef.module.#{mod}.target") + BeEF::Core::Configuration.instance.set("beef.module.#{mod}.target", targets) end end