MCPcopy Index your code
hub / github.com/secdev/scapy / LDAP_SASL_Buffer

Class LDAP_SASL_Buffer

scapy/layers/ldap.py:1677–1710  ·  view source on GitHub ↗

RFC 4422 sect 3.7

Source from the content-addressed store, hash-verified

1675
1676
1677class LDAP_SASL_Buffer(Packet):
1678 """
1679 RFC 4422 sect 3.7
1680 """
1681
1682 # "Each buffer of protected data is transferred over the underlying
1683 # transport connection as a sequence of octets prepended with a four-
1684 # octet field in network byte order that represents the length of the
1685 # buffer."
1686
1687 fields_desc = [
1688 FieldLenField("BufferLength", None, fmt="!I", length_of="Buffer"),
1689 _GSSAPI_Field("Buffer", LDAP),
1690 ]
1691
1692 def hashret(self):
1693 return b"ldap"
1694
1695 def answers(self, other):
1696 return isinstance(other, LDAP_SASL_Buffer)
1697
1698 @classmethod
1699 def tcp_reassemble(cls, data, *args, **kwargs):
1700 if len(data) < 4:
1701 return None
1702 if data[0] == 0x30:
1703 # Add a heuristic to detect LDAP errors
1704 xlen, x = BER_len_dec(BER_id_dec(data)[1])
1705 if xlen and xlen == len(x):
1706 return LDAP(data)
1707 # Check BufferLength
1708 length = struct.unpack("!I", data[:4])[0] + 4
1709 if len(data) >= length:
1710 return cls(data)
1711
1712
1713class LDAP_Exception(RuntimeError):

Callers 1

sr1Method · 0.85

Calls 2

FieldLenFieldClass · 0.90
_GSSAPI_FieldClass · 0.90

Tested by

no test coverage detected