Attempted to fix to_hash problem with get_by_database_id
git-svn-id: https://beef.googlecode.com/svn/trunk@944 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
@@ -30,6 +30,12 @@ module Module
|
||||
return false
|
||||
end
|
||||
|
||||
# Return module configuration by database id
|
||||
def self.get_key_by_database_id(id)
|
||||
ret = BeEF::Core::Configuration.instance.get('beef.module').select {|k, v| v.has_key?('db') and v['db']['id'].to_i == id.to_i }
|
||||
return (ret.kind_of?(Array)) ? ret.first : ret.keys[0]
|
||||
end
|
||||
|
||||
# Returns category name in a system folder format
|
||||
def self.safe_category(cat)
|
||||
return cat.to_s.strip.downcase.sub(/\s/, '_')
|
||||
|
||||
@@ -11,10 +11,6 @@ module Modules
|
||||
return BeEF::Core::Configuration.instance.get('beef.module').select {|k,v| v['loaded'] == true }
|
||||
end
|
||||
|
||||
# Return module configuration by database id
|
||||
def self.get_by_database_id(id)
|
||||
return BeEF::Core::Configuration.instance.get('beef.module').select {|k,v| v.has_key?('db') and v['db']['id'].to_i == id.to_i }.to_hash
|
||||
end
|
||||
|
||||
# Loads modules
|
||||
def self.load
|
||||
|
||||
@@ -283,9 +283,8 @@ class Modules < BeEF::Extension::AdminUI::HttpController
|
||||
raise WEBrick::HTTPStatus::BadRequest, "command_module_id is nil" if command_module_id.nil?
|
||||
|
||||
# get the command_module path
|
||||
mod = BeEF::Modules.get_by_database_id(command_module_id)
|
||||
key = mod.keys[0]
|
||||
mod = mod[key]
|
||||
key = BeEF::Module.get_key_by_database_id(command_module_id)
|
||||
mod = BeEF::Core::Configuration.instance.get('beef.module.'+key.to_s)
|
||||
|
||||
path = (mod['db']['path'].match(/^Dynamic/)) ? mod['db']['path'] : "#{$root_dir}"+mod['db']['path']
|
||||
|
||||
@@ -426,8 +425,8 @@ class Modules < BeEF::Extension::AdminUI::HttpController
|
||||
zombie_id = zombie.id
|
||||
raise WEBrick::HTTPStatus::BadRequest, "Zombie id is nil" if zombie_id.nil?
|
||||
|
||||
mod = BeEF::Modules.get_by_database_id(command_module_id)
|
||||
mod = mod[mod.keys[0]]
|
||||
key = BeEF::Module.get_key_by_database_id(command_module_id)
|
||||
mod = BeEF::Core::Configuration.instance.get('beef.module.'+key.to_s)
|
||||
|
||||
# if the module id is not in the database return false
|
||||
return {'success' => 'false'}.to_json if(not mod)
|
||||
|
||||
Reference in New Issue
Block a user