
An AD CS toolkit for AD Admins, Defensive Security Professionals, and Filthy Red Teamers

Locksmith 2 is a comprehensive PowerShell module for auditing Active Directory Certificate Services (AD CS) infrastructure. It identifies security misconfigurations across certificate templates, certification authorities, and PKI infrastructure objects based on established ESC (Escalation) techniques.
Built for AD administrators, security professionals, and penetration testers, Locksmith 2 provides:
Locksmith 2 represents the next generation in the Locksmith line of open-source AD CS security tooling, improving upon the original with better code organization, enhanced reporting, and deeper risk analysis.
Install-Module -Name Locksmith2 -Scope CurrentUser -Force
git clone https://github.com/jakehildreth/Locksmith2.git
cd Locksmith2
Import-Module .\Locksmith2.psd1
Invoke-Locksmith2
New-LS2Dashboard
| Technique | Description | Target Objects | Sub-techniques |
|---|---|---|---|
| ESC1 | Misconfigured Certificate Templates | Templates | — |
| ESC2 | Certificate SubCA Abuse | Templates | — |
| ESC3 | Enrollment Agent Restrictions | Templates | ESC3c1, ESC3c2 |
| ESC4 | Vulnerable Access Control | Templates | ESC4a (ACL), ESC4o (owner) |
| ESC5 | Vulnerable PKI Object Access Control | Infrastructure Objects | ESC5a (ACL), ESC5o (owner) |
| ESC6 | EDITF_ATTRIBUTESUBJECTALTNAME2 Enabled | CAs | — |
| ESC7 | Vulnerable CA Administrator/Manager Roles | CAs | ESC7a (admin), ESC7m (manager) |
| ESC8 | Vulnerable Web Enrollment Endpoints | CAs | — |
| ESC9 | Weak Certificate Mappings | Templates | — |
| ESC11 | Missing RPC Encryption | CAs | — |
| ESC13 | Group-Linked OID Application Policy | Templates | — |
| ESC16 | Disabled CRL/AIA Security Extensions | CAs | — |
For detailed information on ESC techniques, see Certified Pre-Owned by SpecterOps.
Invoke-Locksmith2Performs comprehensive AD CS security audit scanning for all known ESC vulnerabilities.
Invoke-Locksmith2 [-Forest <String>] [-Credential <PSCredential>] [-Mode <Int>]
[-SkipVersionCheck] [-SkipPowerShellCheck]
[-ExpandGroups] [-Rescan]
# -Mode values:
# (omit) = return LS2Issue objects to the pipeline (default)
# 0 = Emulates Mode 0/no parameters from the original Locksmith: output issues to console as table
# 1 = Emulates Mode 1 from the original Locksmith: output issues + fix scripts to console as list
Find-LS2VulnerableTemplateScans certificate templates for specific ESC vulnerabilities.
Find-LS2VulnerableTemplate -Technique <String>
# Supported: ESC1, ESC2, ESC3c1, ESC3c2, ESC4a, ESC4o, ESC9, ESC13
Returns: LS2Issue objects for programmatic use
Find-LS2VulnerableCAScans certification authorities for configuration issues and dangerous role assignments.
Find-LS2VulnerableCA -Technique <String>
# Supported: ESC6, ESC7a, ESC7m, ESC8, ESC11, ESC16
Returns: LS2Issue objects for programmatic use
Find-LS2VulnerableObjectScans PKI infrastructure objects (containers, computer accounts) for security issues.
Find-LS2VulnerableObject -Technique <String>
# Supported: ESC5a, ESC5o
Returns: LS2Issue objects for programmatic use
Get-LS2StoresReturns internal data stores populated during audits for inspection and analysis.
Get-LS2Stores [-Name <String>]
# Valid -Name values: PrincipalStore, AdcsObjectStore, DomainStore, IssueStore,
# SafePrincipals, DangerousPrincipals, StandardOwners
# Omit -Name to return all stores.
Returns:
Set-LS2ForestSets the target forest for scanning. Useful for running multiple scans or using Find-LS2Vulnerable* functions independently.
Set-LS2Forest -Forest <String>
Set-LS2CredentialSets credentials for AD queries. Useful for running multiple scans or using Find-LS2Vulnerable* functions independently.
Set-LS2Credential -Credential <PSCredential>
Find-LS2RiskyPrincipalPivots from configuration-centric to principal-centric risk analysis. Aggregates vulnerabilities by individual principal to show which users or service accounts have the highest AD CS exposure.
Find-LS2RiskyPrincipal [-Technique <String>] [-MinimumIssueCount <Int>] [-Top <Int>] [-Rescan]
Returns: PSCustomObject with Principal, IssueCount, Techniques, VulnerableObjects, Issues
New-LS2DashboardGenerates an interactive HTML dashboard from current scan results. PSWriteHTML is included (vendored) — no separate install needed.
New-LS2Dashboard [-FilePath <String>] [-Show] [-ExpandGroups] [-Online]
Returns: HTML file at the specified path. Run Invoke-Locksmith2 or Find-LS2Vulnerable* first to populate the store.