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

Class WINNT_SID

scapy/layers/smb2.py:785–830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

783
784
785class WINNT_SID(Packet):
786 fields_desc = [
787 ByteField("Revision", 1),
788 FieldLenField("SubAuthorityCount", None, count_of="SubAuthority", fmt="B"),
789 PacketField(
790 "IdentifierAuthority",
791 WINNT_SID_IDENTIFIER_AUTHORITY(),
792 WINNT_SID_IDENTIFIER_AUTHORITY,
793 ),
794 FieldListField(
795 "SubAuthority",
796 [0],
797 LEIntField("", 0),
798 count_from=lambda pkt: pkt.SubAuthorityCount,
799 ),
800 ]
801
802 def default_payload_class(self, payload):
803 return conf.padding_layer
804
805 _SID_REG = re.compile(r"^S-(\d)-(\d+)((?:-\d+)*)$")
806
807 @staticmethod
808 def fromstr(x):
809 m = WINNT_SID._SID_REG.match(x)
810 if not m:
811 raise ValueError("Invalid SID format !")
812 rev, authority, subauthority = m.groups()
813 return WINNT_SID(
814 Revision=int(rev),
815 IdentifierAuthority=WINNT_SID_IDENTIFIER_AUTHORITY(
816 Value=struct.pack(">Q", int(authority))[2:]
817 ),
818 SubAuthority=[int(x) for x in subauthority[1:].split("-")],
819 )
820
821 def summary(self):
822 return "S-%s-%s%s" % (
823 self.Revision,
824 struct.unpack(">Q", b"\x00\x00" + self.IdentifierAuthority.Value)[0],
825 (
826 ("-%s" % "-".join(str(x) for x in self.SubAuthority))
827 if self.SubAuthority
828 else ""
829 ),
830 )
831
832
833# https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers

Callers 8

_build_sidMethod · 0.90
_format_attributeMethod · 0.90
UPN_DNS_INFOClass · 0.90
PAC_REQUESTOR_SIDClass · 0.90
fromstrMethod · 0.85
SECURITY_DESCRIPTORClass · 0.85

Calls 6

ByteFieldClass · 0.90
FieldLenFieldClass · 0.90
PacketFieldClass · 0.90
FieldListFieldClass · 0.90
LEIntFieldClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…