This rule identifies potential Portable Executable (PE) files that may be infected with malware, indicating an adversary has successfully delivered a malicious binary to a host. Proactively hunting for these detections allows the SOC team to isolate compromised endpoints early in the kill chain, preventing the execution of malicious code and subsequent lateral movement within the Azure environment.
rule IsSuspicious
{
meta:
author="_pusher_"
date = "2016-07"
description="Might be PE Virus"
condition:
uint32(0x20) == 0x20202020
}
This YARA rule can be deployed in the following contexts:
dotnet build or msbuild to compile a C# application in a development environment, where the compiler generates a temporary .exe or .dll file that is immediately loaded into memory or executed for testing before being cleaned up.
MSBuild.exe, dotnet.exe, or csc.exe (C# Compiler), and the file path contains standard build directories like bin\Debug, bin\Release, or obj\.PowerShell to execute a small, self-contained .NET utility (e.g., a custom log rotation script or disk cleanup tool) that is stored in a standard administrative folder like C:\AdminTools\ or C:\Scripts\.
C:\AdminTools\, C:\Scripts\, C:\ProgramData\CorpTools\) if the parent process is powershell.exe or pwsh.exe and the file size is below a certain threshold (e.g., < 500KB)..dll or .pyd files, which are then loaded by the application runtime (e.g., python.exe or node.exe).
C:\Users\<User>\.nuget\packages\, C:\Users\<User>\.cache\pip\, or node_modules\ if the parent process is a known runtime interpreter (python.exe, node.exe, java.exe).