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.
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.[3][4] |
S0234 | Bandook |
Bandook can support commands to execute Python-based payloads.[5] |
G0060 | BRONZE BUTLER |
BRONZE BUTLER has made use of Python-based remote access tools.[6] |
S0482 | Bundlore | |
S0631 | Chaes |
Chaes has used Python scripts for execution and the installation of additional files.[8] |
S0154 | Cobalt Strike |
Cobalt Strike can use Python to perform execution.[9][10][11][12] |
S0369 | CoinTicker |
CoinTicker executes a Python script to download its second stage.[13] |
S0492 | CookieMiner |
CookieMiner has used python scripts on the user’s system, as well as the Python variant of the Empire agent, EmPyre.[14] |
S0695 | Donut |
Donut can generate shellcode outputs that execute via Python.[15] |
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.[16] |
S0547 | DropBook |
DropBook is a Python-based backdoor compiled with PyInstaller.[17] |
S0377 | Ebury | |
S0581 | IronNetInjector |
IronNetInjector can use IronPython scripts to load payloads with the help of a .NET injector.[19] |
S0387 | KeyBoy |
KeyBoy uses Python scripts for installing files and performing execution.[20] |
S0276 | Keydnap |
Keydnap uses Python for scripting to execute additional commands.[21] |
G0094 | Kimsuky |
Kimsuky has used a macOS Python implant to gather data as well as MailFetcher.py code to automatically collect email data.[22][23] |
S0409 | Machete |
Machete is written in Python and is used in conjunction with additional Python scripts.[24][25][26] |
G0095 | Machete |
Machete used multiple compiled Python scripts on the victim’s system. Machete's main backdoor Machete is also written in Python.[27][24][26] |
S0459 | MechaFlounder |
MechaFlounder uses a python-based payload.[28] |
G0069 | MuddyWater |
MuddyWater has used developed tools in Python including Out1.[29] |
G0116 | Operation Wocao |
Operation Wocao's backdoors have been written in Python and compiled with py2exe.[30] |
S0428 | PoetRAT |
PoetRAT was executed with a Python script and worked in conjunction with additional Python-based post-exploitation tools.[31] |
S0196 | PUNCHBUGGY |
PUNCHBUGGY has used python scripts.[32] |
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.[33] |
S0583 | Pysa | |
S0332 | Remcos | |
G0106 | Rocke |
Rocke has used Python-based malware to install and spread their coinminer.[36] |
S0692 | SILENTTRINITY |
SILENTTRINITY is written in Python and can use multiple Python scripts for execution on targeted systems.[37][38] |
S0374 | SpeakUp | |
G0131 | Tonto Team |
Tonto Team has used Python-based tools for execution.[40] |
S0609 | TRITON |
TRITON was run as trilog.exe, a Py2EXE compiled python script that accepts a single IP address as a flag.[41] |
S0647 | Turian |
Turian has the ability to use Python to spawn a Unix shell.[42] |
G0010 | Turla |
Turla has used IronPython scripts as part of the IronNetInjector toolchain to drop payloads.[19] |
G0128 | ZIRCONIUM |
ZIRCONIUM has used Python-based implants to interact with compromised hosts.[43][44] |
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 | Data Source | Data Component |
---|---|---|
DS0017 | Command | Command Execution |
DS0009 | Process | Process Creation |
Monitor systems for abnormal Python usage and python.exe behavior, which could be an indicator of malicious activity. Understanding standard usage patterns is important to avoid a high number of false positives. If scripting is restricted for normal users, then any attempts to enable scripts running on a system would be considered suspicious. If scripts are not commonly used on a system, but enabled, scripts running out of cycle from patching or other administrator functions are suspicious. Scripts should be captured from the file system when possible to determine their actions and intent.
Scripts are likely to perform actions with various effects on a system that may generate events, depending on the types of monitoring used. Monitor processes and command-line arguments for script execution and subsequent behavior. Actions may be related to network and system information Discovery, Collection, or other scriptable post-compromise behaviors and could be used as indicators of detection leading back to the source script.