class Rex::Proto::DRDA::BASIC_DDM
Public Class Methods
new()
click to toggle source
# File lib/rex/proto/drda/packet.rb, line 131 def initialize self[:payload] = [] end
Public Instance Methods
read(str="")
click to toggle source
# File lib/rex/proto/drda/packet.rb, line 135 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_check()
click to toggle source
Just a quick test.
# File lib/rex/proto/drda/packet.rb, line 158 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_s()
click to toggle source
# File lib/rex/proto/drda/packet.rb, line 168 def to_s self.to_a.pack("nCCnnn") + self[:payload].map {|x| x.to_s}.join end