AMSI Bypass via .NET Reflection (PowerShell)
Disclaimer
This content is provided for educational and research purposes only.
It must not be used for malicious activities.
The author assumes no responsibility for any misuse.
This technique manipulates the internal .NET
class AmsiUtils
by setting the private static field amsiInitFailed
to true
.
This tricks PowerShell into skipping AMSI initialization, effectively disabling AMSI scanning for the rest of the session.
Full Version
|
|
Inline Version
|
|
Obfuscated Version (Static signature evasion)
|
|
Limitations
- CLM (Constrained Language Mode): The technique does not work if CLM is enforced, for example through Device Guard.
- EDR/AV Interference: Advanced EDR solutions may detect reflection-based field access and block execution.
- Scope: The effect is limited to the current PowerShell process and is not persistent.
Detection
Monitor for the following behaviors:
- Access to
System.Management.Automation.AmsiUtils
- Use of
.GetField()
and.SetValue()
onamsiInitFailed
- PowerShell events indicating suspicious reflection activity (Event ID 4104)