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 comes with many built-in packages to interact with the underlying system, such as file operations and device I/O. Adversaries can use these libraries to download and execute commands or other scripts as well as perform various malicious behaviors.
| ID | Name | Description |
|---|---|---|
| G0016 | APT29 | |
| G0067 | APT37 | |
| G0087 | APT39 |
APT39 has used a command line utility and a network scanner written in python.[4][5] |
| S0234 | Bandook |
Bandook can support commands to execute Python-based payloads.[6] |
| G0060 | BRONZE BUTLER |
BRONZE BUTLER has made use of Python-based remote access tools.[7] |
| S0482 | Bundlore | |
| S0631 | Chaes |
Chaes has used Python scripts for execution and the installation of additional files.[9] |
| G1021 | Cinnamon Tempest |
Cinnamon Tempest has used a customized version of the Impacket wmiexec.py module to create renamed output files.[10] |
| S0154 | Cobalt Strike |
Cobalt Strike can use Python to perform execution.[11][12][13][14] |
| S0369 | CoinTicker |
CoinTicker executes a Python script to download its second stage.[15] |
| G1052 | Contagious Interview |
Contagious Interview has used the Python-based malware such as InvisibleFerret to install and execute Python Packages and Python modules.[16][17][18] |
| S0492 | CookieMiner |
CookieMiner has used python scripts on the user’s system, as well as the Python variant of the Empire agent, EmPyre.[19] |
| C0029 | Cutting Edge |
During Cutting Edge, threat actors used a Python reverse shell and the PySoxy SOCKS5 proxy tool.[20][21] |
| S0695 | Donut |
Donut can generate shellcode outputs that execute via Python.[22] |
| G0035 | Dragonfly |
Dragonfly has used various types of scripting to perform operations, including Python scripts. The group was observed installing Python 2.7 on a victim.[23] |
| S0547 | DropBook |
DropBook is a Python-based backdoor compiled with PyInstaller.[24] |
| G1006 | Earth Lusca |
Earth Lusca used Python scripts for port scanning or building reverse shells.[25] |
| S0377 | Ebury | |
| S1120 | FRAMESTING |
FRAMESTING is a Python web shell that can embed in the Ivanti Connect Secure CAV Python package.[27] |
| S1245 | InvisibleFerret |
InvisibleFerret is written in Python and has used Python scripts for execution.[16][28][17][29][18] |
| S0581 | IronNetInjector |
IronNetInjector can use IronPython scripts to load payloads with the help of a .NET injector.[30] |
| S0387 | KeyBoy |
KeyBoy uses Python scripts for installing files and performing execution.[31] |
| S0276 | Keydnap |
Keydnap uses Python for scripting to execute additional commands.[32] |
| G0094 | Kimsuky |
Kimsuky has used a macOS Python implant to gather data as well as MailFetcher.py code to automatically collect email data.[33][34] |
| S0681 | Lizar |
Lizar has used Python scripts (ps2x.py script and ps2p.py) to execute files on remote hosts using the Impacket library.[35] |
| S1213 | Lumma Stealer |
Lumma Stealer has used malicious Python scripts to execute payloads.[36] |
| S0409 | Machete |
Machete is written in Python and is used in conjunction with additional Python scripts.[37][38][39] |
| G0095 | Machete |
Machete used multiple compiled Python scripts on the victim’s system. Machete's main backdoor Machete is also written in Python.[40][37][39] |
| S0459 | MechaFlounder |
MechaFlounder uses a python-based payload.[41] |
| G0069 | MuddyWater |
MuddyWater has developed tools in Python including Out1.[42] |
| S1189 | Neo-reGeorg |
Neo-reGeorg is a Python-based web shell.[43] |
| C0014 | Operation Wocao |
During Operation Wocao, threat actors' backdoors were written in Python and compiled with py2exe.[44] |
| S0428 | PoetRAT |
PoetRAT was executed with a Python script and worked in conjunction with additional Python-based post-exploitation tools.[45] |
| S0196 | PUNCHBUGGY |
PUNCHBUGGY has used python scripts.[46] |
| S0192 | Pupy |
Pupy can use an add on feature when creating payloads that allows you to create custom Python scripts ("scriptlets") to perform tasks offline (without requiring a session) such as sandbox detection, adding persistence, etc.[47] |
| S1032 | PyDCrypt |
PyDCrypt, along with its functions, is written in Python.[48] |
| S0583 | Pysa | |
| G1039 | RedCurl |
RedCurl has used a Python script to establish outbound communication and to execute commands using SMB port 445.[50] |
| S1187 | reGeorg | |
| S0332 | Remcos | |
| G0106 | Rocke |
Rocke has used Python-based malware to install and spread their coinminer.[53] |
| C0059 | Salesforce Data Exfiltration |
During Salesforce Data Exfiltration, threat actors used custom applications developed in python.[54] |
| C0045 | ShadowRay |
During ShadowRay, threat actors used the Python |
| S0692 | SILENTTRINITY |
SILENTTRINITY is written in Python and can use multiple Python scripts for execution on targeted systems.[56][57] |
| S1035 | Small Sieve |
Small Sieve can use Python scripts to execute commands.[58] |
| S0374 | SpeakUp | |
| S1223 | THINCRUST | |
| G0131 | Tonto Team |
Tonto Team has used Python-based tools for execution.[61] |
| S0647 | Turian |
Turian has the ability to use Python to spawn a Unix shell.[62] |
| G0010 | Turla |
Turla has used IronPython scripts as part of the IronNetInjector toolchain to drop payloads.[30] |
| G1048 | UNC3886 |
UNC3886 has used Python scripts to enumerate ESXi hosts and guest VMs.[63] |
| S1164 | UPSTYLE | |
| S1218 | VIRTUALPIE |
VIRTUALPIE is a Python-based backdoor malware.[66][67] |
| S1217 | VIRTUALPITA |
VIRTUALPITA can call a Python script to run commands on a targeted guest virtual machine.[66] |
| G0128 | ZIRCONIUM |
ZIRCONIUM has used Python-based implants to interact with compromised hosts.[68][1] |
| ID | Mitigation | Description |
|---|---|---|
| M1049 | Antivirus/Antimalware |
Anti-virus can be used to automatically quarantine suspicious files. |
| M1047 | Audit |
Inventory systems for unauthorized Python installations. |
| M1038 | Execution Prevention |
Denylist Python where not required. |
| M1033 | Limit Software Installation |
Prevent users from installing Python where not required. |
| ID | Name | Analytic ID | Analytic Description |
|---|---|---|---|
| DET0063 | Cross-Platform Behavioral Detection of Python Execution | AN0172 |
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. |
| AN0173 |
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. |
||
| AN0174 |
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). |
||
| AN0175 |
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. |