Frida is a dynamic code instrumentation toolkit. Frida allows you to write tweaks in JavaScript:
to hook a functions invocation
to show and modify incoming arguments to functions
to print and modify function returns
to inject custom code before and after a functions invocation
This is used to monitor how AMSI reacts to certain VBA, PowerShell, JScript etc commands.
frida-trace generates JavaScript templates which can then be modified. For example, after handlers\AmsiScanBuffer.js has been generated, you can open and modify it using the below code (AmsiScanBufferVebose.js) for a for more verbose output.
Steps:
Find PID of PowerShell process to hook using sysinternals etc.
Run ./tracer.py as below specifying the PID:
Type string or test command and check output. A successful string returns '1' a malicious string returns '32768'.