This rule identifies Windows processes that are configured as GUI applications, which may indicate an adversary attempting to interact with the user interface or establish a foothold for lateral movement. Proactively hunting for these instances helps the SOC team distinguish between legitimate interactive sessions and potential malicious activity, ensuring that unexpected GUI processes are investigated for signs of compromise or unauthorized access.
rule IsWindowsGUI : PECheck
{
condition:
// MZ signature at offset 0 and ...
uint16(0) == 0x5A4D and
// ... PE signature at offset stored in MZ header at 0x3C
uint16(uint32(0x3C)+0x5C) == 0x0002
}
This YARA rule can be deployed in the following contexts:
mspaint.exe or notepad.exe via a PowerShell script to generate a simple text log or image for a ticket attachment, triggering the GUI detection because the process is launched from a non-interactive context.
powershell.exe or pwsh.exe and the command line contains specific arguments like /s (silent) or output redirection, or whitelist known benign GUI apps (notepad.exe, mspaint.exe) when launched by service accounts.cmd.exe /c start /wait notepad.exe to create a temporary file for a backup verification step, where the GUI window flashes briefly before the process exits, causing the YARA rule to flag the transient GUI state.
svchost.exe (Task Scheduler) or cmd.exe with a /c flag, indicating a short-lived command execution.java.exe or dotnet.exe) spawns a native Windows GUI component (like mshtml.dll or a WinForms window) for a user-facing report generation task, where the YARA rule incorrectly attributes the GUI flag to the parent interpreter process.
java.exe, dotnet.exe, node.exe) and the child process is a standard Windows system binary (e.g., mshtml.dll, user32.dll related windows) or a known application binary, unless the child process is explicitly known to be a standalone GUI app.WMI