# Impacket - Collection of Python classes for working with network protocols. # # Copyright Fortra, LLC and its affiliated companies # # All rights reserved. # # This software is provided under a slightly modified version # of the Apache Software License. See the accompanying LICENSE file # for more information. # # Description: # [MS-PAC] Implementation # # Author: # Alberto Solino (@agsolino) # from impacket.dcerpc.v5.dtypes import ULONG, RPC_UNICODE_STRING, FILETIME, PRPC_SID, USHORT, RPC_SID, SID from impacket.dcerpc.v5.ndr import NDRSTRUCT, NDRUniConformantArray, NDRPOINTER from impacket.dcerpc.v5.nrpc import USER_SESSION_KEY, CHAR_FIXED_8_ARRAY, PUCHAR_ARRAY, PRPC_UNICODE_STRING_ARRAY from impacket.dcerpc.v5.rpcrt import TypeSerialization1 from impacket.ldap.ldaptypes import LDAP_SID from impacket.structure import Structure ################################################################################ # CONSTANTS ################################################################################ # From https://msdn.microsoft.com/library/aa302203#msdn_pac_credentials # and http://diswww.mit.edu/menelaus.mit.edu/cvs-krb5/25862 PAC_LOGON_INFO = 1 PAC_CREDENTIALS_INFO = 2 PAC_SERVER_CHECKSUM = 6 PAC_PRIVSVR_CHECKSUM = 7 PAC_CLIENT_INFO_TYPE = 10 PAC_DELEGATION_INFO = 11 PAC_UPN_DNS_INFO = 12 PAC_ATTRIBUTES_INFO = 17 PAC_REQUESTOR_INFO = 18 ################################################################################ # STRUCTURES ################################################################################ PISID = PRPC_SID # 2.2.1 KERB_SID_AND_ATTRIBUTES class KERB_SID_AND_ATTRIBUTES(NDRSTRUCT): structure = ( ('Sid', PISID), ('Attributes', ULONG), ) class KERB_SID_AND_ATTRIBUTES_ARRAY(NDRUniConformantArray): item = KERB_SID_AND_ATTRIBUTES class PKERB_SID_AND_ATTRIBUTES_ARRAY(NDRPOINTER): referent = ( ('Data', KERB_SID_AND_ATTRIBUTES_ARRAY), ) # 2.2.2 GROUP_MEMBERSHIP from impacket.dcerpc.v5.nrpc import PGROUP_MEMBERSHIP_ARRAY # 2.2.3 DOMAIN_GROUP_MEMBERSHIP class DOMAIN_GROUP_MEMBERSHIP(NDRSTRUCT): structure = ( ('DomainId', PISID), ('GroupCount', ULONG), ('GroupIds', PGROUP_MEMBERSHIP_ARRAY), ) class DOMAIN_GROUP_MEMBERSHIP_ARRAY(NDRUniConformantArray): item = DOMAIN_GROUP_MEMBERSHIP class PDOMAIN_GROUP_MEMBERSHIP_ARRAY(NDRPOINTER): referent = ( ('Data', KERB_SID_AND_ATTRIBUTES_ARRAY), ) # 2.3 PACTYPE class PACTYPE(Structure): structure = ( ('cBuffers', '