OBTS v3 Cthomas
OBTS v3 Cthomas
Cody Thomas
Objective By The Sea 3.0
March 2020
WHO AM I?
Cody Thomas - @its_a_feature_
● Operator / Instructor at SpecterOps
● Open Source Developer
○ Apfell – Red Team C2 Framework
○ Bifrost – Kerberos Manipulation
○ Orchard – Open Directory Access
○ GitHub: https://github.com/its-a-feature
OVERVIEW
● Brief intro to Kerberos
○ What is it / How does it work / Why do we care?
○ Common Attacks
5. TGS responds with a ticket to the service and encrypts a portion with
the service account’s hash (another shared secret)
○ This is a TGS-REP. The ticket is a Service Ticket
6. Client presents Service Ticket to the service and requests services
As a Blue Teamer:
● More authentication logs for correlation
● More credential material to track
● You might be using it and not even know it
WINDOWS ACTIVE DIRECTORY & HEIMDAL
A case study in Windows attacks from a macOS perspective
WHAT / WHO IS HEIMDAL?
• Heimdall in Norse Mythology guards the Bifrost (rainbow road) in
Asgard (where Thor, Loki, Odin, etc live)
• Heimdal is Apple’s slightly tweaked implementation of Kerberos
• In Windows, you don’t send your password around, you use a hash
• Active Directory knows this hash, not your plaintext password
• AD knows many hashes of your password to be able to support a wide
range of system versions
• RC4 hashes are so enticing because they’re not unique across domains and are
easier to crack
STAGE 1 – THE SHARED SECRET
• If you’re curious how to
get your computer$
shared secret, you can
reveal it with admin
credentials from the
SYSTEM Keychain
• Found under
/Active Directory/
NETBIOS Name
• Also found via dscl
(Open Directory)
STAGE 1 – THE SHARED SECRET
STAGE 1.5 – SAVING HASHES
• What if you can’t be bothered to keep typing your password each
time to generate that shared secret?
• Keytabs
• A table of keys associated with various accounts
• System generated (/etc/krb5.keytab)
• Your system has one for hashes of its own computer$ account
• Need to be root to access
• User generated
• Users can generate their own at any time (yikes!)
STAGE 1.5 – SAVING HASHES
• [[ Bifrost keytab dump ]] Backing account for VNC is
spooky$
LKDC:SHA1.B58C56AD77898DE69AAEFD22A538D6EDDE
FF8D47
COM.APPLE.KERBEROS.KDC
• /System/Library/LaunchDaemons/
com.apple.Kerberos.kdc.plist
des3-cbc-sha1-kd
LKDC – AS-REQ1
• Now let’s say we want to mount a volume on another mac, but we
don’t know that mac’s LKDC realm and we don’t know the full shared
secret, just the plaintext password
• Make an AS-REQ for a generic
realm:
• WELLKNOWN:COM.APPLE.LKDC
• Kerberos responds with generic
error specifically to call out real
realm
LKDC – PA-FX-COOKIE
• We now know the realm, we still don’t know the shared secret
• The LKDC uses the Secure Remote Protocol (SRP) for this
• It’s a method of key exchange based on crypto
• It’s integrated into the Kerberos implementation
• Kerberos is stateless though?
• RFC613 added a way to manage state within Kerberos:
• PA-FX-COOKIE (133) can be passed with other PADATA fields
• Same area as our PA-ENC-TIMESTAMP
• We need to capture and relay this with every request to keep state
LKDC – USER PASSWORDS
• Ok, we have a way to keep state and we know the realm, but we still
need to get that shared secret
• Passwords on macOS aren’t saved in plaintext, instead they’re passed
through a PBKDF2 function to generate a new, longer password
• You can see your ShadowHashData by looking into your Open
Directory Local Node as root – Using Orchard (OSS) or built in:
dscl . read /Users/itsafeature ShadowHashData
Verifier is based on user’s password
LKDC –
V=gx SHADOWHASHDATA
where x = H(s | H( I | “:” | P ) )
• Salted-SHA512-PBKDF2
• Many iterations (80k+) with a
salt.
• Designed to be slow and unique
• Used when you sign in
• SRP-RFC5054-4096-
SHA512-PBKDF2
• This is the server-side shared
secret for Kerberos traffic
• This is called the “Verifier”
LKDC – AS-REQ2
• We can make a slightly modified
AS-REQ again, this time
specifying the real realm of the
remote LKDC
• We can then treat this TGT like any other normal TGT and use it to
request Service Tickets like normal for the remote mac
Normal Kerberos
So What’s this??
LKDC – CCACHE ENTRIES
Plaintext Password!!
Associated Remote
Username
Salt
LKDC - SUMMARY
• You’re running Heimdal on your macOS computer.
• How often do you change your password?
What about your _krbtgt password?
What about your computer’s password?
• LKDC should not come into play if you’re AD joined
• Realistically, it just doesn’t come into play with AD users
• Still comes into play with local user accounts
• The tickets in your ccache are flushed periodically
• LKDC tickets are flushed when you’re no longer using the them
• i.e. unmount that shared drive, disconnect VNC, etc
THANK YOU – QUESTIONS?
• Bifrost
• https://github.com/its-a-feature/bifrost
• Will release updated code for LKDC interaction
• Still need to add in Silver/Golden ticket generation
• Blog on the topic with video demo:
• https://posts.specterops.io/when-kirbi-walks-the-bifrost-4c727807744f
• Using a captured hash to get a TGT, inject ticket, get a CIFS service ticket, then
mounting a remote share with those tickets