class Rex::Proto::Rmi::Model::CallData

This class provides a representation of an RMI return value

Attributes

arguments[RW]

@!attribute arguments

@return [Array] the returned exception or value according to code
hash[RW]

@!attribute hash

@return [Fixnum] On JDK 1.1 stub protocol the stub's interface hash. On JDK1.2 is a hash
  representing the method to call.
object_number[RW]

@!attribute object_number

@return [Fixnum] Random to identify the object being called
operation[RW]

@!attribute operation

@return [Fixnum] On JDK 1.1 stub protocol the operation index in the interface. On JDK 1.2
  it is -1.
uid[RW]

@!attribute uid

@return [Rex::Proto::Rmi::Model::UniqueIdentifier] unique identifier for the target to call

Public Instance Methods

decode(io) click to toggle source

Decodes the Rex::Proto::Rmi::Model::CallData from the input.

@param io [IO] the IO to read from @return [Rex::Proto::Rmi::Model::CallData]

# File lib/rex/proto/rmi/model/call_data.rb, line 44
def decode(io)
  stream = Rex::Java::Serialization::Model::Stream.decode(io)

  block_data = stream.contents[0]
  block_data_io = StringIO.new(block_data.contents, 'rb')

  self.object_number = decode_object_number(block_data_io)
  self.uid = decode_uid(block_data_io)
  self.operation = decode_operation(block_data_io)
  self.hash = decode_hash(block_data_io)
  self.arguments = []

  stream.contents[1..stream.contents.length - 1].each do |content|
    self.arguments << content
  end

  self
end
encode() click to toggle source

Encodes the Rex::Proto::Rmi::Model::CallData into an String.

@return [String]

# File lib/rex/proto/rmi/model/call_data.rb, line 30
def encode
  stream = Rex::Java::Serialization::Model::Stream.new
  block_data = Rex::Java::Serialization::Model::BlockData.new(nil, encode_object_number + encode_uid + encode_operation + encode_hash)

  stream.contents << block_data
  stream.contents += arguments

  stream.encode
end

Private Instance Methods

decode_hash(io) click to toggle source

Reads the hash from the IO

@param io [IO] the IO to read from @return [Fixnum]

# File lib/rex/proto/rmi/model/call_data.rb, line 99
def decode_hash(io)
  hash = read_long(io)

  hash
end
decode_object_number(io) click to toggle source

Reads the object number from the IO

@param io [IO] the IO to read from @return [Fixnum]

# File lib/rex/proto/rmi/model/call_data.rb, line 69
def decode_object_number(io)
  object_number = read_long(io)

  object_number
end
decode_operation(io) click to toggle source

Reads the operation from the IO

@param io [IO] the IO to read from @return [Fixnum]

# File lib/rex/proto/rmi/model/call_data.rb, line 89
def decode_operation(io)
  operation = read_int(io)

  operation
end
decode_uid(io) click to toggle source

Reads and deserializes the uid from the IO

@param io [IO] the IO to read from @return [Rex::Proto::Rmi::Model::UniqueIdentifier]

# File lib/rex/proto/rmi/model/call_data.rb, line 79
def decode_uid(io)
  uid = Rex::Proto::Rmi::Model::UniqueIdentifier.decode(io)

  uid
end
encode_hash() click to toggle source

Encodes the hash field

@return [String]

# File lib/rex/proto/rmi/model/call_data.rb, line 129
def encode_hash
  [hash].pack('q>')
end
encode_object_number() click to toggle source

Encodes the code field

@return [String]

# File lib/rex/proto/rmi/model/call_data.rb, line 108
def encode_object_number
  [object_number].pack('q>')
end
encode_operation() click to toggle source

Encodes the operation field

@return [String]

# File lib/rex/proto/rmi/model/call_data.rb, line 122
def encode_operation
  [operation].pack('l>')
end
encode_uid() click to toggle source

Encodes the uid field

@return [String]

# File lib/rex/proto/rmi/model/call_data.rb, line 115
def encode_uid
  uid.encode
end