Class: Rex::Proto::DRDA::Packet::BASIC_DDM
- Inherits:
-
Struct
- Object
- Struct
- Rex::Proto::DRDA::Packet::BASIC_DDM
- Defined in:
- lib/rex/proto/drda/packet.rb
Instance Attribute Summary collapse
-
#codepoint ⇒ Object
Returns the value of attribute codepoint.
-
#correlid ⇒ Object
Returns the value of attribute correlid.
-
#format ⇒ Object
Returns the value of attribute format.
-
#length ⇒ Object
Returns the value of attribute length.
-
#length2 ⇒ Object
Returns the value of attribute length2.
-
#magic ⇒ Object
Returns the value of attribute magic.
-
#payload ⇒ Object
Returns the value of attribute payload.
Instance Method Summary collapse
-
#initialize ⇒ BASIC_DDM
constructor
A new instance of BASIC_DDM.
- #read(str = "") ⇒ Object
-
#sanity_check ⇒ Object
Just a quick test.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ BASIC_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
#codepoint ⇒ Object
Returns the value of attribute codepoint
130 131 132 |
# File 'lib/rex/proto/drda/packet.rb', line 130 def codepoint @codepoint end |
#correlid ⇒ Object
Returns the value of attribute correlid
130 131 132 |
# File 'lib/rex/proto/drda/packet.rb', line 130 def correlid @correlid end |
#format ⇒ Object
Returns the value of attribute format
130 131 132 |
# File 'lib/rex/proto/drda/packet.rb', line 130 def format @format end |
#length ⇒ Object
Returns the value of attribute length
130 131 132 |
# File 'lib/rex/proto/drda/packet.rb', line 130 def length @length end |
#length2 ⇒ Object
Returns the value of attribute length2
130 131 132 |
# File 'lib/rex/proto/drda/packet.rb', line 130 def length2 @length2 end |
#magic ⇒ Object
Returns the value of attribute magic
130 131 132 |
# File 'lib/rex/proto/drda/packet.rb', line 130 def magic @magic end |
#payload ⇒ Object
Returns the value of attribute payload
130 131 132 |
# File 'lib/rex/proto/drda/packet.rb', line 130 def payload @payload end |
Instance Method Details
#read(str = "") ⇒ Object
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] == Rex::Proto::DRDA::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 ⇒ Object
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_s ⇒ Object
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 |