diff --git a/core/main/ar-migrations/004_create_commands.rb b/core/main/ar-migrations/004_create_commands.rb index 9bdeba338..20c9d632a 100644 --- a/core/main/ar-migrations/004_create_commands.rb +++ b/core/main/ar-migrations/004_create_commands.rb @@ -8,7 +8,7 @@ class CreateCommands < ActiveRecord::Migration[6.0] t.text :data t.datetime :creationdate t.text :label - t.boolean :instructions_sent + t.boolean :instructions_sent, default: false end end diff --git a/core/main/ar-migrations/005_create_results.rb b/core/main/ar-migrations/005_create_results.rb index 9a1265dce..97d1c6fad 100644 --- a/core/main/ar-migrations/005_create_results.rb +++ b/core/main/ar-migrations/005_create_results.rb @@ -3,6 +3,8 @@ class CreateResults < ActiveRecord::Migration[6.0] def change create_table :results do |t| + t.references :command + t.references :hooked_browser t.datetime :date t.integer :status t.text :data diff --git a/core/main/models/command.rb b/core/main/models/command.rb index 3a621483a..d43cb5917 100644 --- a/core/main/models/command.rb +++ b/core/main/models/command.rb @@ -41,13 +41,13 @@ module Models raise TypeError, "command is nil" if command.nil? # @note create the entry for the results - command.results.new( + BeEF::Core::Models::Result.create( :hooked_browser_id => hooked_browser.id, + :command_id => command.id, :data => result.to_json, :status => status, :date => Time.now.to_i ) - command.save! s = show_status(status) log = "Hooked browser [id:#{hooked_browser.id}, ip:#{hooked_browser.ip}]" diff --git a/core/main/models/result.rb b/core/main/models/result.rb index 2128450fd..a78c5ddd7 100644 --- a/core/main/models/result.rb +++ b/core/main/models/result.rb @@ -8,6 +8,9 @@ module Core module Models class Result < BeEF::Core::Model + + has_one :command + has_one :hooked_browser end diff --git a/extensions/admin_ui/controllers/modules/modules.rb b/extensions/admin_ui/controllers/modules/modules.rb index 01d875bd5..e1c8c964d 100644 --- a/extensions/admin_ui/controllers/modules/modules.rb +++ b/extensions/admin_ui/controllers/modules/modules.rb @@ -289,7 +289,7 @@ class Modules < BeEF::Extension::AdminUI::HttpController zombie_id = zombie.id (print_error "Zombie id is nil";return) if zombie_id.nil? - C.where(:command_module => command_module_id, :hooked_browser => zombie_id).each do |command| + C.where(:command_module_id => command_module_id, :hooked_browser_id => zombie_id).each do |command| commands.push({ 'id' => i, 'object_id' => command.id, diff --git a/extensions/demos/html/basic.html b/extensions/demos/html/basic.html index 0b4eaddf2..f2dd3cfcc 100644 --- a/extensions/demos/html/basic.html +++ b/extensions/demos/html/basic.html @@ -7,6 +7,7 @@ -->