Has poisoned PyPi packages with malicious code and has used a 13 file modular Python framework for data collection.1231
Python T1059.006
- Tactic
- Execution
- Platforms
- ESXi, Linux, macOS, Windows
- Version
- 1.1
- Created
- 09 March 2020
- Last modified
- 12 May 2026
Adversaries may abuse Python commands and scripts for execution. Python is a very popular scripting/programming language, with capabilities to perform many functions. Python can be executed interactively from the command-line (via the python.exe interpreter) or via scripts (.py) that can be written and distributed to different systems. Python code can also be compiled into binary executables.[1]
Python MITRE reference T1059.006
19 groups have been recorded using this technique. Newest first; each entry carries MITRE’s procedure text and a link to the group’s full record. Click a name to filter the rules below.
Has utilized Python scripts to execute its malicious payloads.1
Has used the Python-based malware such as InvisibleFerret to install and execute Python Packages and Python modules.123
Has used Python scripts to enumerate ESXi hosts and guest VMs.1
Has used a Python script to establish outbound communication and to execute commands using SMB port 445.1
Has used a customized version of the Impacket wmiexec.py module to create renamed output files.1
All 19 groups for this technique · 6 newest in this preview
4 campaigns have been recorded using this technique. Listed newest first; dates are year-granularity and attribution is MITRE’s.
During Cutting Edge, threat actors used a Python reverse shell and the PySoxy SOCKS5 proxy tool.12
During ShadowRay, threat actors used the Python pty module to open reverse shells.1
During Operation Wocao, threat actors' backdoors were written in Python and compiled with py2exe.1
During Salesforce Data Exfiltration, threat actors used custom applications developed in python.1
All 4 campaigns for this technique
40 software entries are documented implementing this technique. MITRE files each as a tool or as malware; newest first, then by how many groups carry them.
Has used a Python script as a second-stage backdoor.1
Has leveraged Python scripts to download additional payloads, engage in discovery, and to establish persistence.12334
Has searched the contents of two Python files scanner.py and scanner_legacy.py by searching for specific lines and replacing them with values that reduce their ability to track mismatches or new files.1
Is a Python-based script that executes within the victim environment.12
All 40 software entries for this technique · 6 newest in this preview
Offense vs defense T1059.006
Is defensive coverage keeping up with adversary use? Eight counts, each ranked against all 697 ATT&CK techniques. Attack sits left, defense right, so a shape leaning left means adversaries are better documented here than defenders are equipped. Hover any spoke for its percentile and the share of techniques that have more. The timeline below shows when each side arrived.
How it got here
Adversary activity (campaign spans) over cumulative rule output. Each source is plotted independently from zero, so neither line includes the other. Campaign dates are year-granularity.
Python detection strategy DET0063
MITRE names one behaviour worth catching for this technique and breaks it into 4 analytics, one per platform. Each carries the log sources it needs and the fields you tune per environment.
Cross-Platform Behavioral Detection of Python Execution
AN0172 · Windows
Detects Python execution via python.exe or py.exe with anomalous parent lineage (e.g., Office macros, LOLBAS), execution from unusual directories, or chained network/PowerShell/system-level activity.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | WinEventLog:Sysmon | EventCode=1 |
| Network Traffic ContentDC0085 | EDR:hunting | Advanced Hunting: DeviceProcessEvents + DeviceNetworkEvents |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| ParentProcess | Non-standard processes spawning python.exe (e.g., winword.exe, mshta.exe). |
| ScriptPath | Execution of .py from temp directories or user profile paths. |
| TimeWindow | Execution outside maintenance or patch windows. |
| UserContext | Execution by low-privileged or service accounts. |
| ChildProcess | Python spawning suspicious binaries or scripts (e.g., PowerShell, certutil). |
AN0173 · macOS
Detects native Python or framework-based execution from Terminal, embedded apps, or launchd jobs. Flags network calls, persistence writes, or system enumeration after Python launch.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Script ExecutionDC0029 | macos:unifiedlog | log stream --predicate 'eventMessage contains "python"' |
| Process CreationDC0032 | macos:osquery | process_events |
| Command ExecutionDC0064 | macos:syslog | system.log |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| ExecutionPath | Detects python scripts from ~/Downloads/, /Volumes/, or /tmp/. |
| ScriptName | Obfuscated or high entropy script names. |
| SpawnChain | Chained behavior: Python → bash → curl or Python → osascript. |
AN0174 · Linux
Detects Python execution from non-standard user contexts or cron jobs that invoke outbound traffic, access sensitive files, or perform process injection (e.g., ptrace or /proc memory maps).
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Script ExecutionDC0029 | linux:syslog | /var/log/syslog |
| Process CreationDC0032 | auditd:SYSCALL | execve |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| ScriptDir | Script invoked from /tmp, /var/tmp, or .hidden/ folders. |
| ScheduledContext | Execution from user cron or systemd timers outside of approved scripts. |
| NetworkActivity | Python performing HTTP/HTTPS without package updates. |
AN0175 · ESXi
Detects Python script or interpreter execution on ESXi hosts via embedded BusyBox shells, nested installations, or dropped files via SSH or datastore mount. Flags unusual scripting or post-compromise enumeration behavior.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | esxi:vobd | /var/log/vobd.log |
| Command ExecutionDC0064 | esxi:hostd | /var/log/hostd.log |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| ExecutionSource | Script loaded from mounted datastore, SSH upload, or dropped via guest-to-host tools. |
| HostUser | Python launched under root or unknown user. |
| InstallPath | Custom Python binaries or packages in non-default paths (/tmp/python/bin/python3). |
Anti-virus can be used to automatically quarantine suspicious files.
Inventory systems for unauthorized Python installations.
Denylist Python where not required.
Prevent users from installing Python where not required.
Tests from Atomic Red Team (MIT licence) · technique definition