Suspicious PowerShell Script with .NET Reflection
Description
Detects the use of Reflection.Assembly to load PEs and DLLs in memory in PowerShell scripts. Attackers use this method to load executables and DLLs without writing to the disk, bypassing security solutions.
Query · eql
api where process.Ext.api.name == "AmsiScanBuffer" and
(process.name in~ ("powershell.exe") or process.Ext.api.parameters.app_name == "PowerShell") and
process.parent.executable != null and
process.Ext.api.parameters.buffer : ("*Reflection.Assembly]::Load($*", "*Reflection.Assembly*::UnsafeLoad*", "*assembly.Load(*") and
process.Ext.api.parameters.buffer : ("*::FromBase64String($*", "*.downloadstring*", "*.downloaddata*", "*.WebClient*") and
process.Ext.api.parameters.buffer : "*.Invoke(*" and
not process.Ext.api.parameters.content_name :
("?:\\Program Files (x86)\\*",
"?:\\Program Files\\*",
"?:\\WINDOWS\\system32\\config\\systemprofile\\AppData\\Local\\*.ps1",
"D:\\*", "E:\\*", "F:\\*",
"C:\\WINDOWS\\system32\\config\\systemprofile\\AppData\\Local\\*.ps1",
"C:\\Packages\\Plugins\\Microsoft.Powershell.DSC\\2.83.5\\bin\\DscExtensionTelemetry.psm1",
"C:\\windows\\AdminArsenal\\PDQDeployRunner\\service-1\\exec\\PSAppDeployToolkit\\PSAppDeployToolkit.psm1") and
not process.executable :
("C:\\Program Files (x86)\\N-able Technologies\\AutomationManagerAgent\\AutomationManager.AgentService.exe",
"C:\\Program Files (x86)\\COT\\COT Help\\COTHelpx64.exe",
"C:\\Program Files (x86)\\Cygate System Information\\SystemInformation.exe",
"C:\\Program Files (x86)\\Cygate System Information\\SystemInformation.exe",
"C:\\Program Files\\Microsoft Visual Studio\\*\\Common?\\IDE\\devenv.exe") and
not process.parent.executable : ("C:\\Program Files (x86)\\baramundi\\Management Server\\BDSRun.exe",
"C:\\Windows\\CCM\\CcmExec.exe",
"C:\\Windows\\AdminArsenal\\PDQDeployRunner\\service-?\\exec\\Invoke-AppDeployToolkit.exe",
"C:\\Program Files\\Mesh Agent\\MeshAgent.exe",
"C:\\Program Files (x86)\\COT\\COT Help\\COTHelp.exe",
"C:\\Program Files (x86)\\baramundi\\Management Server\\BDSRun.exe",
"C:\\Program Files (x86)\\N-able Technologies\\AutomationManagerAgent\\AutomationManager.AgentService.exe")