2010-05-03 17:13:09 +00:00
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
|
2005-11-19 16:25:26 +00:00
|
|
|
module Msf
|
|
|
|
|
|
|
|
###
|
2010-05-03 17:13:09 +00:00
|
|
|
#
|
2005-11-22 03:20:09 +00:00
|
|
|
# This class illustrates a sample plugin. Plugins can change the behavior of
|
|
|
|
# the framework by adding new features, new user interface commands, or
|
|
|
|
# through any other arbitrary means. They are designed to have a very loose
|
|
|
|
# definition in order to make them as useful as possible.
|
2005-11-19 16:25:26 +00:00
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Revision$
|
2005-11-19 16:25:26 +00:00
|
|
|
###
|
|
|
|
class Plugin::Sample < Msf::Plugin
|
|
|
|
|
2005-11-23 14:34:11 +00:00
|
|
|
###
|
|
|
|
#
|
|
|
|
# This class implements a sample console command dispatcher.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
class ConsoleCommandDispatcher
|
|
|
|
include Msf::Ui::Console::CommandDispatcher
|
|
|
|
|
|
|
|
#
|
|
|
|
# The dispatcher's name.
|
|
|
|
#
|
|
|
|
def name
|
|
|
|
"Sample"
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Returns the hash of commands supported by this dispatcher.
|
|
|
|
#
|
|
|
|
def commands
|
|
|
|
{
|
|
|
|
"sample" => "A sample command added by the sample plugin"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# This method handles the sample command.
|
|
|
|
#
|
|
|
|
def cmd_sample(*args)
|
2010-05-03 17:13:09 +00:00
|
|
|
print_line("You passed: #{args.join(' ')}")
|
2005-11-23 14:34:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-11-22 03:20:09 +00:00
|
|
|
#
|
|
|
|
# The constructor is called when an instance of the plugin is created. The
|
|
|
|
# framework instance that the plugin is being associated with is passed in
|
|
|
|
# the framework parameter. Plugins should call the parent constructor when
|
|
|
|
# inheriting from Msf::Plugin to ensure that the framework attribute on
|
|
|
|
# their instance gets set.
|
|
|
|
#
|
2005-11-23 14:02:30 +00:00
|
|
|
def initialize(framework, opts)
|
2005-11-19 16:25:26 +00:00
|
|
|
super
|
2005-11-23 14:02:30 +00:00
|
|
|
|
2005-11-23 14:34:11 +00:00
|
|
|
# If this plugin is being loaded in the context of a console application
|
|
|
|
# that uses the framework's console user interface driver, register
|
|
|
|
# console dispatcher commands.
|
|
|
|
add_console_dispatcher(ConsoleCommandDispatcher)
|
|
|
|
|
2005-11-23 14:02:30 +00:00
|
|
|
print_status("Sample plugin loaded.")
|
2005-11-19 16:25:26 +00:00
|
|
|
end
|
|
|
|
|
2005-11-23 14:34:11 +00:00
|
|
|
#
|
|
|
|
# The cleanup routine for plugins gives them a chance to undo any actions
|
|
|
|
# they may have done to the framework. For instance, if a console
|
|
|
|
# dispatcher was added, then it should be removed in the cleanup routine.
|
|
|
|
#
|
|
|
|
def cleanup
|
|
|
|
# If we had previously registered a console dispatcher with the console,
|
|
|
|
# deregister it now.
|
2010-05-03 17:13:09 +00:00
|
|
|
remove_console_dispatcher('Sample')
|
2005-11-23 14:34:11 +00:00
|
|
|
end
|
|
|
|
|
2005-11-22 03:20:09 +00:00
|
|
|
#
|
|
|
|
# This method returns a short, friendly name for the plugin.
|
|
|
|
#
|
|
|
|
def name
|
2005-11-19 16:25:26 +00:00
|
|
|
"sample"
|
|
|
|
end
|
|
|
|
|
2005-11-22 03:20:09 +00:00
|
|
|
#
|
|
|
|
# This method returns a brief description of the plugin. It should be no
|
|
|
|
# more than 60 characters, but there are no hard limits.
|
|
|
|
#
|
|
|
|
def desc
|
2005-11-19 16:25:26 +00:00
|
|
|
"Demonstrates using framework plugins"
|
|
|
|
end
|
|
|
|
|
2005-11-23 14:34:11 +00:00
|
|
|
protected
|
2005-11-19 16:25:26 +00:00
|
|
|
end
|
|
|
|
|
2008-10-19 21:03:39 +00:00
|
|
|
end
|