LoFP LoFP / potential for some third party applications to disable amsi upon invocation. filter as needed.

Techniques

Sample rules

Unloading AMSI via Reflection

Description

The following analytic utilizes PowerShell Script Block Logging (EventCode=4104) to identify suspicious PowerShell execution. Script Block Logging captures the command sent to PowerShell, the full command to be executed. Upon enabling, logs will output to Windows event logs. Dependent upon volume, enable on critical endpoints or all.

This analytic identifies the behavior of AMSI being tampered with. Implemented natively in many frameworks, the command will look similar to SEtValuE($Null,(New-OBJEct COLlECtionS.GenerIC.HAshSEt{[StrINg]))}$ReF=[ReF].AsSeMbLY.GeTTyPe("System.Management.Automation.Amsi"+"Utils") taken from Powershell-Empire. During triage, review parallel processes using an EDR product or 4688 events. It will be important to understand the timeline of events around this activity. Review the entire logged PowerShell script block.

Detection logic

`powershell` EventCode=4104 ScriptBlockText = *system.management.automation.amsi* 
| stats count min(_time) as firstTime max(_time) as lastTime by EventCode ScriptBlockText Computer user_id 
| `security_content_ctime(firstTime)` 
| `security_content_ctime(lastTime)` 
| `unloading_amsi_via_reflection_filter`