This rule identifies executables that have been packed or modified using the UPX packer with a non-standard or altered stub, a common technique adversaries employ to compress malware and evade static signature-based detection. Proactively hunting for these artifacts allows the SOC to uncover stealthy payloads that may be hiding in memory or on disk, ensuring that compressed binaries are properly unpacked and analyzed to reveal their true malicious behavior.
rule UPXModifiedstub
{
meta:
author="malware-lu"
strings:
$a0 = { 79 07 0F B7 07 47 50 47 B9 57 48 F2 AE 55 FF 96 84 ?? 00 00 09 C0 74 07 89 03 83 C3 04 EB D8 FF 96 88 ?? 00 00 61 E9 [3] FF }
condition:
$a0 at pe.entry_point
}
This YARA rule can be deployed in the following contexts:
This rule contains 1 string patterns in its detection logic.
C:\Builds\Release\, /opt/app/bin/) or filter by file extension (.exe, .dll) combined with a known hash list of approved compressed binaries.Sysinternals tools or a custom internal script) using a patched version of UPX to reduce file size for distribution over a slow network link, resulting in a modified stub that differs from standard UPX signatures.
svc_deploy, admin_build) or filter by directory paths associated with shared network drives used for tool distribution (e.g., \\fileserver\tools\, C:\Program Files\InternalTools\).devenv.exe or code.exe) or exclude binaries with specific PE section names that indicate custom packing (e.g., sections named .custom_stub or .meta).