Class: Rex::Java::Serialization::Model::NewClass

Inherits:
Element
  • Object
show all
Includes:
Contents
Defined in:
lib/rex/java/serialization/model/new_class.rb

Overview

This class provides a NewArray (Java Array) representation

Constant Summary

Constants included from Rex::Java::Serialization

BASE_WIRE_HANDLE, OBJECT_TYPE_CODES, PRIMITIVE_TYPE_CODES, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, TC_ARRAY, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING, TYPE_CODES

Instance Attribute Summary collapse

Attributes inherited from Element

#stream

Instance Method Summary collapse

Methods included from Contents

#decode_content, #encode_content, #print_class, #print_content

Methods inherited from Element

decode

Constructor Details

#initialize(stream = nil) ⇒ NewClass

Returns a new instance of NewClass.

Parameters:



17
18
19
20
# File 'lib/rex/java/serialization/model/new_class.rb', line 17

def initialize(stream = nil)
  super(stream)
  self.class_description = nil
end

Instance Attribute Details

#array_descriptionJava::Serialization::Model::ClassDesc

Returns The description of the class.

Returns:



14
# File 'lib/rex/java/serialization/model/new_class.rb', line 14

attr_accessor :class_description

#class_descriptionObject

Returns the value of attribute class_description.



14
15
16
# File 'lib/rex/java/serialization/model/new_class.rb', line 14

def class_description
  @class_description
end

Instance Method Details

#decode(io) ⇒ self

Deserializes a Rex::Java::Serialization::Model::NewClass

Parameters:

  • io (IO)

    the io to read from

Returns:

  • (self)

    if deserialization succeeds

Raises:



27
28
29
30
31
32
# File 'lib/rex/java/serialization/model/new_class.rb', line 27

def decode(io)
  self.class_description = ClassDesc.decode(io, stream)
  stream.add_reference(self) unless stream.nil?

  self
end

#encodeString

Serializes the Rex::Java::Serialization::Model::NewClass

Returns:

  • (String)

    if serialization succeeds

Raises:



38
39
40
41
42
43
44
45
# File 'lib/rex/java/serialization/model/new_class.rb', line 38

def encode
  unless class_description.kind_of?(ClassDesc)
    raise Rex::Java::Serialization::EncodeError, 'Failed to serialize NewClass'
  end

  encoded = ''
  encoded << class_description.encode
end

#to_sString

Creates a print-friendly string representation

Returns:

  • (String)


50
51
52
# File 'lib/rex/java/serialization/model/new_class.rb', line 50

def to_s
  print_content(class_description)
end