diff --git a/lib/modules/command.rb b/lib/modules/command.rb index aa8501204..af0c997c6 100644 --- a/lib/modules/command.rb +++ b/lib/modules/command.rb @@ -55,7 +55,7 @@ module BeEF # Super class controller def initialize(info) @info = info - @datastore = @info['Data'] || nil + @datastore = @info['Data'] || {} @friendlyname = @info['Name'] || nil @target = @info['Target'] || nil @output = '' @@ -94,7 +94,7 @@ module BeEF # Builds the 'datastore' attribute of the command which is used to generate javascript code. def build_datastore(data); - @datastore = JSON.parse(data); + @datastore = JSON.parse(data) end # Sets the datastore for the callback function. This function is meant to be called by the CommandHandler diff --git a/lib/server/modules/common.rb b/lib/server/modules/common.rb index c12e45e68..8507cf660 100644 --- a/lib/server/modules/common.rb +++ b/lib/server/modules/common.rb @@ -100,10 +100,6 @@ module Modules raise WEBrick::HTTPStatus::BadRequest, "zombie.session is nil" if zombie.session.nil? raise WEBrick::HTTPStatus::BadRequest, "zombie is nil" if command.nil? raise WEBrick::HTTPStatus::BadRequest, "zombie.session is nil" if command.command_module_id.nil? - - # flag that the command has been sent to the hooked browser - command.instructions_sent = true - command.save # get the command module command_module = BeEF::Models::CommandModule.first(:id => command.command_module_id) @@ -111,7 +107,7 @@ module Modules raise WEBrick::HTTPStatus::BadRequest, "command_module.path is nil" if command_module.path.nil? klass = File.basename command_module.path, '.rb' - + @guard.synchronize { command_module = BeEF::Modules::Commands.const_get(klass.capitalize).new command_module.command_id = command.id @@ -126,6 +122,10 @@ module Modules puts "+ Hooked browser #{zombie.ip} sent command module #{klass}" if @cmd_opts[:verbose] } + + # flag that the command has been sent to the hooked browser + command.instructions_sent = true + command.save end #