Skip to content
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

Add ul_type 12 (UPN and DNS info) to pac bindata #17603

Merged
merged 1 commit into from
Feb 8, 2023

Conversation

dwelch-r7
Copy link
Contributor

@dwelch-r7 dwelch-r7 commented Feb 6, 2023

Adds supported for the UPN and DNS info pac structure documented here: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-pac/1c0d6e11-6443-4846-b744-f9f810a504eb

Bumped bindata version to include the fix from here: dmendel/bindata#149 (comment)

I tested around trying to make it so that when you didn't need to manually remember to call set_offsets! before writing out the UPN and DNS info element but I couldn't find a nice way of doing that which wouldn't also have the side effect of potentially altering the existing values at the time of reading the ticket, so I've just left it in a similar way to the Pac itself

Validation

  • CI passes
  • run the inspect ticket module against a ccache/kirbi containing the UPN and DNS info element

Example of a kirbi file in base64 with the extended UPN and DNS info included

doIFbTCCBWmgAwIBBaEDAgEWooIEZTCCBGFhggRdMIIEWaADAgEFoREbD1dJTkRPTUFJTi5MT0NBTKIp
MCegAwIBAqEgMB4bBGNpZnMbFmRjMjAxOS53aW5kb21haW4ubG9jYWyjggQSMIIEDqADAgEXoQMCAQOi
ggQABIID/DN1zTi+AIX9ekmkuGT7Rww/9Aikd7WC3SC6qNzGvfYjL20h04Em5iAiy+m1C12a1Z+0yA0h
XmxvDpma65wOEuxj+aunTDnXkYzPXNetp8n4dXtYvw4FVcE+9Y4o4PgshkdgMZJiJb0hzqCAfCTiTgMU
Yd5ZwUAmwP6ikTYJk6FY31a9xM67lXpE5hWmLYDwsnJby6P0uCuwNNrkYr3nLGbPolQoMO/Wr9mHK/ty
zzrWCmcRvbA+rlyV8Hy16YDMvdy4Mk40Hve7AVNbIoOO9j5hffSlEbzCMGMDqXEKZWBmg93aAWsDNZFS
n2KF3N1A9jv37q/jvEM3CBcZ5fYWQjemZ2s69alm/7HuMqL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IEEPNKmCn0rEfa
UUhidlvInL6hERsPV0lORE9NQUlOLkxPQ0FMohEwD6ADAgEBoQgwBhsEdGVzdKMHAwUAQKAAAKQRGA8y
MDIzMDIwMjEzMDYzMVqlERgPMjAyMzAyMDIxMzA2MzFaphEYDzIwMjMwMjAyMjMwNjMxWqcRGA8yMDIz
MDIwOTEzMDYzMVqoERsPV0lORE9NQUlOLkxPQ0FMqSkwJ6ADAgECoSAwHhsEY2lmcxsWZGMyMDE5Lndp
bmRvbWFpbi5sb2NhbA==

Alternatively you can generate your own using rubeus with a command like:
rubeus.exe silver /service:cifs/dc2019.windomain.local /rc4:64FBAE31CC352FC26AF97CBDEF151E03 /creduser:windomain.local\test /credpassword:vagrant /user:test /krbkey:4b912be0366a6f37f4a7d571bee18b1173d93195ef76f8d1e3e81ef6172ab326 /krbenctype:aes256 /domain:windomain.local /ptt /sid:S-1-5-21-3541430928-2051711210-1391384369 /extendedupndns

end

context 'with non-extended upn dns info' do
describe '#read' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A #write example would be good to add too, from a BinData object that doesn't have the offsets specified upfront 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about this already but just to leave a paper trail I think this covers what you're asking for here:
https://github.com/rapid7/metasploit-framework/pull/17603/files#diff-4c294da130b0102eb5a73e30dc42d56ae8ac3bb3dc990dc7d41b230e2c956437R371-R381

Copy link
Contributor

@adfoster-r7 adfoster-r7 Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm more used to seeing this sort of pattern that uses described_class instead, in conjunction with initialising the object values directly in the constructor instead of mutating subject, and compares to the expected binary result

https://github.com/rapid7/metasploit-framework/blob/master/spec/lib/rex/proto/kerberos/credential_cache/krb5_ccache_spec.rb#L45-L54

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I think I've done what you're asking for, honestly didn;t even see that you'd left the comment on #read totally my fault for not realising I'd done that too

@sempervictus
Copy link
Contributor

Neat, thank you.

Gemfile.lock Outdated Show resolved Hide resolved
@adfoster-r7
Copy link
Contributor

Tested with the data from #17468 (comment)

Before:

            {:ul_type=>12, :cb_buffer_size=>72, :offset=>560, :buffer=>{:pac_element=>{:ul_type=>12, :unknown_element=>"\x1E\x00\x10\x00\x14\x000\x00\x01\x00\x00\x00\x00\x00\x00\x00D\x00C\x003\x00$\x00@\x00a\x00d\x00f\x003\x00.\x00l\x00o\x00c\x00a\x00l\x00\x00\x00A\x00D\x00F\x003\x00.\x00L\x00O\x00C\x00A\x00L\x00\x00\x00\x00\x00"}, :padding=>""}}

After:

            UPN and DNS Information:
              UPN: DC3$@adf3.local
              DNS Domain Name: ADF3.LOCAL
              Flags: 1

The Flags: 1 is a bit bare, but that should be easy to enhance in the future

@adfoster-r7 adfoster-r7 merged commit d261aa6 into rapid7:master Feb 8, 2023
@adfoster-r7
Copy link
Contributor

Release Notes

Updates admin/kerberos/inspect_ticket to show the UPN and DNS Information within a decrypted PAC

@adfoster-r7 adfoster-r7 added the rn-enhancement release notes enhancement label Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rn-enhancement release notes enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants