Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 5a62dd4

Browse files
committed
merging pull request #4
2 parents c37b0ba + 7a1a073 commit 5a62dd4

3 files changed

Lines changed: 69 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# V1.1 - 29 March 2019
2+
## New Scripts
3+
- Added [techniques_from_data_src.py](scripts/techniques_from_data_src.py).
4+
15
# V1.0 - 1 March 2019
26
## New Scripts
3-
- Added [techniques_data_sources_vis.py](scripts/techniques_data_sources_vis.py).
7+
- Added [techniques_data_sources_vis.py](scripts/techniques_data_sources_vis.py).

scripts/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ This folder contains one-off scripts for working with ATT&CK content. These scri
44

55
| script | description |
66
|:-------|:------------|
7-
| [techniques_data_sources_vis.py](techniques_data_sources_vis.py) | Generate the csv data used to create the "Techniques Mapped to Data Sources" visualization in the ATT&CK roadmap. Run `python techniques_data_sources_vis.py -h` for usage instructions. |
7+
| [techniques_from_data_src.py](techniques_from_data_src.py) | Fetches the current ATT&CK STIX 2.0 objects from the ATT&CK TAXII server, prints all of the data sources listed in Enterprise ATT&CK, and then lists all the Enterprise techniques containing a given data source. Run `python3 techniques_from_data_source -h` for usage instructions. |
8+
| [techniques_data_sources_vis.py](techniques_data_sources_vis.py) | Generate the csv data used to create the "Techniques Mapped to Data Sources" visualization in the ATT&CK roadmap. Run `python3 techniques_data_sources_vis.py -h` for usage instructions. |
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from stix2 import TAXIICollectionSource, Filter
2+
from taxii2client import Collection
3+
import argparse
4+
5+
# Establish TAXII2 Collection instance for Enterprise ATT&CK collection
6+
collection = Collection("https://cti-taxii.mitre.org/stix/collections/95ecc380-afe9-11e4-9b6c-751b66dd541e/")
7+
# Supply the collection to TAXIICollection
8+
tc_src = TAXIICollectionSource(collection)
9+
10+
def data_sources():
11+
"""returns all data sources in Enterprise ATT&CK"""
12+
all_data_srcs = []
13+
14+
# Get all techniques in Enterprise ATT&CK
15+
techniques = tc_src.query([Filter("type", "=", "attack-pattern")])
16+
17+
# Get all data sources in Enterprise ATT&CK
18+
for tech in techniques:
19+
if 'x_mitre_data_sources' in tech:
20+
all_data_srcs += [
21+
data_src for data_src in tech.x_mitre_data_sources
22+
if data_src not in all_data_srcs
23+
]
24+
25+
return all_data_srcs
26+
27+
def techniques(data_source):
28+
"""returns all techniques which contain the given data source."""
29+
# Get all techniques that have Windows Registry as a data source
30+
techs_with_data_src = tc_src.query([
31+
Filter("type", "=", "attack-pattern"),
32+
Filter("x_mitre_data_sources", "in", data_source)
33+
])
34+
35+
return techs_with_data_src
36+
37+
38+
39+
if __name__ == "__main__":
40+
41+
parser = argparse.ArgumentParser(
42+
description="Fetches the current ATT&CK STIX 2.0 objects from the ATT&CK TAXII server, prints all of the data sources listed in Enterprise ATT&CK, and then lists all the Enterprise techniques containing a given data source."
43+
)
44+
parser.add_argument("-data_source",
45+
type=str,
46+
default="Windows Registry",
47+
help="the datasource by which to filter techniques. Default value is '%(default)s'."
48+
)
49+
50+
args = parser.parse_args()
51+
52+
print("All data sources in Enterprise ATT&CK:\n")
53+
print("\n".join(data_sources()))
54+
print("\n")
55+
56+
selected_ds = "Windows Registry"
57+
technique_list = techniques(args.data_source)
58+
# Get names of techniques
59+
tech_names = [tech.name for tech in technique_list]
60+
61+
print(f"The following {len(tech_names)} techniques use '{args.data_source}' as a data source:\n")
62+
print("\n".join(tech_names))

0 commit comments

Comments
 (0)