This rule detects adversaries utilizing the exe2hex utility to convert executable files into hexadecimal strings for covert data exfiltration or command-and-control communication. A proactive hunt is essential in Azure Sentinel because this technique often bypasses traditional signature-based defenses by disguising malicious payloads as benign text, allowing attackers to move laterally undetected within the cloud environment.
rule Payload_Exe2Hex : toolkit {
meta:
description = "Detects payload generated by exe2hex"
author = "Florian Roth"
reference = "https://github.com/g0tmi1k/exe2hex"
date = "2016-01-15"
score = 70
strings:
$a1 = "set /p \"=4d5a" ascii
$a2 = "powershell -Command \"$hex=" ascii
$b1 = "set+%2Fp+%22%3D4d5" ascii
$b2 = "powershell+-Command+%22%24hex" ascii
$c1 = "echo 4d 5a " ascii
$c2 = "echo r cx >>" ascii
$d1 = "echo+4d+5a+" ascii
$d2 = "echo+r+cx+%3E%3E" ascii
condition:
all of ($a*) or all of ($b*) or all of ($c*) or all of ($d*)
}
This YARA rule can be deployed in the following contexts:
This rule contains 9 string patterns in its detection logic.
Here are 5 specific false positive scenarios for the Detects payload generated by exe2hex rule, including suggested filters and exclusions:
Scenario: Automated Backup Script Execution
exe2hex as part of the pipeline, triggering the rule every night at 02:00 AM.powershell.exe) and Command Line containing the string exe2hex, restricted to a specific Scheduled Task ID (e.g., \Microsoft\Windows\Backup\NightlyHexConversion). Alternatively, exclude the rule for traffic originating from the specific backup server hostname.Scenario: Software Deployment via SCCM/Intune
exe2hex is used to verify the integrity of the installer binary before execution on 50+ workstations simultaneously.ccmsetup.exe or intunagent.exe. Additionally, filter by User Context, ensuring the process runs under a known service account (e.g., DOMAIN\SCCM-Deploy-Svc) rather than interactive user accounts.Scenario: Digital Forensics and Incident Response
exe2hex locally to generate a hex dump of the suspicious process memory for offline analysis, causing the detection engine to