From 88ce370792e74951b07afd191a73fea15fda19bb Mon Sep 17 00:00:00 2001 From: passbe Date: Thu, 28 Apr 2011 01:12:58 +0000 Subject: [PATCH] Changed reliance upon filename to the configuration system. This works towards fixing issue #322 git-svn-id: https://beef.googlecode.com/svn/trunk@937 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- core/main/command.rb | 2 +- core/main/handlers/modules/command.rb | 6 ++---- core/main/server.rb | 6 ++---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/core/main/command.rb b/core/main/command.rb index 7d3458950..d48839ec7 100644 --- a/core/main/command.rb +++ b/core/main/command.rb @@ -46,7 +46,7 @@ module Core # Super class controller def initialize(info) get_extensions - + @info = info @datastore = @info['Data'] || {} @friendlyname = @info['Name'] || nil diff --git a/core/main/handlers/modules/command.rb b/core/main/handlers/modules/command.rb index 8909b33ba..db4152a55 100644 --- a/core/main/handlers/modules/command.rb +++ b/core/main/handlers/modules/command.rb @@ -21,11 +21,9 @@ module Modules raise WEBrick::HTTPStatus::BadRequest, "command_module.path is nil" if command_module.path.nil? if(command_module.path.match(/^Dynamic/)) - klass = command_module.path.split('/').last - command_module = BeEF::Modules::Commands.const_get(klass.capitalize).new + command_module = BeEF::Modules::Commands.const_get(command_module.name.capitalize).new else - klass = command_module.path.split('/').reverse[1] - command_module = BeEF::Core::Command.const_get(klass.capitalize).new + command_module = BeEF::Core::Command.const_get(command_module.name.capitalize).new end command_module.command_id = command.id diff --git a/core/main/server.rb b/core/main/server.rb index f5fb6d388..dea1e40f9 100644 --- a/core/main/server.rb +++ b/core/main/server.rb @@ -79,10 +79,8 @@ module Core mount("#{@configuration.get("beef.http.hook_file")}", true, BeEF::Core::Handlers::HookedBrowsers) # Create http handlers for all commands in the framework - Dir["#{root_dir}/modules/**/*.rb"].each { |command| - #command_class = (File.basename command, '.rb').capitalize - command_class = command.split('/').reverse[1] - mount("/command/#{command_class}.js", false, BeEF::Core::Handlers::Commands, command_class) + BeEF::Modules.get_loaded.each { |k,v| + mount("/command/#{k}.js", false, BeEF::Core::Handlers::Commands, k) } #