1. Disable PowerShell for users if possible via GPO
2. Fileless malware using PowerShell - PowerShell Logging using Script Block Logging
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_logging_windows?view=powershell-6#enabling-script-block-logging
Enabling Script Block Logging
When you enable Script Block Logging, PowerShell records the content of all script blocks that it processes. Once enabled, any new PowerShell session logs this information. It's recommended to enable Protected Event Logging.Using Group Policy
To enable automatic transcription, enable theTurn on PowerShell Script Block Logging
feature in Group Policy through Administrative Templates -> Windows Components -> Windows PowerShell
.Using the Registry
Run the following function:
PowerShell
function Enable-PSScriptBlockLogging
{
$basePath = 'HKLM:\Software\Policies\Microsoft\Windows' +
'\PowerShell\ScriptBlockLogging'
if(-not (Test-Path $basePath))
{
$null = New-Item $basePath -Force
}
Set-ItemProperty $basePath -Name EnableScriptBlockLogging -Value "1"
}
Powershell-Commands will be logged in Windows Eventlog with Event-ID 4104.
No comments:
Post a Comment