Skip to content

Commit

Permalink
add file attack_nav_mod.py and README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanvg committed Aug 27, 2021
1 parent 7529482 commit 7026a38
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/README.md
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. |
39 changes: 39 additions & 0 deletions src/attack_nav_mod.py
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()

0 comments on commit 7026a38

Please sign in to comment.