Class: Msf::Plugin
- Inherits:
-
Object
- Object
- Msf::Plugin
- Includes:
- Framework::Offspring, Rex::Ref
- Defined in:
- lib/msf/core/plugin.rb
Overview
This module represents an abstract plugin that can be loaded into the context of a framework instance. Plugins are meant to provide an easy way to augment the feature set of the framework by being able to load and unload them during the course of a framework’s lifetime. For instance, a plugin could be loaded to alter the default behavior of new sessions, such as by scripting meterpreter sessions that are created. The possibilities are endless!
All plugins must exist under the Msf::Plugin namespace. Plugins are reference counted to allow them to be loaded more than once if they’re a singleton.
Direct Known Subclasses
Aggregator, Alias, AutoAddRoute, BeSECURE, Beholder, Capture, CredCollect, DB_Tracer, EventLibnotify, EventRSS, EventSounds, EventTester, FFAutoRegen, IPSFilter, Lab, MSGRPC, Msfd, Nessus, Nexpose, OpenVAS, PcapLog, Requests, Sample, SessionNotifier, SessionTagger, SocketLogger, Sqlmap, ThreadTest, TokenAdduser, TokenHunter, Wiki, Wmap
Defined Under Namespace
Classes: Aggregator, Alias, AutoAddRoute, BeSECURE, Beholder, Capture, CredCollect, DB_Tracer, EventLibnotify, EventRSS, EventSounds, EventTester, FFAutoRegen, IPSFilter, Lab, MSGRPC, Msfd, Nessus, Nexpose, OpenVAS, PcapLog, Requests, Sample, SessionNotifier, SessionTagger, SocketLogger, Sqlmap, ThreadTest, TokenAdduser, TokenHunter, Wiki, Wmap
Instance Attribute Summary collapse
-
#opts ⇒ Object
protected
:nodoc:.
Attributes included from Framework::Offspring
Class Method Summary collapse
-
.create(framework, opts = {}) ⇒ Object
Create an instance of the plugin using the supplied framework instance.
Instance Method Summary collapse
-
#add_console_dispatcher(disp) ⇒ Object
protected
Adds the console dispatcher.
-
#cleanup ⇒ Object
Allows the plugin to clean up as it is being unloaded.
-
#desc ⇒ Object
A short description of the plugin.
-
#flush ⇒ Object
Flushes any buffered output.
-
#initialize(framework, opts = {}) ⇒ Plugin
constructor
Initializes the plugin instance with the supplied framework instance.
-
#input ⇒ Object
Returns the local input handle if one was passed into the constructor.
-
#name ⇒ Object
Returns the name of the plugin.
-
#output ⇒ Object
Returns the local output handle if one was passed into the constructor.
-
#print(msg = '') ⇒ Object
Prints a message with no decoration.
-
#print_error(msg = '') ⇒ Object
(also: #print_bad)
Prints an error message.
-
#print_good(msg = '') ⇒ Object
Prints a ‘good’ message.
-
#print_line(msg = '') ⇒ Object
Prints an undecorated line of information.
-
#print_status(msg = '') ⇒ Object
Prints a status line.
-
#print_warning(msg = '') ⇒ Object
Prints a warning.
-
#remove_console_dispatcher(name) ⇒ Object
protected
Removes the console dispatcher.
Constructor Details
#initialize(framework, opts = {}) ⇒ Plugin
Initializes the plugin instance with the supplied framework instance. The opts parameter is a hash of custom arguments that may be useful for a plugin. Some of the pre-defined arguments are:
LocalInput
The local input handle that implements the Rex::Ui::Text::Input interface.
LocalOutput
The local output handle that implements the Rex::Ui::Output interface.
49 50 51 52 53 54 |
# File 'lib/msf/core/plugin.rb', line 49 def initialize(framework, opts = {}) self.framework = framework self.opts = opts refinit end |
Instance Attribute Details
#opts ⇒ Object (protected)
:nodoc:
162 163 164 |
# File 'lib/msf/core/plugin.rb', line 162 def opts @opts end |
Class Method Details
.create(framework, opts = {}) ⇒ Object
Create an instance of the plugin using the supplied framework instance. We use create instead of new directly so that singleton plugins can just return their singleton instance.
31 32 33 |
# File 'lib/msf/core/plugin.rb', line 31 def self.create(framework, opts = {}) new(framework, opts) end |
Instance Method Details
#add_console_dispatcher(disp) ⇒ Object (protected)
Adds the console dispatcher.
173 174 175 176 177 |
# File 'lib/msf/core/plugin.rb', line 173 def add_console_dispatcher(disp) if (opts['ConsoleDriver']) opts['ConsoleDriver'].append_dispatcher(disp) end end |
#cleanup ⇒ Object
Allows the plugin to clean up as it is being unloaded.
59 60 |
# File 'lib/msf/core/plugin.rb', line 59 def cleanup end |
#desc ⇒ Object
A short description of the plugin.
78 79 |
# File 'lib/msf/core/plugin.rb', line 78 def desc end |
#flush ⇒ Object
Flushes any buffered output.
156 157 158 |
# File 'lib/msf/core/plugin.rb', line 156 def flush output.flush(msg) if (output) end |
#input ⇒ Object
Returns the local input handle if one was passed into the constructor.
97 98 99 |
# File 'lib/msf/core/plugin.rb', line 97 def input opts['LocalInput'] end |
#name ⇒ Object
Returns the name of the plugin.
71 72 73 |
# File 'lib/msf/core/plugin.rb', line 71 def name "unnamed" end |
#output ⇒ Object
Returns the local output handle if one was passed into the constructor.
90 91 92 |
# File 'lib/msf/core/plugin.rb', line 90 def output opts['LocalOutput'] end |
#print(msg = '') ⇒ Object
Prints a message with no decoration.
149 150 151 |
# File 'lib/msf/core/plugin.rb', line 149 def print(msg='') output.print(msg) if (output) end |
#print_error(msg = '') ⇒ Object Also known as: print_bad
Prints an error message.
111 112 113 |
# File 'lib/msf/core/plugin.rb', line 111 def print_error(msg='') output.print_error(msg) if (output) end |
#print_good(msg = '') ⇒ Object
Prints a ‘good’ message.
120 121 122 |
# File 'lib/msf/core/plugin.rb', line 120 def print_good(msg='') output.print_good(msg) if (output) end |
#print_line(msg = '') ⇒ Object
Prints an undecorated line of information.
134 135 136 |
# File 'lib/msf/core/plugin.rb', line 134 def print_line(msg='') output.print_line(msg) if (output) end |
#print_status(msg = '') ⇒ Object
Prints a status line.
127 128 129 |
# File 'lib/msf/core/plugin.rb', line 127 def print_status(msg='') output.print_status(msg) if (output) end |
#print_warning(msg = '') ⇒ Object
Prints a warning
141 142 143 |
# File 'lib/msf/core/plugin.rb', line 141 def print_warning(msg='') output.print_warning(msg) if (output) end |
#remove_console_dispatcher(name) ⇒ Object (protected)
Removes the console dispatcher.
182 183 184 185 186 |
# File 'lib/msf/core/plugin.rb', line 182 def remove_console_dispatcher(name) if (opts['ConsoleDriver']) opts['ConsoleDriver'].remove_dispatcher(name) end end |