MITRE ATT&CK Python Library
mitreattack-python is a Python library developed by MITRE for working with ATT&CK data. It provides various tools and utilities for interacting with MITRE ATT&CK STIX 2.0 content, including functionalities for handling ATT&CK Navigator layers, converting ATT&CK data to Excel spreadsheets, and managing ATT&CK Collections. The library is actively maintained and frequently updated to align with the latest versions of the ATT&CK knowledge base, typically on a quarterly release cadence.
Common errors
-
ModuleNotFoundError: No module named 'mitreattack.stix20'
cause The main MitreAttackData class was reorganized in recent major versions, moving from a submodule (like `stix20`) to directly under the top-level `mitreattack` package.fixUpdate your import statement from `from mitreattack.stix20 import MitreAttackData` to `from mitreattack.MitreAttackData import MitreAttackData`. -
TypeError: tacticsToDf() got an unexpected keyword argument 'domain'
cause This error typically occurs when using older patterns or methods from the `attackToExcel` module, where the 'domain' argument might have been expected directly on a function that now infers it or uses a different argument structure, especially after updates to handle STIX 2.1 or newer ATT&CK versions.fixConsult the `mitreattack.attackToExcel` module's documentation for the current version to ensure correct usage of functions like `techniquesToDf()` or `tacticsToDf()`. The `MitreAttackData` object is initialized with the domain, and subsequent methods often operate on that initialized data without needing a repeated 'domain' argument.
Warnings
- breaking Version 5.0.0 and above of `mitreattack-python` requires Python 3.11 or newer. Projects running on older Python versions must upgrade or stick to `mitreattack-python` < 5.0.0.
- breaking With the October 2025 (v18) ATT&CK release, the underlying STIX schema for detections has changed significantly. 'Data Sources' and 'Data Components' are largely deprecated in favor of new 'Detection Strategies' and 'Analytics' objects. This impacts functions in modules like `diffStix` and methods interacting with detection-related data.
- gotcha When querying ATT&CK data, it's highly recommended to filter out 'revoked' and 'deprecated' objects as they are no longer actively maintained by MITRE. Not doing so can lead to unexpected results or outdated information.
Install
-
pip install mitreattack-python
Imports
- MitreAttackData
from mitreattack.stix20 import MitreAttackData
from mitreattack.MitreAttackData import MitreAttackData
- Layer
from mitreattack.navlayers import Layer
- attackToExcel
from mitreattack.attackToExcel import attackToExcel
Quickstart
from mitreattack.MitreAttackData import MitreAttackData
# Initialize with a specific domain (e.g., 'enterprise-attack', 'mobile-attack', 'ics-attack')
# The data will be downloaded and cached locally if not present.
attack_data = MitreAttackData("enterprise-attack")
# Get all techniques
techniques = attack_data.get_techniques()
print(f"Found {len(techniques)} Enterprise ATT&CK techniques.")
# Get a specific technique by ATT&CK ID
spec_technique = attack_data.get_techniques_by_attack_id("T1566.001")
if spec_technique:
print(f"\nSpecific Technique: {spec_technique[0].name} (ID: {spec_technique[0].attack_id})")
# Get all groups
groups = attack_data.get_groups()
print(f"\nFound {len(groups)} Enterprise ATT&CK groups.")