Class: Msf::Plugin::MSGRPC
- Inherits:
-
Msf::Plugin
- Object
- Msf::Plugin
- Msf::Plugin::MSGRPC
- Defined in:
- plugins/msgrpc.rb
Overview
This class implements the msfd plugin interface.
Instance Attribute Summary collapse
-
#server ⇒ Object
The MSGRPC instance.
-
#thread ⇒ Object
Returns the value of attribute thread.
-
#tokens ⇒ Object
Returns the value of attribute tokens.
-
#users ⇒ Object
Returns the value of attribute users.
Attributes inherited from Msf::Plugin
Attributes included from Framework::Offspring
Instance Method Summary collapse
-
#cleanup ⇒ Object
Closes the listener service.
-
#desc ⇒ Object
Returns the plugin description.
-
#initialize(framework, opts) ⇒ MSGRPC
constructor
ServerPort.
-
#name ⇒ Object
Returns 'msgrpc'.
-
#run ⇒ Object
The meat of the plugin, sets up handlers for requests.
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) ⇒ MSGRPC
ServerPort
The local port to listen on for connections. The default is 55552
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'plugins/msgrpc.rb', line 36 def initialize(framework, opts) super host = opts['ServerHost'] || DefaultHost port = opts['ServerPort'] || DefaultPort ssl = (opts['SSL'] && opts['SSL'].to_s =~ /^[ty]/i) ? true : false cert = opts['SSLCert'] user = opts['User'] || "msf" pass = opts['Pass'] || ::Rex::Text.rand_text_alphanumeric(8) uri = opts['URI'] || "/api" timeout = opts['TokenTimeout'] || 300 print_status("MSGRPC Service: #{host}:#{port} #{ssl ? " (SSL)" : ""}") print_status("MSGRPC Username: #{user}") print_status("MSGRPC Password: #{pass}") self.server = ::Msf::RPC::Service.new(framework, { :host => host, :port => port, :ssl => ssl, :cert => cert, :uri => uri, :tokens => { }, :token_timeout => timeout }) self.server.add_user(user, pass) # If the run in foreground flag is not specified, then go ahead and fire # it off in a worker thread. unless opts['RunInForeground'] == true # Store a handle to the thread so we can kill it during # cleanup when we get unloaded. self.thread = Thread.new { run } framework.threads.register(self.thread, "MetasploitRPCServer", true) end end |
Instance Attribute Details
#server ⇒ Object
The MSGRPC instance.
116 117 118 |
# File 'plugins/msgrpc.rb', line 116 def server @server end |
#thread ⇒ Object
Returns the value of attribute thread
117 118 119 |
# File 'plugins/msgrpc.rb', line 117 def thread @thread end |
#tokens ⇒ Object
Returns the value of attribute tokens
119 120 121 |
# File 'plugins/msgrpc.rb', line 119 def tokens @tokens end |
#users ⇒ Object
Returns the value of attribute users
118 119 120 |
# File 'plugins/msgrpc.rb', line 118 def users @users end |
Instance Method Details
#cleanup ⇒ Object
Closes the listener service.
106 107 108 109 110 111 |
# File 'plugins/msgrpc.rb', line 106 def cleanup self.server.stop if self.server self.thread.kill if self.thread self.server = nil super end |
#desc ⇒ Object
Returns the plugin description.
85 86 87 |
# File 'plugins/msgrpc.rb', line 85 def desc "Provides a MessagePack interface over HTTP" end |
#name ⇒ Object
Returns 'msgrpc'
78 79 80 |
# File 'plugins/msgrpc.rb', line 78 def name "msgrpc" end |
#run ⇒ Object
The meat of the plugin, sets up handlers for requests
92 93 94 95 96 97 98 99 100 101 |
# File 'plugins/msgrpc.rb', line 92 def run # Start the actual service self.server.start # Register framework.threads.register(Thread.current, "MetasploitRPCServer", true) # Wait for the service to complete self.server.wait end |