ManageCA
Summary
Description
Identification
PowerShell
function Find-ManageCA {
[CmdletBinding()]
param ( [string]$ComputerDN = $null,[string]$OutputPath = "ManageCA.csv")
foreach ($module in @("ActiveDirectory", "PSPKI")) {
if (-not (Get-Module -Name $module)) {
Write-Host "Attempting to load $module module..."
try {
Import-Module $module -ErrorAction Stop
Write-Host "$module module loaded successfully."
}
catch {
Write-Error "Failed to load $module module. Please ensure it is installed."
return
}
}
}
# Access Control Type (Allow)
$AccessControlType = [System.Security.AccessControl.AccessControlType]::Allow
$results = @()
try {
if ($ComputerDN) {
Write-Host "Scanning specific Certification Authority: $ComputerDN"
$ComputerName = (Get-ADComputer -Identity $ComputerDN -Properties dNSHostName |
Select-Object -ExpandProperty dNSHostName)
$targetComputers = @($ComputerName)
}
else {
Write-Host "Scanning all Certification Authorities in the domain..."
$targetComputers = Get-ADComputer -Filter * -Properties dNSHostName |
Select-Object -ExpandProperty dNSHostName
}
foreach ($ComputerName in $targetComputers) {
try {
Get-CertificationAuthority -ComputerName $ComputerName |
Get-CertificationAuthorityAcl |
Select-Object -ExpandProperty Access |
Where-Object {
$_.AccessControlType -eq $AccessControlType -and
$_.Rights -like "*ManageCA*" -and
$_.IsInherited -eq $false
} |
ForEach-Object {
$results += [PSCustomObject]@{
"Vulnerable CA" = $ComputerName
"Internal Threat" = $_.IdentityReference
}
}
}
catch {Write-Warning "Error scanning CA on $ComputerName : $($_.Exception.Message)" }
}
}
catch {
Write-Error "Unexpected error during CA scan: $($_.Exception.Message)"
return
}
if ($results.Count -gt 0) {
try {
$results | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8
Write-Host "Results exported successfully to '$OutputPath'"
}
catch { Write-Error "Failed to export results to CSV: $($_.Exception.Message)" }
}
else { Write-Host "No ManageCA permissions found." }
}
Exploitation
Windows








Linux






Mitigation

Detection
Event ID
Description
Fields/Attributes
References
References
Last updated
Was this helpful?