T1059.006: Command and Scripting Interpreter: Python
T1059.006 (Command and Scripting Interpreter: Python) is classified under the Execution tactic within the MITRE ATT&CK framework. Techniques that result in adversary-controlled code running on a local or remote target system, including command-line interpreters, PowerShell payloads, and native binary proxy execution. In telemetry gathered across enterprise endpoints and the EMBER 2018 benchmark, this technique was weaponized across 5 distinct malware families, totaling over 74 validated samples.
Technical Anatomy & Adversary Tradecraft
Adversaries leverage Command and Scripting Interpreter: Python to accomplish operational objectives while minimizing anomalous forensic footprints. When executing Command and Scripting Interpreter: Python, malicious binaries commonly interact directly with low-level Windows APIs, kernel mode drivers, or native scripting interfaces to bypass traditional file-integrity monitors and static antivirus signatures.
In modern multi-stage campaigns, T1059.006 is frequently observed functioning as an intermediate bridge: initial access payloads (such as spearphishing loaders or exploit macros) execute Command and Scripting Interpreter: Python to establish in-memory execution or persistence before staging secondary ransomware or data-exfiltration implants.
https://attack.mitre.org/techniques/T1059/006/.
Detection Engineering & Threat Hunting
Detecting Command and Scripting Interpreter: Python requires telemetry correlation across endpoint detection and response (EDR) agents, Sysmon event streams, and security information event management (SIEM) pipelines:
- Process Creation & Lineage: Monitor parent-child process anomalies where unexpected parent binaries (e.g., Office executables, web browsers, or script hosts) spawn command shells or native Windows utilities.
- API Hooking & Behavioral Telemetry: EDR platforms should flag rapid calls to memory allocation, process injection, or registry manipulation APIs originating from unbacked executable memory regions.
- Network Anomaly Correlation: Cross-reference endpoint execution timestamps with external network socket establishment to identify anomalous beaconing or covert data staging.
SOC Containment & Hardening Guidance
To mitigate risks associated with T1059.006 (Command and Scripting Interpreter: Python) across production infrastructure, security teams should implement the following defensive controls:
- Attack Surface Reduction (ASR): Enforce strict application control policies (WDAC or AppLocker) to restrict execution to signed and verified corporate binaries.
- Least Privilege & Credential Hygiene: Restrict local administrative privileges to prevent adversaries from tampering with defensive agents or escalating privileges.
- Network Microsegmentation: Restrict lateral communication across endpoint VLANs to prevent wormable payloads from utilizing Command and Scripting Interpreter: Python across adjacent network segments.
Cataloged Malware Families Utilizing T1059.006 (5 Families)
The following malware families in the SystemHelpDesk catalog have been verified utilizing T1059.006 (Command and Scripting Interpreter: Python):
| Family | Category | Sample Count | Technical Summary |
|---|---|---|---|
| pynamer | Trojan | 67 | Pynamer (cataloged across security vendors and threat intelligence databases under signatures including Trojan:Win32/Pynamer, Trojan.Pynamer, and Trojan:Win32/P... |
| pyfiledel | Ransomware | 4 | Trojan:Python/Pyfiledel is a highly destructive malware classified as a **Wiper**. Unlike ransomware, which encrypts files with the intention of extorting money... |
| pycrypter | Ransomware | 1 | <h3>Executive Summary</h3> PyCrypter is a classification for file-encrypting Ransomware written entirely in Python. While traditionally ransomware was written i... |
| pyinstaller | Ransomware | 1 | <h3>Executive Summary</h3> PyInstaller is not malware. It is a highly popular, legitimate, open-source utility used by developers to bundle Python scripts and t... |
| pyspy | Trojan | 1 | TrojanSpy:Python/Pyspy represents a growing trend in malware development: threats written entirely in the Python programming language. Attackers leverage Python... |