Class: Msf::Plugin::ThreadTest

Inherits:
Msf::Plugin show all
Defined in:
plugins/thread.rb

Defined Under Namespace

Classes: ConsoleCommandDispatcher

Instance Attribute Summary

Attributes inherited from Msf::Plugin

#opts

Attributes included from Framework::Offspring

#framework

Instance Method Summary collapse

Methods inherited from Msf::Plugin

#add_console_dispatcher, create, #flush, #input, #output, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #remove_console_dispatcher

Constructor Details

#initialize(framework, opts) ⇒ ThreadTest

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.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'plugins/thread.rb', line 59

def initialize(framework, opts)
  super

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

  # Extend the thread to track the calling source
  Thread.class_eval("
  attr_accessor :tsource

  alias initialize_old initialize

  def initialize(&block)
    self.tsource = caller(1)
    initialize_old(&block)
  end
", __FILE__, __LINE__ - 9)

  print_status('ThreadTest plugin loaded.')
end

Instance Method Details

#cleanupObject

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.



87
88
89
90
91
# File 'plugins/thread.rb', line 87

def cleanup
  # If we had previously registered a console dispatcher with the console,
  # deregister it now.
  remove_console_dispatcher('ThreadTest')
end

#descObject

This method returns a brief description of the plugin. It should be no more than 60 characters, but there are no hard limits.



104
105
106
# File 'plugins/thread.rb', line 104

def desc
  'Internal test tool for testing thread usage in Metasploit'
end

#nameObject

This method returns a short, friendly name for the plugin.



96
97
98
# File 'plugins/thread.rb', line 96

def name
  'threadtest'
end