Class: Rex::Proto::DRDA::BASIC_DDM

Inherits:
Struct
  • Object
show all
Defined in:
lib/rex/proto/drda/packet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBASIC_DDM

Returns a new instance of BASIC_DDM.



132
133
134
# File 'lib/rex/proto/drda/packet.rb', line 132

def initialize
  self[:payload] = []
end

Instance Attribute Details

#codepointObject

Returns the value of attribute codepoint

Returns:

  • (Object)

    the current value of codepoint



130
131
132
# File 'lib/rex/proto/drda/packet.rb', line 130

def codepoint
  @codepoint
end

#correlidObject

Returns the value of attribute correlid

Returns:

  • (Object)

    the current value of correlid



130
131
132
# File 'lib/rex/proto/drda/packet.rb', line 130

def correlid
  @correlid
end

#formatObject

Returns the value of attribute format

Returns:

  • (Object)

    the current value of format



130
131
132
# File 'lib/rex/proto/drda/packet.rb', line 130

def format
  @format
end

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of length



130
131
132
# File 'lib/rex/proto/drda/packet.rb', line 130

def length
  @length
end

#length2Object

Returns the value of attribute length2

Returns:

  • (Object)

    the current value of length2



130
131
132
# File 'lib/rex/proto/drda/packet.rb', line 130

def length2
  @length2
end

#magicObject

Returns the value of attribute magic

Returns:

  • (Object)

    the current value of magic



130
131
132
# File 'lib/rex/proto/drda/packet.rb', line 130

def magic
  @magic
end

#payloadObject

Returns the value of attribute payload

Returns:

  • (Object)

    the current value of payload



130
131
132
# File 'lib/rex/proto/drda/packet.rb', line 130

def payload
  @payload
end

Instance Method Details

#read(str = "") ⇒ Object

Raises:



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/rex/proto/drda/packet.rb', line 136

def read(str="")
  self[:payload].clear
  raise DRDA::Error, "Input isn't a String." if !str.kind_of? String
  raise DRDA::RespError, "Response is too short." if str.size < 10
  (self[:length],self[:magic],self[:format],
   self[:correlid],self[:length2],self[:codepoint]) =
   str.unpack("nCCnnn")
  sanity_check
  rest = str[10,self[:length2]-4]
  i = 0
  while (i < rest.size)
    if self[:codepoint] == Constants::SQLCARD # These aren't DDM's.
      this_param = rest[i,self[:length]-10]
    else
      this_param = DDM_PARAM.new.read(rest[i,rest.size])
    end
    self[:payload] << this_param
    i += this_param.to_s.size
  end
  return self
end

#sanity_checkObject

Just a quick test.



159
160
161
162
163
164
165
166
167
# File 'lib/rex/proto/drda/packet.rb', line 159

def sanity_check
  if self[:length] < 10
    raise DRDA::RespError, "DDM Length is too short."
  elsif self[:length2] < 4
    raise DRDA::RespError, "DDM Length2 is too short."
  elsif self[:length]-6 != self[:length2]
    raise DRDA::RespError, "Codepoint: 0x#{self[:codepoint].to_s(16)} DDM Length2 (0x#{self[:length2].to_s(16)}) isn't six less than Length (0x#{self[:length].to_s(16)})"
  end
end

#to_sObject



169
170
171
# File 'lib/rex/proto/drda/packet.rb', line 169

def to_s
  self.to_a.pack("nCCnnn") + self[:payload].map {|x| x.to_s}.join
end