-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add file
attack_nav_mod.py
and README.md
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Utility Scripts | ||
|
||
This folder contains additional resources that may be utilized in conjunction with the [MBC STIX2 repository](/README.md). | ||
|
||
| Script | Purpose | | ||
|:---|:---| | ||
| attack_nav_mod.py | This script will modify the MBC content by adding `"x_mitre_platforms": ["N/A"]` to all the attack-pattern objects to satisfy the ATT&K Navigator requirements. This field is not provided by MBC because the behaviors defined in the knowledge base do not contain platform specific information. The script will create a new local file that you can copy over to your navigator installation to create MBC layers. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import argparse | ||
import json | ||
import pathlib | ||
|
||
|
||
def update_content(mbc_path: pathlib.Path) -> None: | ||
""" | ||
This script is meant to locally modify the STIX2 MBC content into | ||
something the attack-navigator can support. Since MBC does not give | ||
details platforms, the field `x_mitre_platform` is not provided. | ||
""" | ||
with mbc_path.open("r", encoding="utf-8") as f: | ||
mbc_objects = json.load(f) | ||
|
||
for mbc_object in mbc_objects["objects"]: | ||
if mbc_object["type"] == "attack-pattern": | ||
mbc_object["x_mitre_platforms"] = ["N/A"] | ||
|
||
with open("mbc-attack-nav-modified.json", "w", encoding="utf-8") as f: | ||
json.dump(mbc_objects, f) | ||
|
||
|
||
def get_argparse() -> argparse.ArgumentParser: | ||
"""Defines argument parser for this script""" | ||
parser = argparse.ArgumentParser(description="Modify MBC content to be compatible with the ATT&CK Navigator") | ||
parser.add_argument("--mbc-content-location", | ||
type=lambda path: pathlib.Path(path), | ||
default=pathlib.Path("..", "mbc", "mbc.json")) | ||
return parser | ||
|
||
|
||
def main(): | ||
arg_parser = get_argparse() | ||
args = arg_parser.parse_args() | ||
update_content(args.mbc_content_location) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |