class Rex::Proto::DCERPC::NDR

Public Class Methods

UniConformantArray(string) click to toggle source

Encode a byte array use to encode:

char  element_1
# File lib/rex/proto/dcerpc/ndr.rb, line 42
def self.UniConformantArray(string)
  warn 'should be using Rex::Encoder::NDR'
  return long(string.length) + string + align(string)
end
UnicodeConformantVaryingString(string) click to toggle source

Encode a string use to encode:

w_char *element_1;
# File lib/rex/proto/dcerpc/ndr.rb, line 50
def self.UnicodeConformantVaryingString(string)
  warn 'should be using Rex::Encoder::NDR'
  string += "\x00" # null pad
  return long(string.length) + long(0) + long(string.length) + Rex::Text.to_unicode(string) + align(Rex::Text.to_unicode(string))
end
UnicodeConformantVaryingStringPreBuilt(string) click to toggle source

Encode a string that is already unicode encoded use to encode:

w_char *element_1;
# File lib/rex/proto/dcerpc/ndr.rb, line 59
def self.UnicodeConformantVaryingStringPreBuilt(string)
  warn 'should be using Rex::Encoder::NDR'
  # if the string len is odd, thats bad!
  if string.length % 2 > 0
    string += "\x00"
  end
  len = string.length / 2;
  return long(len) + long(0) + long(len) + string + align(string)
end
align(string) click to toggle source

Provide padding to align the string to the 32bit boundary

# File lib/rex/proto/dcerpc/ndr.rb, line 10
def self.align(string)
  warn 'should be using Rex::Encoder::NDR'
  return "\x00" * ((4 - (string.length & 3)) & 3)
end
byte(string) click to toggle source

Encode a single byte use to encode:

byte element_1;
# File lib/rex/proto/dcerpc/ndr.rb, line 34
def self.byte(string)
  warn 'should be using Rex::Encoder::NDR'
  return [string].pack('C')
end
long(string) click to toggle source

Encode a 4 byte long use to encode:

long element_1;
# File lib/rex/proto/dcerpc/ndr.rb, line 18
def self.long(string)
  warn 'should be using Rex::Encoder::NDR'
  return [string].pack('V')
end
short(string) click to toggle source

Encode a 2 byte short use to encode:

short element_1;
# File lib/rex/proto/dcerpc/ndr.rb, line 26
def self.short(string)
  warn 'should be using Rex::Encoder::NDR'
  return [string].pack('v')
end