-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC_SID structure does not match the MS documentation #1386
Comments
Hi @Dramelac! AFAIK the
I think the most appropriate is to use the RPC_SID structure. I found that using it with the |
Hi @0xdeaddood ! Although it works well to generate a new PAC ticket, this quick fix is problematic when you want to parse an existing But generally with your workaround, if we want to parse a kerberos ticket with the impakcet lib, we will have a bug every time... and a qucik & dirty fix will be needed everytime :/ which is not ideal for a lib that is supposed to be reliable but that's my opinion PoC: # Ticket generation
pacRequestor = PAC_REQUESTOR()
pacRequestor['UserSid'].fromCanonical('S-1-5-21-4088429403-1159899800-2753317549-1108')
pacData = pacRequestor.getData()[4:]
# Ticket parsing
PAC_REQUESTOR(pacData)['UserSid'].formatCanonical() # Return S-0-0 because of the missing 4 bits.. The quick & dirty fix should be someting like that: PAC_REQUESTOR(b'\x05\x00\x00\x00'+pacData)['UserSid'].formatCanonical() But thats not a very elegant solution because the \x05 byte can change depending on the SID .. PAC_REQUESTOR(pacData[1:5]+pacData)['UserSid'].formatCanonical() |
I can also add that this behavior of RPC_SID impacts other cases than kerberos and I have already heard here and there about using the LDAP_SID structure in workaround, it might be time to create a sustainable solution that correctly implements the SID for all present and future uses and stop using LDAP_SID as a quick & dirty fix |
Hi @Dramelac! Thanks again for all your work in this issue and the extra-pac implementation! After double checking the MS-PAC standard, I found that the PAC_REQUESTOR structure contains a single
So, as you mentioned before, the best solution is to create a new SID structure for use in non-RPC protocols. That structure is defined in the I opened #1545 with this new structure and the modifications in ticketer. |
Fixed in #1545 Closing |
Configuration
impacket version: Impacket v0.10.1.dev1+20220830.171426.b74c9e1e
Python version: Python 3.9.2
Target OS: Debian 11
Context
The data generated by
impacket.dcerpc.v5.dtypes.RPC_SID.getData()
does not correspond to the structure documented by Microsoft https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/f992ad60-0fe4-4b87-9fed-beb478836861According to the MS documentation, the first byte should be the Revision byte but impacket seems to duplicate the SubAuthorityCount at the right place AND at the beginning of the packet.
It should have come out with this result:
b'\x01\x05\x00\x00\x00\x00\x00\x05\x15\x00\x00\x00\xacv\x1d*q\x82[\x88h"\xa7Z\xe8\x03\x00\x00'
Same error for the parsing:
Is there a reason why this structure behaves like this in impacket or is it a mistake?
Waiting for an answer / correction, I was able to use the equivalent LDAP implementation (
impacket.ldap.ldaptypes.LDAP_SID
) which behaves correctly.Thank you
The text was updated successfully, but these errors were encountered: