Skip to content
Misconfiguration Write-up Intermediate

Poch, Poch, is this thing on? Bypass AMSI with Divide & Conquer

The article describes how splitting known PowerShell scripts, such as AMSI bypasses, into multiple lines or stages can evade Windows Defender's static detection. An attacker could then execute malicious commands like Mimikatz that would otherwise be blocked.

badoption.eu

Published on badoption.eu

Everytime I play with Windows Defender detection, it surprises me, how many ways exist to bypass something. And some of them are really simple.

PfiatDe, on badoption.eu

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the antivirus relies on static signatures that match complete script blocks, so splitting the script into separate lines or stages avoids the signature match.

Impact

This technique could allow an attacker to bypass Windows Defender and execute malicious PowerShell commands, such as credential theft tools, though it may be ineffective against EDR solutions.

What the attacker needed

Windows Defender as the only AV; Ability to run PowerShell commands; No EDR present

How it was found

  1. Paste a PowerShell script into Windows Terminal or PowerShell to execute it line by line.
  2. Observe which line triggers the AMSI detection.
  3. Split the triggering line into separate commands, for example by assigning parts to variables.
  4. Execute the split commands line by line to bypass detection.
  5. For a one-liner, obfuscate strings with a replace or HTML decode method.
  6. Use a builder script to XOR and base64-encode multiple stages, then run them sequentially in one command.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

AMSI is a Windows security feature that scans PowerShell commands for malicious content. This article shows that if you break a malicious script into smaller pieces and run them one by one, the scanner may not recognise the whole attack. That allows an attacker to run tools like Mimikatz, which steals passwords, even when antivirus is active.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.