AMSI Bypass - Neutralizing the Microsoft Antimalware Scan Interface
Overview
How AMSI Works Internally
┌─────────────────────────────────────────────────────────────────┐
│ AMSI Flow — Overview │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ │
│ │ Interpreter │───▶│ amsi.dll │───▶│ AV Provider │ │
│ │ (PowerShell,│ │ (AmsiScan │ │ (Defender, │ │
│ │ JScript...)│ │ Buffer) │ │ CrowdStrike..) │ │
│ └──────────────┘ └──────────────┘ └──────────────────┘ │
│ │ │ │ │
│ │ ▼ ▼ │
│ │ ┌──────────────┐ ┌──────────────────┐ │
│ │ │ AMSI_RESULT │ │ AMSI_RESULT_ │ │
│ │ │ _CLEAN (1) │ │ DETECTED (32768)│ │
│ │ └──────────────┘ └──────────────────┘ │
│ │ │ │
│ └───────────────────▶ Execution allowed / blocked │
└─────────────────────────────────────────────────────────────────┘Technique 1: AmsiScanBuffer Patch via Reflection (PowerShell)
Principle
The Patch
Technique 2: Patch via Context Pointer (AmsiContext Corruption)
Technique Comparison
Technique 3: AmsiOpenSession Patch
Technique 4: Forcing Failure via Private Field Reflection
Detection and Countermeasures
Operational Considerations
References
PreviousProbabilistic Call Stack: A Deep Dive into Non-Deterministic Execution PathsNextETW Bypass - Blinding Windows Telemetry
Last updated