AMSI Bypass via Byte-Signature Patching
Description
A .NET defense-evasion technique in which the malware dynamically resolves amsi.dll exports (AmsiInitialize, AmsiOpenSession, AmsiScanBuffer), then scans the function prologues for known byte signatures (e.g., 0x8B, 0xFF, 0x55, 0x48) and overwrites them with a benign stub (typically mov eax, 0; ret or equivalent). This neutralizes Windows Antimalware Scan Interface (AMSI) in the current process without terminating the service or touching disk.
Why It Works
AMSI operates in-process. By patching the function bytes in the loaded module's .text section, all subsequent calls to AmsiScanBuffer return AMSI_RESULT_CLEAN (0), allowing the payload to execute without triggering AMSI-integrated scanners (Defender, ATP, etc.).
Static Indicators
- Method names like
Get_AmsiOpenSession_Byte,Get_AmsiScanBuffer_Byte,AmsiInitializein CIL metadata LoadLibrary("amsi.dll")/GetProcAddresspairsVirtualProtectto mark the target pagePAGE_EXECUTE_READWRITEbefore patching- Absence of normal AMSI API call patterns (the malware never actually calls
AmsiScanBufferwith a real buffer — it only resolves and patches)
Notable Examples
-
unclassified-dotnet-crypter-loader sibling
931242f8...— unobfuscated .NET 4.8 loader with explicitGet_AmsiOpenSession_ByteandGet_AmsiScanBuffer_Bytemethods, alongsideAmsiInitialize,AmsiOpenSession, andAmsiScanBufferstrings. ^[sample 931242f8/strings.txt:100-102] -
unclassified-dotnet-crypter-loader sibling
673e6738...— unobfuscated .NET 4.0+ loader with identical AMSI bypass method names andAmsi_dllP/Invoke string. ^[/intel/analyses/673e673800b807ec8ab291b464f62dc81576874956d702e7cfa152af61844421.html] -
unclassified-dotnet-crypter-loader sibling
4e31a886...— unobfuscated .NET 4.5.1 loader with identical AMSI bypass method names. ^[/intel/analyses/4e31a886cd81ca02100d96b6b1475085dbe02d7c6f3fc72604be3ae64a56d1e8.html] -
unclassified-dotnet-crypter-loader sibling
5f54948e...— .NET 4.0+ loader with Unicode control-character / Hangul jamo CIL name obfuscation, but plaintextGet_AmsiOpenSession_Byte,Get_AmsiScanBuffer_Byte,Get_ComplementaryStrings_Byte,AmsiInitialize,AmsiOpenSession,AmsiScanBuffer, andAmsi_dllstrings survive in metadata. Sixth confirmed sibling. ^[/intel/analyses/5f54948ef4ea19feac07408f4109df54c07137d35b34804250cd20eeccfcd254.html]
Detection
- ETW / AMSI event logs showing
AmsiScanBufferreturning 0 immediately after process start - Memory scans for the byte sequence
B8 00 00 00 00 C3(x86mov eax, 0; ret) at the start ofAmsiScanBuffer - Suspicious
VirtualProtectonamsi.dllmapped pages