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

Function _NTLM_post_build

scapy/layers/ntlm.py:370–403  ·  view source on GitHub ↗

Util function to build the offset and populate the lengths

(self, p, pay_offset, fields, config=_NTLM_CONFIG)

Source from the content-addressed store, hash-verified

368
369
370def _NTLM_post_build(self, p, pay_offset, fields, config=_NTLM_CONFIG):
371 """Util function to build the offset and populate the lengths"""
372 for field_name, value in self.fields[self._NTLM_PAYLOAD_FIELD_NAME]:
373 fld = self.get_field(self._NTLM_PAYLOAD_FIELD_NAME).fields_map[field_name]
374 length = fld.i2len(self, value)
375 count = fld.i2count(self, value)
376 offset = fields[field_name]
377 i = 0
378 r = lambda y: {2: "H", 4: "I", 8: "Q"}[y]
379 for fname, ftype in config:
380 if isinstance(ftype, dict):
381 ftype = ftype[field_name]
382 if ftype & _NTLM_ENUM.LEN:
383 fval = length
384 elif ftype & _NTLM_ENUM.OFFSET:
385 fval = pay_offset
386 elif ftype & _NTLM_ENUM.MAXLEN:
387 fval = length
388 elif ftype & _NTLM_ENUM.COUNT:
389 fval = count
390 else:
391 raise ValueError
392 if ftype & _NTLM_ENUM.PAD8:
393 fval += (-fval) % 8
394 sz = self.get_field(field_name + fname).sz
395 if self.getfieldval(field_name + fname) is None:
396 p = (
397 p[: offset + i]
398 + struct.pack("<%s" % r(sz), fval)
399 + p[offset + i + sz :]
400 )
401 i += sz
402 pay_offset += length
403 return p
404
405
406##############

Callers 10

post_buildMethod · 0.90
_SMB2_post_buildFunction · 0.90
post_buildMethod · 0.90
post_buildMethod · 0.90
post_buildMethod · 0.90
post_buildMethod · 0.90
post_buildMethod · 0.90
post_buildMethod · 0.85
post_buildMethod · 0.85
post_buildMethod · 0.85

Calls 4

get_fieldMethod · 0.80
i2lenMethod · 0.45
i2countMethod · 0.45
getfieldvalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…