mirror of
https://github.com/Yamato-Security/WELA.git
synced 2025-12-09 10:43:01 +01:00
fix: add registry check
This commit is contained in:
23
WELA.ps1
23
WELA.ps1
@@ -158,6 +158,25 @@ function RuleFilter {
|
|||||||
return $result
|
return $result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CheckRegistryValue {
|
||||||
|
param (
|
||||||
|
[string]$registryPath,
|
||||||
|
[string]$valueName,
|
||||||
|
[int]$expectedValue
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
$value = Get-ItemProperty -Path $registryPath -Name $valueName -ErrorAction Stop
|
||||||
|
if ($value.$valueName -eq $expectedValue) {
|
||||||
|
return $true
|
||||||
|
} else {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function AuditLogSetting {
|
function AuditLogSetting {
|
||||||
param (
|
param (
|
||||||
[string] $outType
|
[string] $outType
|
||||||
@@ -195,7 +214,7 @@ function AuditLogSetting {
|
|||||||
$guid = ""
|
$guid = ""
|
||||||
$eids = @("4103")
|
$eids = @("4103")
|
||||||
$channels = @("pwsh")
|
$channels = @("pwsh")
|
||||||
$enabled = $false
|
$enabled = CheckRegistryValue -registryPath "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\ModuleLogging" -valueName "EnableModuleLogging" -expectedValue 1
|
||||||
$rules = $all_rules | Where-Object { RuleFilter $_ $eids $channels $guid }
|
$rules = $all_rules | Where-Object { RuleFilter $_ $eids $channels $guid }
|
||||||
$rules | ForEach-Object { $_.applicable = $enabled }
|
$rules | ForEach-Object { $_.applicable = $enabled }
|
||||||
$auditResult += [WELA]::New(
|
$auditResult += [WELA]::New(
|
||||||
@@ -209,7 +228,7 @@ function AuditLogSetting {
|
|||||||
$guid = ""
|
$guid = ""
|
||||||
$eids = @("4104")
|
$eids = @("4104")
|
||||||
$channels = @("pwsh")
|
$channels = @("pwsh")
|
||||||
$enabled = $false
|
$enabled = CheckRegistryValue -registryPath "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging" -valueName "EnableScriptBlockLogging" -expectedValue 1
|
||||||
$rules = $all_rules | Where-Object { RuleFilter $_ $eids $channels $guid }
|
$rules = $all_rules | Where-Object { RuleFilter $_ $eids $channels $guid }
|
||||||
$rules | ForEach-Object { $_.applicable = $enabled }
|
$rules | ForEach-Object { $_.applicable = $enabled }
|
||||||
$auditResult += [WELA]::New(
|
$auditResult += [WELA]::New(
|
||||||
|
|||||||
Reference in New Issue
Block a user