2012-06-29 05:18:28 +00:00
|
|
|
# -*- coding: binary -*-
|
2011-08-24 21:41:03 +00:00
|
|
|
|
2005-05-22 19:39:21 +00:00
|
|
|
module Msf
|
|
|
|
module Ui
|
|
|
|
module Console
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
###
|
|
|
|
#
|
|
|
|
# The common command dispatcher base class that is shared for component-specific
|
|
|
|
# command dispatching.
|
|
|
|
#
|
|
|
|
###
|
2005-05-22 19:39:21 +00:00
|
|
|
module CommandDispatcher
|
|
|
|
|
2005-07-18 05:13:21 +00:00
|
|
|
include Rex::Ui::Text::DispatcherShell::CommandDispatcher
|
2005-05-22 19:39:21 +00:00
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# Initializes a command dispatcher instance.
|
|
|
|
#
|
2005-07-18 05:13:21 +00:00
|
|
|
def initialize(driver)
|
|
|
|
super
|
2005-05-22 19:39:21 +00:00
|
|
|
|
2005-07-18 05:13:21 +00:00
|
|
|
self.driver = driver
|
2010-01-06 05:06:12 +00:00
|
|
|
self.driver.on_command_proc = Proc.new { |command| framework.events.on_ui_command(command) }
|
2005-05-22 19:39:21 +00:00
|
|
|
end
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# Returns the framework instance associated with this command dispatcher.
|
|
|
|
#
|
2005-05-22 19:39:21 +00:00
|
|
|
def framework
|
|
|
|
return driver.framework
|
|
|
|
end
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# Returns the active module if one has been selected, otherwise nil is
|
|
|
|
# returned.
|
|
|
|
#
|
2005-07-14 06:34:58 +00:00
|
|
|
def active_module
|
|
|
|
driver.active_module
|
2005-05-22 19:39:21 +00:00
|
|
|
end
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# Sets the active module for this driver instance.
|
|
|
|
#
|
2005-07-14 06:34:58 +00:00
|
|
|
def active_module=(mod)
|
|
|
|
driver.active_module = mod
|
2005-05-22 19:39:21 +00:00
|
|
|
end
|
|
|
|
|
2007-02-18 22:35:07 +00:00
|
|
|
#
|
|
|
|
# Returns the active session if one has been selected, otherwise nil is
|
|
|
|
# returned.
|
|
|
|
#
|
|
|
|
def active_session
|
|
|
|
driver.active_session
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Sets the active session for this driver instance.
|
|
|
|
#
|
|
|
|
def active_session=(mod)
|
|
|
|
driver.active_session = mod
|
|
|
|
end
|
2007-01-30 04:48:35 +00:00
|
|
|
#
|
|
|
|
# Checks to see if the driver is defanged.
|
|
|
|
#
|
|
|
|
def defanged?
|
|
|
|
driver.defanged?
|
|
|
|
end
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# Logs an error message to the screen and the log file. The callstack is
|
|
|
|
# also printed.
|
|
|
|
#
|
2005-07-14 07:32:11 +00:00
|
|
|
def log_error(err)
|
|
|
|
print_error(err)
|
|
|
|
|
|
|
|
wlog(err)
|
2005-09-24 00:19:27 +00:00
|
|
|
|
|
|
|
# If it's a syntax error, log the call stack that it originated from.
|
2005-09-27 00:35:51 +00:00
|
|
|
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_1)
|
2005-07-14 07:32:11 +00:00
|
|
|
end
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# The driver that this command dispatcher is associated with.
|
|
|
|
#
|
2005-05-22 19:39:21 +00:00
|
|
|
attr_accessor :driver
|
2010-12-29 21:10:14 +00:00
|
|
|
|
2011-11-20 01:32:06 +00:00
|
|
|
end
|
2005-07-15 22:30:04 +00:00
|
|
|
end end end
|
2011-11-20 01:32:06 +00:00
|
|
|
|
2011-08-24 21:41:03 +00:00
|
|
|
require 'msf/ui/console/module_command_dispatcher'
|
2009-03-28 21:42:30 +00:00
|
|
|
require 'msf/ui/console/command_dispatcher/core'
|
2011-08-24 21:41:03 +00:00
|
|
|
|