Class: Msf::Plugin

Inherits:
Object
  • Object
show all
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.

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

Attributes included from Framework::Offspring

#framework

Class Method Summary collapse

Instance Method Summary collapse

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

#optsObject (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

#cleanupObject

Allows the plugin to clean up as it is being unloaded.



59
60
# File 'lib/msf/core/plugin.rb', line 59

def cleanup
end

#descObject

A short description of the plugin.



78
79
# File 'lib/msf/core/plugin.rb', line 78

def desc
end

#flushObject

Flushes any buffered output.



156
157
158
# File 'lib/msf/core/plugin.rb', line 156

def flush
  output.flush(msg) if (output)
end

#inputObject

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

#nameObject

Returns the name of the plugin.



71
72
73
# File 'lib/msf/core/plugin.rb', line 71

def name
  "unnamed"
end

#outputObject

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

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

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

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

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

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

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