The returntosender rule detects potential adversary behavior involving the use of malicious payloads disguised as legitimate email attachments, leveraging Azure Sentinel to identify suspicious file execution patterns. SOC teams should proactively hunt for this behavior to uncover stealthy malware delivery methods that bypass traditional email security controls.
YARA Rule
rule returntosender {
strings: $ = "\\x2F\\x6D\\x65\\x64\\x69\\x61\\x2F\\x63\\x61\\x74\\x61\\x6C\\x6F\\x67\\x2F\\x70\\x72\\x6F\\x64\\x75\\x63\\x74\\x2F\\x63\\x61\\x63\\x68\\x65\\x2F\\x31\\x2F\\x74\\x68\\x75\\x6D\\x62\\x6E\\x61\\x69\\x6C\\x2F\\x37\\x30\\x30\\x78\\x2F\\x32\\x62\\x66\\x38\\x66\\x32\\x62\\x38\\x64\\x30\\x32\\x38\\x63\\x63\\x65\\x39\\x36\\x2F\\x42\\x2F\\x57\\x2F\\x64\\x61\\x34\\x31\\x38\\x30\\x33\\x63\\x63\\x39\\x38\\x34\\x62\\x38\\x63\\x2E\\x70\\x68\\x70"
condition: any of them
}
This YARA rule can be deployed in the following contexts:
Scenario: Scheduled System Backup Using Veeam
Description: A legitimate scheduled backup job using Veeam may generate traffic that matches the returntosender YARA rule due to the use of similar string patterns.
Filter/Exclusion: Exclude traffic originating from the Veeam backup server or processes with the veeam executable.
Scenario: Email Server Rejection of Malformed Emails Using Postfix
Description: Postfix email servers may trigger the rule when rejecting malformed or invalid emails, which can resemble malicious return paths.
Filter/Exclusion: Exclude traffic involving the postfix service or emails with the reject action in the SMTP protocol.
Scenario: Windows Task Scheduler Running Administrative Scripts
Description: Administrative scripts scheduled via the Windows Task Scheduler may use similar string patterns to the rule, leading to false positives.
Filter/Exclusion: Exclude processes launched by the schtasks.exe or Task Scheduler service.
Scenario: System Integrity Verification Using Windows Defender ATP
Description: Windows Defender ATP may generate alerts or logs that match the rule during system integrity checks or malware scans.
Filter/Exclusion: Exclude events related to Microsoft Defender for Endpoint or processes with the MsMpEng.exe executable.
Scenario: DNS Rebinding Testing Using DNSTools
Description: Security teams may use DNSTools or similar tools to perform DNS rebinding tests, which can trigger the rule due to similar network patterns.
Filter/Exclusion: Exclude traffic from known security testing tools or IPs used in internal red team exercises.