Added sanity check to module loading + additional print_debug's for futher information if something breaks in the loading process (Fixes issue 334)

git-svn-id: https://beef.googlecode.com/svn/trunk@962 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
passbe
2011-05-10 22:26:09 +00:00
parent 7d9008f38c
commit bdd39209da
3 changed files with 23 additions and 7 deletions

View File

@@ -18,14 +18,21 @@ module Module
# Loads module
def self.load(mod, cat)
cat = BeEF::Module.safe_category(cat)
cat = self.safe_category(cat)
if File.exists?('modules/'+cat+'/'+mod+'/module.rb')
require 'modules/'+cat+'/'+mod+'/module.rb'
BeEF::Core::Configuration.instance.set('beef.module.'+mod+'.loaded', true)
BeEF::Core::Configuration.instance.set('beef.module.'+mod+'.class', mod.capitalize)
print_debug "Loaded module: '#{mod}'"
return true
end
if self.exists?(mod)
BeEF::Core::Configuration.instance.set('beef.module.'+mod+'.loaded', true)
print_debug "Loaded module: '#{mod}'"
return true
else
BeEF::Core::Configuration.instance.set('beef.module.'+mod+'.loaded', false)
print_debug "Unable to locate module class: BeEF::Core::Commands::#{mod.capitalize}"
end
else
print_debug "Unable to locate module file: modules/#{cat}/#{mod}/module.rb"
end
print_error "Unable to load module '#{mod}'"
return false
end
@@ -40,6 +47,16 @@ module Module
def self.safe_category(cat)
return cat.to_s.strip.downcase.sub(/\s/, '_')
end
#checks to see if module class exists
def self.exists?(mod)
begin
kclass = BeEF::Core::Command.const_get(mod.capitalize)
return kclass.is_a?(Class)
rescue NameError
return false
end
end
end
end

View File

@@ -15,7 +15,6 @@ module Modules
return BeEF::Core::Models::CommandModule.all(:order => [:id.asc])
end
# Loads modules
def self.load
self.get_enabled.each { |k,v|

View File

@@ -27,4 +27,4 @@ class Collect_links < BeEF::Core::Command
save content
end
end
end