MCPcopy Index your code
hub / github.com/MorDavid/NetworkHound / _parse_binary_sid

Method _parse_binary_sid

NetworkHound.py:1236–1258  ·  view source on GitHub ↗

Parse binary SID to string format

(self, sid_bytes)

Source from the content-addressed store, hash-verified

1234 pass
1235
1236 def _parse_binary_sid(self, sid_bytes):
1237 """Parse binary SID to string format"""
1238 import struct
1239
1240 if len(sid_bytes) < 12:
1241 raise ValueError("SID too short")
1242
1243 # Parse SID structure
1244 revision = sid_bytes[0]
1245 sub_authority_count = sid_bytes[1]
1246 authority = struct.unpack('>Q', b'\x00\x00' + sid_bytes[2:8])[0]
1247
1248 # Build SID string
1249 sid_string = f"S-{revision}-{authority}"
1250
1251 # Parse sub-authorities (little-endian 32-bit integers)
1252 for i in range(sub_authority_count):
1253 offset = 8 + (i * 4)
1254 if offset + 4 <= len(sid_bytes):
1255 sub_auth = struct.unpack('<I', sid_bytes[offset:offset+4])[0]
1256 sid_string += f"-{sub_auth}"
1257
1258 return sid_string
1259
1260 def __getattr__(self, name):
1261 """Delegate other attributes to the impacket auth object"""

Callers 2

get_domain_infoMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected