From 73d6f93d1d5f38ba7539e457a31bf38e0bcabc80 Mon Sep 17 00:00:00 2001 From: "wade@bindshell.net" Date: Tue, 4 Jan 2011 08:40:58 +0000 Subject: [PATCH] Updated to fix Issue 186. Previously, if a HB did not return a module result the instructions are resent. This update stops that and will only send the module instructions once. git-svn-id: https://beef.googlecode.com/svn/trunk@665 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- lib/model/command.rb | 6 +----- lib/server/modules/common.rb | 4 ++++ lib/server/zombiehandler.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/model/command.rb b/lib/model/command.rb index 8ef3f264f..a1bf2cea8 100644 --- a/lib/model/command.rb +++ b/lib/model/command.rb @@ -35,16 +35,12 @@ class Command zombie_ip = zombie.ip # get the command module data structure from the database - command = first(:id => command_id.to_i, :has_run => false, :zombie_id => zombie_id) || nil + command = first(:id => command_id.to_i, :zombie_id => zombie_id) || nil raise WEBrick::HTTPStatus::BadRequest, "command is nil" if command.nil? # create the entry for the results command.results.new(:zombie_id => zombie_id, :data => result, :date => Time.now.to_i) - - # flag that the command has run and the results have been returned - command.has_run = true - # write the data to the database command.save # log that the result was returned diff --git a/lib/server/modules/common.rb b/lib/server/modules/common.rb index 4129c1f9f..36307370f 100644 --- a/lib/server/modules/common.rb +++ b/lib/server/modules/common.rb @@ -97,6 +97,10 @@ module Modules 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.has_run = true + command.save + # get the command module command_module = BeEF::Models::CommandModule.first(:id => command.command_module_id) raise WEBrick::HTTPStatus::BadRequest, "command_module is nil" if command_module.nil? diff --git a/lib/server/zombiehandler.rb b/lib/server/zombiehandler.rb index 767a50ece..ebbce2109 100644 --- a/lib/server/zombiehandler.rb +++ b/lib/server/zombiehandler.rb @@ -55,7 +55,7 @@ module BeEF hooked_browser.save execute_plugins! - + # add all availible command module instructions to the response zombie_commands = BeEF::Models::Command.all(:zombie_id => hooked_browser.id, :has_run => false) zombie_commands.each{|command| add_command_instructions(command, hooked_browser)}