From c57519c990e47203002415f3f4d56eea7e01fe13 Mon Sep 17 00:00:00 2001 From: antisnatchor Date: Sun, 24 Apr 2011 15:38:28 +0000 Subject: [PATCH] (Fixes issue 299): now commands are sorted by working-kind (working commands firsts). Also replaced numbers with constants for future code maintenance. git-svn-id: https://beef.googlecode.com/svn/trunk@921 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9 --- core/main/constants/commandmodule.rb | 10 ++++++---- .../ui/panel/tabs/ZombieTabCommands.js | 7 ++++--- extensions/metasploit/dbmigration.rb | 19 +++++++++++-------- extensions/metasploit/msfcommand.rb | 15 ++++++++++----- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/core/main/constants/commandmodule.rb b/core/main/constants/commandmodule.rb index f38066e64..ddefd4841 100644 --- a/core/main/constants/commandmodule.rb +++ b/core/main/constants/commandmodule.rb @@ -3,11 +3,13 @@ module Core module Constants module CommandModule - - VERIFIED_NOT_WORKING = 0 - VERIFIED_WORKING = 1 + + + VERIFIED_WORKING = 0 + VERIFIED_UNKNOWN = 1 VERIFIED_USER_NOTIFY = 2 - VERIFIED_UNKNOWN = 3 + VERIFIED_NOT_WORKING = 3 + end diff --git a/extensions/admin_ui/media/javascript/ui/panel/tabs/ZombieTabCommands.js b/extensions/admin_ui/media/javascript/ui/panel/tabs/ZombieTabCommands.js index 65ce5f472..21a363ada 100644 --- a/extensions/admin_ui/media/javascript/ui/panel/tabs/ZombieTabCommands.js +++ b/extensions/admin_ui/media/javascript/ui/panel/tabs/ZombieTabCommands.js @@ -34,10 +34,11 @@ ZombieTab_Commands = function(zombie) { "the wiki:
" + "http://code.google.com/p/beef/wiki/DevDocs

" + "Each command module has a traffic light icon, which is used to indicate the following:" + "
  • - It is unknown if this command works against this target
  • " + + "
  • - Command does not work against this target
  • " + }) ] }); diff --git a/extensions/metasploit/dbmigration.rb b/extensions/metasploit/dbmigration.rb index c645bbfd6..1e692fe6a 100644 --- a/extensions/metasploit/dbmigration.rb +++ b/extensions/metasploit/dbmigration.rb @@ -27,14 +27,17 @@ module Metasploit browsers = BeEF::Core::Constants::Browsers::match_browser(msfi['name'] + msfi['targets'].to_json) - targets << {'os_name' => os_name, 'browser_name' => 'ALL', 'verified_status' => 3} if browsers.count == 0 - - browsers.each do |bn| - targets << {'os_name' => os_name, 'browser_name' => bn, 'verified_status' => 1} - end - - targets << {'os_name' => "ALL", 'verified_status' => 0 } - + targets << {'os_name' => os_name, 'browser_name' => 'ALL', 'verified_status' => + BeEF::Core::Constants::CommandModule::VERIFIED_UNKNOWN} if browsers.count == 0 + + browsers.each do |bn| + targets << {'os_name' => os_name, 'browser_name' => bn, 'verified_status' => + BeEF::Core::Constants::CommandModule::VERIFIED_WORKING + } + end + + targets << {'os_name' => "ALL", 'verified_status' => BeEF::Core::Constants::CommandModule::VERIFIED_NOT_WORKING} + msfci = BeEF::Core::Models::DynamicCommandInfo.new( :name => msfi['name'], :description => msfi['description'], diff --git a/extensions/metasploit/msfcommand.rb b/extensions/metasploit/msfcommand.rb index fdd12fa0b..54816c52b 100644 --- a/extensions/metasploit/msfcommand.rb +++ b/extensions/metasploit/msfcommand.rb @@ -39,14 +39,19 @@ module Commands puts "st: " + st os_name = BeEF::Core::Constants::Os::match_os(st) + browsers = BeEF::Core::Constants::Browsers::match_browser(msfinfo['name'] + msfinfo['targets'].to_json) - targets << {'os_name' => os_name, 'browser_name' => 'ALL', 'verified_status' => 3} if browsers.count == 0 - + + targets << {'os_name' => os_name, 'browser_name' => 'ALL', 'verified_status' => + BeEF::Core::Constants::CommandModule::VERIFIED_UNKNOWN} if browsers.count == 0 + browsers.each do |bn| - targets << {'os_name' => os_name, 'browser_name' => bn, 'verified_status' => 1} + targets << {'os_name' => os_name, 'browser_name' => bn, 'verified_status' => + BeEF::Core::Constants::CommandModule::VERIFIED_WORKING + } end - - targets << {'os_name' => "ALL", 'verified_status' => 0 } + + targets << {'os_name' => "ALL", 'verified_status' => BeEF::Core::Constants::CommandModule::VERIFIED_NOT_WORKING} mod.dynamic_command_info = BeEF::Core::Models::DynamicCommandInfo.new( :name => msfinfo['name'],