Visual guide
AMSI-Bypass-Generator
A defensive guide to AMSI: how a script travels through Windows’ antimalware interface and what telemetry any attempt to evade it leaves behind.
- 5
- scan stages
- 4
- documented families
- 4104
- key PowerShell event
- 0
- evasion snippets published
2 screens · 7 parts explained
How a script flows through AMSI
AMSI receives the content already deobfuscated just before it runs and hands it to the registered antivirus, which decides whether it proceeds.
- Process start
- amsi.dll
- AmsiScanBuffer
- Antimalware provider
- Verdict
Who requests the scan
PowerShellWindows Script HostJScript / VBScriptOffice VBA macros.NET (Assembly.Load)
Registered providers
- Microsoft Defender Antivirusdefault
- Microsoft Defender for EndpointEDR
- Third-party antivirusoptional
The host blocks execution and Defender logs the detection. If the result is clean, the script carries on.
The five stages
The process loads amsi.dll, the host sends content with AmsiScanBuffer, the provider analyses it and returns a verdict.
Why it sees through obfuscation
Script hosts send the code at the last moment, after obfuscation is resolved. That is why it works so well.
Providers
Any antivirus can register as a provider; on Windows the default is Defender.
The verdict
On detection the host refuses to run it and an event is logged. It is the last barrier before execution.
What trace each technique family leaves
Evasion techniques fall into four families. None is invisible: each leaves signals the blue team can watch.
| Family | Signal | Where |
|---|---|---|
| Tampering with amsi.dll functions | memory tampering | EDR / ETW |
| Obfuscating strings and payloads | deobfuscated script | 4104 |
| Changing AMSI state | reflection access | 4104 |
| Loading in-memory assemblies | Assembly.Load | AMSI .NET / ETW |
events to watch
PowerShell 4104 · Script Block Logging
Defender 1116 · malware detected
ETW · Microsoft-Antimalware-Scan-Interface
Sysmon 7 · image loaded (amsi.dll)
Mitigation
- Script Block Logging enabled
- Constrained Language Mode
- Remove PowerShell v2
- WDAC / AppLocker
Four families, four traces
Described by their effect, not their code: what they change and in which telemetry they show up.
Key events
Event 4104 stores the deobfuscated script block; 1116 is Defender’s detection; ETW and Sysmon give low-level context.
Hardening
Script block logging, constrained language mode, removing PowerShell v2 (which lacks AMSI) and application control.
How it is used
Understand the flow
Where AMSI steps in and who decides.
Enable logging
Script Block Logging and Defender telemetry.
Watch the signals
Build alerts for each technique family.
Harden
Reduce the surface with CLM and application control.
Key concepts
- AMSI
- Antimalware Scan Interface: a Windows API letting antivirus inspect scripts at run time.
- Script Block Logging
- PowerShell logging that stores executed code, already deobfuscated (event 4104).
- ETW
- Event Tracing for Windows: low-level telemetry consumed by EDRs.
- CLM
- Constrained Language Mode: limits what PowerShell can do.
Want to use it for real?
pwn3d.es only publishes the defensive side: neither the generator nor evasion snippets. The original educational project is on its official site.