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
|
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
|
2007-02-12 00:20:06 +00:00
|
|
|
|
2005-05-22 19:39:21 +00:00
|
|
|
end
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
###
|
|
|
|
#
|
|
|
|
# Module-specific command dispatcher.
|
|
|
|
#
|
|
|
|
###
|
2005-07-15 22:30:04 +00:00
|
|
|
module ModuleCommandDispatcher
|
|
|
|
|
|
|
|
include Msf::Ui::Console::CommandDispatcher
|
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# The active driver module, if any.
|
|
|
|
#
|
2005-07-15 22:30:04 +00:00
|
|
|
def mod
|
|
|
|
return driver.active_module
|
|
|
|
end
|
2005-05-22 19:39:21 +00:00
|
|
|
|
2005-11-15 15:11:43 +00:00
|
|
|
#
|
|
|
|
# Sets the active driver module.
|
|
|
|
#
|
2005-10-10 00:30:14 +00:00
|
|
|
def mod=(m)
|
|
|
|
self.driver.active_module = m
|
|
|
|
end
|
|
|
|
|
2005-07-15 22:30:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end end end
|
|
|
|
|
2008-10-19 21:03:39 +00:00
|
|
|
require 'msf/ui/console/command_dispatcher/core'
|