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:
@@ -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
|
||||
|
||||
|
||||
@@ -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|
|
||||
|
||||
@@ -27,4 +27,4 @@ class Collect_links < BeEF::Core::Command
|
||||
save content
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user