Class: Rex::Proto::Rmi::Model::ReturnValue
- Defined in:
- lib/rex/proto/rmi/model/return_value.rb
Overview
This class provides a representation of an RMI return value
Constant Summary
Constants included from Rex::Proto::Rmi::Model
CALL_MESSAGE, DGC_ACK_MESSAGE, MULTIPLEX_PROTOCOL, PING_ACK, PING_MESSAGE, PROTOCOL_ACK, PROTOCOL_NOT_SUPPORTED, RETURN_DATA, RETURN_EXCEPTION, RETURN_VALUE, SIGNATURE, SINGLE_OP_PROTOCOL, STREAM_PROTOCOL
Instance Attribute Summary collapse
-
#code ⇒ Integer
The return code.
-
#uid ⇒ Rex::Proto::Rmi::Model::UniqueIdentifier
Unique identifier of the returned value.
-
#value ⇒ Array
The returned exception or value according to code.
Instance Method Summary collapse
-
#decode(io) ⇒ Rex::Proto::Rmi::Model::ReturnValue
Decodes the Rex::Proto::Rmi::Model::ReturnValue from the input.
-
#encode ⇒ String
Encodes the Rex::Proto::Rmi::Model::ReturnValue into an String.
-
#get_class_name ⇒ String, NilClass
The object/exception class of the returned value.
-
#is_exception? ⇒ Boolean
Answers if the ReturnValue is an exception.
Methods inherited from Element
attr_accessor, attributes, #attributes, decode, #initialize
Constructor Details
This class inherits a constructor from Rex::Proto::Rmi::Model::Element
Instance Attribute Details
#code ⇒ Integer
Returns the return code.
12 13 14 |
# File 'lib/rex/proto/rmi/model/return_value.rb', line 12 def code @code end |
#uid ⇒ Rex::Proto::Rmi::Model::UniqueIdentifier
Returns unique identifier of the returned value.
15 16 17 |
# File 'lib/rex/proto/rmi/model/return_value.rb', line 15 def uid @uid end |
#value ⇒ Array
Returns the returned exception or value according to code.
18 19 20 |
# File 'lib/rex/proto/rmi/model/return_value.rb', line 18 def value @value end |
Instance Method Details
#decode(io) ⇒ Rex::Proto::Rmi::Model::ReturnValue
Decodes the Rex::Proto::Rmi::Model::ReturnValue from the input.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rex/proto/rmi/model/return_value.rb', line 39 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 ⇒ String
Encodes the Rex::Proto::Rmi::Model::ReturnValue into an String.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rex/proto/rmi/model/return_value.rb', line 23 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 ⇒ String, NilClass
The object/exception class of the returned value
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rex/proto/rmi/model/return_value.rb', line 66 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? ⇒ Boolean
Answers if the ReturnValue is an exception
59 60 61 |
# File 'lib/rex/proto/rmi/model/return_value.rb', line 59 def is_exception? code == RETURN_EXCEPTION end |