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 possiblities 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.

Instance Attribute Summary

Attributes included from Framework::Offspring

#framework

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Rex::Ref

#deref, #ref, #refinit

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

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

#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.


161
162
163
# File 'lib/msf/core/plugin.rb', line 161

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.


154
155
156
# File 'lib/msf/core/plugin.rb', line 154

def print(msg='')
  output.print(msg) if (output)
end

Prints a 'debug' message.


125
126
127
# File 'lib/msf/core/plugin.rb', line 125

def print_debug(msg='')
  output.print_debug(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.


118
119
120
# File 'lib/msf/core/plugin.rb', line 118

def print_good(msg='')
  output.print_good(msg) if (output)
end

Prints an undecorated line of information.


139
140
141
# File 'lib/msf/core/plugin.rb', line 139

def print_line(msg='')
  output.print_line(msg) if (output)
end

Prints a status line.


132
133
134
# File 'lib/msf/core/plugin.rb', line 132

def print_status(msg='')
  output.print_status(msg) if (output)
end

Prints a warning


146
147
148
# File 'lib/msf/core/plugin.rb', line 146

def print_warning(msg='')
  output.print_warning(msg) if (output)
end