This rule detects potential UI overlay attacks where an adversary places a malicious window over a legitimate interface to trick users into interacting with the wrong element, a common tactic in phishing and credential theft scenarios. Proactively hunting for these overlays in Azure Sentinel helps identify subtle social engineering attempts that may bypass standard network-based detections by exploiting user trust and visual cues.
rule HasOverlay : PECheck
{
meta:
author="_pusher_"
description = "Overlay Check"
condition:
// MZ signature at offset 0 and ...
uint16(0) == 0x5A4D and
// ... PE signature at offset stored in MZ header at 0x3C
uint32(uint32(0x3C)) == 0x00004550 and
//stupid check if last section is 0
//not (pe.sections[pe.number_of_sections-1].raw_data_offset+pe.sections[pe.number_of_sections-1].raw_data_size) == 0x0 and
(pe.sections[pe.number_of_sections-1].raw_data_offset+pe.sections[pe.number_of_sections-1].raw_data_size) < filesize
}
This YARA rule can be deployed in the following contexts:
mstsc.exe (Microsoft Terminal Services Client) or CitrixReceiver.exe, and where the window class name matches known RDS overlay classes (e.g., RDPOverlay or CitrixOverlay).TeamViewer.exe, AnyDesk.exe, ScreenConnect.exe, or logmein.exe. Additionally, filter out windows with specific class names like TVOverlay or AnyDeskOverlay that are known to be non-interactive UI elements.vmware-view.exe or Udica.exe (Citrix). Filter windows where the parent process is a VDI client and the window style includes WS_EX_TOOLWINDOW (indicating a non-taskbar overlay) rather than a full application window.