Class: Rex::Proto::DCERPC::NDR

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/proto/dcerpc/ndr.rb

Class Method Summary collapse

Class Method Details

.align(string) ⇒ Object

Provide padding to align the string to the 32bit boundary



11
12
13
14
# File 'lib/rex/proto/dcerpc/ndr.rb', line 11

def self.align(string)
  warn 'should be using Rex::Encoder::NDR'
  return "\x00" * ((4 - (string.length & 3)) & 3)
end

.byte(string) ⇒ Object

Encode a single byte use to encode:

byte element_1;


35
36
37
38
# File 'lib/rex/proto/dcerpc/ndr.rb', line 35

def self.byte(string)
  warn 'should be using Rex::Encoder::NDR'
  return [string].pack('C')
end

.long(string) ⇒ Object

Encode a 4 byte long use to encode:

long element_1;


19
20
21
22
# File 'lib/rex/proto/dcerpc/ndr.rb', line 19

def self.long(string)
  warn 'should be using Rex::Encoder::NDR'
  return [string].pack('V')
end

.short(string) ⇒ Object

Encode a 2 byte short use to encode:

short element_1;


27
28
29
30
# File 'lib/rex/proto/dcerpc/ndr.rb', line 27

def self.short(string)
  warn 'should be using Rex::Encoder::NDR'
  return [string].pack('v')
end

.UnicodeConformantVaryingString(string) ⇒ Object

Encode a string use to encode:

w_char *element_1;


51
52
53
54
55
# File 'lib/rex/proto/dcerpc/ndr.rb', line 51

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) ⇒ Object

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

w_char *element_1;


60
61
62
63
64
65
66
67
68
# File 'lib/rex/proto/dcerpc/ndr.rb', line 60

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

.UniConformantArray(string) ⇒ Object

Encode a byte array use to encode:

char  element_1


43
44
45
46
# File 'lib/rex/proto/dcerpc/ndr.rb', line 43

def self.UniConformantArray(string)
  warn 'should be using Rex::Encoder::NDR'
  return long(string.length) + string + align(string)
end