Files
nuclei-templates/code/windows/audit/powershell-script-block-logging-disabled.yaml
2025-03-17 14:05:37 +05:30

44 lines
1.4 KiB
YAML

id: powershell-script-block-logging-disabled
info:
name: PowerShell Script Block Logging - Disabled
author: JeonSungHyun[nukunga]
severity: medium
description: |
Disabling script block logging reduces visibility into executed scripts, making it harder to detect and investigate malicious PowerShell activity.
reference:
- https://www.elastic.co/guide/en/security/7.17/prebuilt-rule-0-16-1-powershell-script-block-logging-disabled.html
impact: |
Lack of script block logging allows malicious PowerShell activity to go unnoticed, increasing security risks and reducing forensic capabilities.
remediation: |
Enable PowerShell script block logging in Group Policy or Registry.
tags: windows,powershell,audit,code
self-contained: true
code:
- pre-condition: |
IsWindows();
engine:
- powershell
- powershell.exe
args:
- -ExecutionPolicy
- Bypass
pattern: "*.ps1"
source: |
$regPath = "HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging"
$logValue = (Get-ItemProperty -Path $regPath -Name "EnableScriptBlockLogging" -ErrorAction SilentlyContinue).EnableScriptBlockLogging
if ($logValue -ne 1) {
Write-Output "PowerShell Script Block Logging is disabled!"
}
matchers:
- type: word
words:
- "PowerShell Script Block Logging is disabled!"