MCPcopy Create free account
hub / github.com/secdev/scapy / StrNullField

Class StrNullField

scapy/fields.py:2215–2245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2213
2214
2215class StrNullField(StrField):
2216 DELIMITER = b"\x00"
2217
2218 def addfield(self, pkt, s, val):
2219 # type: (Packet, bytes, Optional[bytes]) -> bytes
2220 return s + self.i2m(pkt, val) + self.DELIMITER
2221
2222 def getfield(self,
2223 pkt, # type: Packet
2224 s, # type: bytes
2225 ):
2226 # type: (...) -> Tuple[bytes, bytes]
2227 len_str = 0
2228 while True:
2229 len_str = s.find(self.DELIMITER, len_str)
2230 if len_str < 0:
2231 # DELIMITER not found: return empty
2232 return b"", s
2233 if len_str % len(self.DELIMITER):
2234 len_str += 1
2235 else:
2236 break
2237 return s[len_str + len(self.DELIMITER):], self.m2i(pkt, s[:len_str])
2238
2239 def randval(self):
2240 # type: () -> RandTermString
2241 return RandTermString(RandNum(0, 1200), self.DELIMITER)
2242
2243 def i2len(self, pkt, x):
2244 # type: (Optional[Packet], Any) -> int
2245 return super(StrNullField, self).i2len(pkt, x) + 1
2246
2247
2248class StrNullFieldUtf16(StrNullField, StrFieldUtf16):

Callers 15

SOCKS4RequestClass · 0.90
ParameterStatusClass · 0.90
QueryClass · 0.90
ColumnDescriptionClass · 0.90
BindClass · 0.90
CloseClass · 0.90
DescribeClass · 0.90
ParseClass · 0.90
ExecuteClass · 0.90
HCI_Mon_System_NoteClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…