Class: Msf::RPC::RPC_Plugin
- Defined in:
- lib/msf/core/rpc/v10/rpc_plugin.rb
Instance Attribute Summary
Attributes inherited from RPC_Base
#framework, #job_status_tracker, #service, #tokens, #users
Instance Method Summary collapse
-
#rpc_load(path, xopts = {}) ⇒ Hash
Loads a plugin.
-
#rpc_loaded ⇒ Hash
Returns a list of loaded plugins.
-
#rpc_unload(name) ⇒ Hash
Unloads a plugin.
Methods inherited from RPC_Base
Constructor Details
This class inherits a constructor from Msf::RPC::RPC_Base
Instance Method Details
#rpc_load(path, xopts = {}) ⇒ Hash
Loads a plugin.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/msf/core/rpc/v10/rpc_plugin.rb', line 21 def rpc_load(path, xopts = {}) opts = ActiveSupport::HashWithIndifferentAccess.new 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 directory (~/.msf3/plugins/), use the base path = Msf::Config.user_plugin_directory + File::SEPARATOR + plugin_file_name if not File.exist?(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 self.framework.plugins.load(path, opts) return { "result" => "success" } end rescue ::Exception => e elog("Error loading plugin #{path}:", error: e) return { "result" => "failure" } end end |
#rpc_loaded ⇒ Hash
Returns a list of loaded plugins.
81 82 83 84 85 86 87 88 |
# File 'lib/msf/core/rpc/v10/rpc_plugin.rb', line 81 def rpc_loaded ret = {} ret[:plugins] = [] self.framework.plugins.each do |plugin| ret[:plugins] << plugin.name end ret end |
#rpc_unload(name) ⇒ Hash
Unloads a plugin.
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/msf/core/rpc/v10/rpc_plugin.rb', line 61 def rpc_unload(name) # Find a plugin within the plugins array plugin = self.framework.plugins.find { |p| p.name == name } # Unload the plugin if it matches the name we're searching for if plugin self.framework.plugins.unload(plugin) return { "result" => "success" } end { "result" => "failure" } end |