class Rex::Proto::Rmi::Model::ReturnValue
This class provides a representation of an RMI return value
Attributes
code[RW]
@!attribute code
@return [Fixnum] the return code
uid[RW]
@!attribute uid
@return [Rex::Proto::Rmi::Model::UniqueIdentifier] unique identifier of the returned value
value[RW]
@!attribute value
@return [Array] the returned exception or value according to code
Public Instance Methods
decode(io)
click to toggle source
Decodes the Rex::Proto::Rmi::Model::ReturnValue
from the input.
@param io [IO] the IO
to read from @return [Rex::Proto::Rmi::Model::ReturnValue]
# File lib/rex/proto/rmi/model/return_value.rb, line 38 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.code = decode_code(block_data_io) self.uid = decode_uid(block_data_io) self.value = [] stream.contents[1..stream.contents.length - 1].each do |content| self.value << content end self end
encode()
click to toggle source
Encodes the Rex::Proto::Rmi::Model::ReturnValue
into an String.
@return [String]
# File lib/rex/proto/rmi/model/return_value.rb, line 22 def encode stream = Rex::Java::Serialization::Model::Stream.new block_data = Rex::Java::Serialization::Model::BlockData.new(nil, encode_code + encode_uid) stream.contents << block_data value.each do |v| stream.contents << v end stream.encode end
get_class_name()
click to toggle source
The object/exception class of the returned value
@return [String, NilClass] the returned value class, nil it cannot be retrieved
# File lib/rex/proto/rmi/model/return_value.rb, line 65 def get_class_name unless value[0] && value[0].is_a?(Rex::Java::Serialization::Model::NewObject) return nil end case value[0].class_desc.description when Rex::Java::Serialization::Model::NewClassDesc return value[0].class_desc.description.class_name.contents when Rex::Java::Serialization::Model::ProxyClassDesc return value[0].class_desc.description.interfaces[0].contents else return nil end end
is_exception?()
click to toggle source
Answers if the ReturnValue
is an exception
@return [Boolean]
# File lib/rex/proto/rmi/model/return_value.rb, line 58 def is_exception? code == RETURN_EXCEPTION end
Private Instance Methods
decode_code(io)
click to toggle source
Reads the return code from the IO
@param io [IO] the IO
to read from @return [String] @raise [Rex::Proto::Rmi::DecodeError] if fails to decode the return code
# File lib/rex/proto/rmi/model/return_value.rb, line 87 def decode_code(io) code = read_byte(io) unless code == RETURN_VALUE || code == RETURN_EXCEPTION raise Rex::Proto::Rmi::DecodeError, 'Failed to decode the ReturnValue code' end code end
decode_uid(io)
click to toggle source
encode_code()
click to toggle source
Encodes the code field
@return [String]
# File lib/rex/proto/rmi/model/return_value.rb, line 109 def encode_code [code].pack('c') end
encode_uid()
click to toggle source
Encodes the uid field
@return [String]
# File lib/rex/proto/rmi/model/return_value.rb, line 116 def encode_uid uid.encode end