-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support for Kerberos TGS etype 17/18 #2809
Comments
I haven't seen any proof (or proof-of-concept) that doing this is possible. Also see my comments in PR #2822. |
@elitest Do you have any proof (or proof-of-concept) that |
@kholia Great question. So it is possible to to generate the hashes against correctly configured accounts. To configure service accounts correctly set As to whether or not the hashes will crack. I don't have any PoC that cracks an AES kerberos ticket, however my understanding of the RFCs and MS-KILE lead me to believe that the TGS-REP is encrypted with the RC4 hash(NTLM in the case of AD) the same way that AES does with the respective keys(AES128 and AES256). One other issue specific to john, is that I believe john's TGS hash format will need to be modified or something as it doesn't specify which type of crypto is used, whereas hashcat's format does. Let me know if you have any other further questions or if I can help in any way. |
This particular problem is easy to solve. |
Maybe @gentilkiwi, @PyroTek3, @Fist0urs, and @HarmJ0y have something to say on this topic (i.e. Kerberoasting of etype 17 and 18 "hashes" instead of etype 23). It seems that solving this problem will require some amount of reversing / low-level debugging of Kerberos functionality on Windows platform. |
Low Level Debug ? If I remember well, type 17 or 18 are standards. |
@gentilkiwi Thanks for taking a look at this stuff! 👍 I have the We need to figure out the HMAC key derivation part (which is involved in the SHA1 checksum calculation). This will also involve figuring out the correct value of [1] https://github.com/kholia/JohnTheRipper/tree/TGS-ng (see |
Did you take a look in: https://www.ietf.org/rfc/rfc3962.txt ? |
Yes, we have already implemented this entire RFC in the
Yes, @Fist0urs implemented this technique in |
Here are some rough ideas on how further progress can be made. Please note that I am not sure if this approach is even correct. I suspect that Kerberos functionality is provided by lsasrv.dll on Windows. WinDbg can be attached to the LSASS process, and various functions present in lsasrv.dll can be traced. In particular, tracing of input + output data from LspRC4EncryptData, LspAES256EncryptData, rijndaelEncrypt128, rijndaelEncrypt256, LspAES256DecryptData and related functions needs to be done. Tracing LspRC4EncryptData will act as a verifier for this approach. We should see the NT hash coming in as the RC4 key while tracing the LspRC4EncryptData function. After that, I would like to see the actual AES key being used to encrypt the TGS stuff. The output of AES encryption needs to be compared to the data in the TGS-REP packet we see on the wire. The https://blogs.msdn.microsoft.com/spatdsg/2005/12/27/debugging-lsass-oh-what-fun-it-is-to-ride/ should be useful here. For function tracing, ideas from https://labs.mwrinfosecurity.com/blog/heap-tracing-with-windbg-and-python/ can be used. |
@kholia What would happen if we just decrypted a bunch of TGS-REPs... shouldn't we get something formatted as ASN1 if the decryption worked? |
@elitest Yes, that is correct. https://adsecurity.org/?p=2293 says, "The TGS is encrypted using the target service accounts’ NTLM password hash and sent to the user (TGS-REP)". This is what makes Kerberoasting attacks possible. The code in In case of etype 17/18, I have the AES key derivation part working. This matches the Current code -> https://github.com/kholia/JohnTheRipper/tree/TGS-ng (see crypt_all from the top commit, filename is krb5_tgs_fmt_plug.c) |
So far no one has been able to prove that this task/technique is possible. |
@kholia this is something I want to see if we can revisit - the code you at the |
Thanks for looking into this stuff @HarmJ0y 👍 https://github.com/kholia/JohnTheRipper/tree/TGS-ng I have restored this branch now (I don't know how/why it was gone earlier). |
Hi guys, I've been discussing with @skelsec at offensivecon. I planned to reverse stuff to implement it (as I did for the RC4 part) but he told me that he already made a script that implements the algorithm. I guess he can share it here so that it will be implemented? As @kholia has already started the jtr part maybe I could stick to the hashcat part? So that we'll have it both jtr and hashcat implementations 👍 Cheers! |
I put together a poc script alongside with some test cases of TGS ticket decryption for etype17/18. Note: most of the encryption-decryption part was originally coming from impacket, I just ported it to py3 and dissected the AES it into a single file and added some comments. |
@kholia, the input hash formats accepted for the 23 enctype are as follows: Unfortunately 17/18 require the user + realm in order to create a salt, so we must include them in the input hash. I suggest to adopt these input formats:
Are you okay with that? |
@Fist0urs Sure. It would be nice to update the associated helpers tools (like Thanks for handling this 👍 Update: Hopefully, I will be back in action in some weeks :) |
I'll update the associated helpers tools yes! Take your time for the code, I'll have to dive into hashcat code first to remember it so this is not urgent 😄 |
Sure. Please go for it. Create a small PR and I will review it asap.
This would be awesome, thanks! I don't remember most of this Kerberos stuff these days! |
Ok, I've implemented it in hashcat (hashcat/hashcat#1955) Next step is implementing here. Regarding the input format I adopted this:
I enclosed user and realm within '$' and spn within '*' as user and realm are mandatory and spn is optionnal (not taken into account while computing the hash). PR to adapt the hash format (+ correction) was accepted in impacket: fortra/impacket#584 I'll also commit a "HOWTO" regarding Kerberos in jtr. I tried to comment a lot the hashcat code so that it would be easier to implement these hash formats within john, if I'm not the one who implements it. |
Go for it @Fist0urs 👍 It might be a while before I am back in action. |
Any chance this could get a bump? Ran into this exact thing and see that hashcat now supports 19700. |
I've just added this to a milestone, but I didn't look into the actual issue and I expect that only @Fist0urs might contribute anything in this area soon. |
Hi there! Sorry I've been really busy lately... I'll try to take a look in the upcoming month :) |
It seems that hashcat's 19700 module is broken and doesn't actually crack real hashes. Sample hash: hashes.txt Password is Pcap for the same setup: W2019DC-hello-test@123-TGS-REP.pcapng.txt - hash may be different due to a different impacket "session".
Related: https://twitter.com/hashcat/status/1105909927825104896. |
CC @Fist0urs and @jsteube - Context is #2809 (comment). |
Hello,
|
Looks like @kholia had a working format but never created a PR, and now that branch is gone in his repo 😢 |
Damm, was felling luck I could try cracking some Kerberos tickets with John ... Meanwhile, I also have the following hash format Kerberos 5 TGS etype 18 with a 32 bits checksum instead of 24 like the sample from @kholia . This was captured from a Windows 2016 Server using Invoke-Kerberoast.ps1 from @HarmJ0y ... I know its not related to JtR but wondering if anyone in this thread knows if this is a different format? (also unable to load it into hashcat)
|
Also known as aes-cts-hmac-sha1-96. The existing krb5tgs formats are for etype 23 (rc4-hmac) and too different from 17/18 that it would be relevant to add this functionality to them. Also add "cost" notion of etype for a few existing formats, and changed their benchmark to etype 17 instead of some unknown mix of etypes. Closes openwall#2809
Also known as aes-cts-hmac-sha1-96. The existing krb5tgs formats are for etype 23 (rc4-hmac) and too different from 17/18 that it would be relevant to add this functionality to them. Also add "cost" notion of etype for a few existing formats, and changed their benchmark to etype 17 instead of some unknown mix of etypes. Closes #2809
hashcat/hashcat#1384
The text was updated successfully, but these errors were encountered: