diff --git a/src/README.md b/src/README.md new file mode 100644 index 00000000..08df60b7 --- /dev/null +++ b/src/README.md @@ -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. | diff --git a/src/attack_nav_mod.py b/src/attack_nav_mod.py new file mode 100644 index 00000000..566176b5 --- /dev/null +++ b/src/attack_nav_mod.py @@ -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()