This detection identifies adversary activity involving the execution of PoetRat Python scripts, which are often used for initial reconnaissance and data exfiltration within cloud workloads. Proactively hunting for this behavior in Azure Sentinel is essential to uncover early-stage lateral movement or persistence mechanisms that may evade standard alerting due to their low severity classification.
rule PoetRat_Python
{
meta:
Author = "Nishan Maharjan"
Description = "A yara rule to catch PoetRat python scripts"
Data = "6th May 2020"
strings:
// Any of the strings that stand out in the files, these are for the multiple python files, not just for a single file
$encrptionFunction = "Affine"
$commands = /version|ls|cd|sysinfo|download|upload|shot|cp|mv|link|register|hid|compress|jobs|exit|tasklist|taskkill/
$domain = "dellgenius.hopto.org"
$grammer_massacre = /BADD|Bad Error Happened|/
$mayBePresent = /self\.DIE|THE_GUID_KEY/
$pipe_out = "Abibliophobia23"
$shot = "shot_{0}_{1}.png"
condition:
3 of them
}
This YARA rule can be deployed in the following contexts:
This rule contains 7 string patterns in its detection logic.
Here are 4 specific false positive scenarios for the PoetRat Python detection rule in an enterprise environment, along with suggested filters and exclusions:
Scenario: Automated Software Deployment via Ansible
ansible service spawns a Python process (python.exe) that executes custom modules involving network socket creation and file system enumeration, which mimics PoetRat’s reconnaissance behavior.ansible-runner.exe or ansible-playbook.exe, specifically when the command line contains arguments pointing to the standard Ansible installation path (e.g., C:\Program Files\Ansible\bin\python.exe).Scenario: Scheduled Data Backup Script using PowerShell
BackupAgent.py, is executed by the Windows Task Scheduler (TaskScheduler service). The script opens multiple file handles and establishes connections to an on-premise SQL database for logging, triggering the rule’s indicators of persistent data exfiltration.svchost.exe (specifically the Schedule service) where the process path matches C:\Scripts\BackupAgent\python.exe. Additionally, whitelist the specific hash of the known good BackupAgent.py script.Scenario: Enterprise Endpoint Protection Scanning
python.exe processes to analyze memory dumps, generating network traffic patterns identical to