Class: Msf::RPC::JSON::V1_0::RpcCommand

Inherits:
RpcCommand
  • Object
show all
Defined in:
lib/msf/core/rpc/json/v1_0/rpc_command.rb

Constant Summary collapse

METHOD_GROUP_SEPARATOR =
'.'
MODULE_EXECUTE_KEY =
'module.execute'
PAYLOAD_MODULE_TYPE_KEY =
'payload'
PAYLOAD_KEY =
'payload'

Instance Attribute Summary

Attributes inherited from RpcCommand

#execute_timeout, #framework

Instance Method Summary collapse

Constructor Details

#initialize(framework, execute_timeout: 7200) ⇒ RpcCommand

Instantiate an RpcCommand.

Parameters:

  • framework (Msf::Simple::Framework)

    Framework wrapper instance

  • execute_timeout (Integer) (defaults to: 7200)

    execute timeout duration in seconds


15
16
17
18
19
20
21
22
23
24
# File 'lib/msf/core/rpc/json/v1_0/rpc_command.rb', line 15

def initialize(framework, execute_timeout: 7200)
  super(framework, execute_timeout: execute_timeout)

  # The legacy Msf::RPC::Service will not be started, however, it will be used to proxy
  # requests to existing handlers. This frees the command from having to act as the
  # service to RPC_Base subclasses and expose accessors for tokens and users.
  @legacy_rpc_service	= ::Msf::RPC::Service.new(@framework, {
      execute_timeout: @execute_timeout
  })
end

Instance Method Details

#execute(method, params) ⇒ Object

Invokes the method on the receiver object with the specified params, returning the method's return value.

Parameters:

  • method (String)

    the RPC method name

  • params (Array, Hash)

    parameters for the RPC call


36
37
38
39
40
41
# File 'lib/msf/core/rpc/json/v1_0/rpc_command.rb', line 36

def execute(method, params)
  result = execute_internal(method, params)
  result = post_process_result(result, method, params)

  result
end

#register_method(method, name: nil) ⇒ Object

Raises:

  • (RuntimeError)

    The method is not implemented


27
28
29
# File 'lib/msf/core/rpc/json/v1_0/rpc_command.rb', line 27

def register_method(method, name: nil)
  raise "#{self.class.name}##{__method__} is not implemented"
end