Class: Msf::RPC::RPC_Plugin

Inherits:
RPC_Base show all
Defined in:
lib/msf/core/rpc/v10/rpc_plugin.rb

Instance Attribute Summary

Attributes inherited from RPC_Base

#framework, #service, #tokens, #users

Instance Method Summary collapse

Methods inherited from RPC_Base

#error, #initialize

Constructor Details

This class inherits a constructor from Msf::RPC::RPC_Base

Instance Method Details

#rpc_load(path, xopts = {}) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/msf/core/rpc/v10/rpc_plugin.rb', line 6

def rpc_load(path, xopts = {})

  opts  = {}

  xopts.each do |k,v|
    if k.class == String
      opts[k.to_sym] = v
    end
  end

  if (path !~ /#{File::SEPARATOR}/)
    plugin_file_name = path

    # If the plugin isn't in the user direcotry (~/.msf3/plugins/), use the base
    path = Msf::Config.user_plugin_directory + File::SEPARATOR + plugin_file_name
    if not File.exists?( path  + ".rb" )
      # If the following "path" doesn't exist it will be caught when we attempt to load
      path = Msf::Config.plugin_directory + File::SEPARATOR + plugin_file_name
    end
  end

  begin
    if (inst = self.framework.plugins.load(path, opts))
      return 	{ "result" => "success" }
    end
  rescue ::Exception => e
    elog("Error loading plugin #{path}: #{e}\n\n#{e.backtrace.join("\n")}", src = 'core', level = 0, from = caller)
    return 	{ "result" => "failure" }
  end

end

#rpc_loadedObject


50
51
52
53
54
55
56
57
# File 'lib/msf/core/rpc/v10/rpc_plugin.rb', line 50

def rpc_loaded
  ret = {}
  ret[:plugins] = []
  self.framework.plugins.each do  |plugin|
    ret[:plugins] << plugin.name
  end
  ret
end

#rpc_unload(name) ⇒ Object


38
39
40
41
42
43
44
45
46
47
48
# File 'lib/msf/core/rpc/v10/rpc_plugin.rb', line 38

def rpc_unload(name)
  self.framework.plugins.each { |plugin|
    # Unload the plugin if it matches the name we're searching for
    if (plugin.name == name)
      self.framework.plugins.unload(plugin)
      return 	{ "result" => "success" }
    end
  }
  return 	{ "result" => "failure" }

end