diff --git a/core/extension.rb b/core/extension.rb index 2f57cb4fe..7569ec0e7 100644 --- a/core/extension.rb +++ b/core/extension.rb @@ -1,5 +1,20 @@ module BeEF module Extension + # Checks to see if extensions is in configuration + def self.is_present(ext) + return BeEF::Core::Configuration.instance.get('beef.extension').has_key?(ext.to_s) + end + + # Checks to see if extension is enabled in configuration + def self.is_enabled(ext) + return (self.is_present(ext) and BeEF::Core::Configuration.instance.get('beef.extension.'+ext.to_s+'.enable') == true) + end + + # Checks to see if extensions reports loaded through the configuration + def self.is_loaded(ext) + return (self.is_enabled(ext) and BeEF::Core::Configuration.instance.get('beef.extension.'+ext.to_s+'.loaded') == true) + end + end end diff --git a/core/module.rb b/core/module.rb index 46229d4cf..480b5f51d 100644 --- a/core/module.rb +++ b/core/module.rb @@ -1,10 +1,25 @@ module BeEF module Module + # Checks to see if module is in configuration + def self.is_present(mod) + return BeEF::Core::Configuration.instance.get('beef.module').has_key?(mod.to_s) + end + + # Checks to see if module is enabled in configuration + def self.is_enabled(mod) + return (self.is_present(mod) and BeEF::Core::Configuration.instance.get('beef.module.'+mod.to_s+'.enable') == true) + end + + # Checks to see if the module reports that it has loaded through the configuration + def self.is_loaded(mod) + return (self.is_enabled(mod) and BeEF::Core::Configuration.instance.get('beef.module.'+mod.to_s+'.loaded') == true) + end + + # Returns category name in a system folder format def self.safe_category(cat) return cat.to_s.strip.downcase.sub(/\s/, '_') end - end end