mirror of
https://github.com/Yamato-Security/WELA.git
synced 2025-12-06 01:02:48 +01:00
fix: add AD CS AuditFilter configuration to streamline auditing setup in WELA.ps1
This commit is contained in:
73
WELA.ps1
73
WELA.ps1
@@ -5890,6 +5890,79 @@ function ConfigureAuditSettings {
|
||||
}
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
# AD CS AuditFilter の設定
|
||||
Write-Host "Configuring AD CS Audit Settings..."
|
||||
Write-Host ""
|
||||
|
||||
try {
|
||||
$installed = (Get-WindowsFeature -Name AD-Certificate).InstallState -eq "Installed"
|
||||
} catch {
|
||||
$installed = $false
|
||||
}
|
||||
|
||||
if ($installed) {
|
||||
try {
|
||||
$csRootKey = "HKLM:\SYSTEM\CurrentControlSet\Services\CertSvc\Configuration\"
|
||||
$caName = (Get-ItemProperty $csRootKey -ErrorAction Stop).Active
|
||||
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\CertSvc\Configuration\$caName"
|
||||
$prop = Get-ItemProperty -Path $regPath -Name "AuditFilter" -ErrorAction SilentlyContinue
|
||||
|
||||
$currentValue = if ($null -ne $prop) { [int]$prop.AuditFilter } else { "Not Set" }
|
||||
|
||||
Write-Host "Registry: $regPath"
|
||||
if ($currentValue -eq 127) {
|
||||
Write-Host "[OK] AuditFilter is already 127" -ForegroundColor Green
|
||||
}
|
||||
else {
|
||||
Write-Host ("[SET] AuditFilter: {0} -> 127" -f $currentValue) -ForegroundColor Yellow
|
||||
|
||||
$proceed = $false
|
||||
if ($Auto) {
|
||||
$proceed = $true
|
||||
}
|
||||
else {
|
||||
$response = Read-Host "Do you want to set AuditFilter to 127 and restart Certificate Services? (Y/n)"
|
||||
$proceed = ($response -eq "" -or $response -match "^[Yy]$")
|
||||
}
|
||||
|
||||
if ($proceed) {
|
||||
try {
|
||||
# AuditFilter の設定
|
||||
Start-Process -FilePath "certutil.exe" -ArgumentList "-setreg","CA\AuditFilter","127" -NoNewWindow -Wait
|
||||
|
||||
# 証明書サービスの再起動
|
||||
Restart-Service -Name "CertSvc" -Force -ErrorAction Stop
|
||||
|
||||
# 反映確認
|
||||
$propAfter = Get-ItemProperty -Path $regPath -Name "AuditFilter" -ErrorAction SilentlyContinue
|
||||
$newValue = if ($null -ne $propAfter) { [int]$propAfter.AuditFilter } else { $null }
|
||||
|
||||
if ($newValue -eq 127) {
|
||||
Write-Host "[OK] AuditFilter set to 127 and CertSvc restarted" -ForegroundColor Green
|
||||
}
|
||||
else {
|
||||
Write-Host "[ERROR] AuditFilter did not apply as expected (current: $newValue)" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "[ERROR] Failed to set AuditFilter or restart CertSvc: $_" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "[SKIP] No changes applied to AuditFilter"
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "[ERROR] Failed to process AD CS audit settings: $_" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "[INFO] AD Certificate Services is not installed. Skipping." -ForegroundColor Yellow
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
Write-Host "Configuration completed successfully" -ForegroundColor Green
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user