From c3a611d12e98aeb1cb49149632c77a04e516a8ce Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Tue, 13 Mar 2012 17:18:13 +0100 Subject: [PATCH] Implemented info/options retrieval for a specific module throught the REST API --- core/main/rest/handlers/modules.rb | 17 ++++++++++++++--- core/module.rb | 5 ----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/main/rest/handlers/modules.rb b/core/main/rest/handlers/modules.rb index 28abbadf2..9f9ce4224 100644 --- a/core/main/rest/handlers/modules.rb +++ b/core/main/rest/handlers/modules.rb @@ -34,9 +34,20 @@ module BeEF "return available modules" end - # @note Get the module definition (info, options, targets) - get '/:session/:mod_id' do + # @note Get the module definition (info, options) + get '/:mod_id' do + cmd = BeEF::Core::Models::CommandModule.get(params[:mod_id]) + error 404 unless cmd != nil + modk = BeEF::Module.get_key_by_database_id(params[:mod_id]) + error 404 unless modk != nil + #todo check if it's possible to also retrieve the TARGETS supported + { + 'name' => cmd.name, + 'description' => config.get("beef.module.#{cmd.name}.description"), + 'category'=> config.get("beef.module.#{cmd.name}.category"), + 'options' => BeEF::Module.get_options(modk) #todo => get also payload options..get_payload_options(modk,text) + }.to_json end # @note Get the module result for the specific executed command @@ -84,7 +95,7 @@ module BeEF hb = BeEF::Core::Models::HookedBrowser.first(:session => params[:session]) error 401 unless hb != nil modk = BeEF::Module.get_key_by_database_id(params[:mod_id]) - error 401 unless modk != nil + error 404 unless modk != nil request.body.rewind begin diff --git a/core/module.rb b/core/module.rb index 516fd6d81..124661db7 100644 --- a/core/module.rb +++ b/core/module.rb @@ -67,11 +67,6 @@ module BeEF if class_symbol and class_symbol.respond_to?(:options) return class_symbol.options end - #TODO: do we really need to print this info? At then modules with no options are common, - # so I guess we shouldn't print this info even in debug mode - # else - # print_debug "Module '#{mod}', no options method defined" - # end end return [] end