This rule detects the use of PECompact, a compression tool often employed by adversaries to reduce the size of malicious executables or legitimate binaries to evade file-based detection mechanisms. Proactively hunting for this behavior in Azure Sentinel allows the SOC team to identify potential stealth techniques used in initial access or persistence stages, ensuring that compressed payloads are not overlooked during incident response.
rule pecompact2 : Packer
{
meta:
author="Kevin Falcoz"
date_create="25/02/2013"
description="PECompact"
strings:
$str1={B8 [3] 00 50 64 FF 35 00 00 00 00 64 89 25 00 00 00 00 33 C0 89 08 50 45 43} /*EntryPoint*/
condition:
$str1 at pe.entry_point
}
This YARA rule can be deployed in the following contexts:
This rule contains 1 string patterns in its detection logic.
upx.exe (Universal Packer) by a DevOps engineer or build agent to compress native C/C++ binaries before deployment to production.
msbuild.exe, dotnet.exe, npm.exe) or where the command line contains upx.exe and the working directory is within a designated source control or build artifact path (e.g., C:\Builds\, D:\Artifacts\).pecompact.exe or similar compression utilities to optimize legacy .NET assemblies or native DLLs during off-hours maintenance windows.
pecompact.exe and the parent process is svchost.exe (indicating a Windows Task Scheduler trigger) or the execution time falls within the defined maintenance window (e.g., 02:00–04:00 AM).MsMpEng.exe, CrowdStrike Falcon Sensor, Defender.exe) or where the image path resides in the vendor’s installation directory (e.g., C:\Program Files\Microsoft Security Client\, C:\Program Files\CrowdStrike\).NSIS-based installers, Inno Setup) compressing payloads in memory or temporary directories during software installation or patch application.