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

Commit 73aefc1

Browse files
committed
merging develop into master
2 parents 41991c6 + 01a1cd5 commit 73aefc1

File tree

12 files changed

+71
-51
lines changed

12 files changed

+71
-51
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v1.5.2 - 2 September 2020
2+
## Improvements
3+
- Clarified documentation on creation of virtual environments for Windows compatibility.
4+
- Added section to install docs about taxii2client compatibility. See issue [#19](https://github.com/mitre-attack/attack-scripts/issues/19).
5+
- Standardized import style to better follow the standard set in [MITRE/CTI#103](https://github.com/mitre/cti/pull/103).
6+
17
# v1.5.1 - 27 July 2020
28
## New Scripts
39
- Added [layer to excel](https://github.com/mitre-attack/attack-scripts/tree/master/layers#to_excelpy) converter. See issue [#25](https://github.com/mitre-attack/attack-scripts/issues/25).

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ This repository contains various tools and utilities for working with ATT&CK con
99
- [python3](https://www.python.org/)
1010

1111
## Installation
12-
1. Create a new virtual environment: `python3 -m venv env`
13-
2. Activate the environment: `source env/bin/activate`
12+
1. Create virtual environment:
13+
- macOS and Linux: `python3 -m venv env`
14+
- Windows: `py -m venv env`
15+
2. Activate the virtual environment:
16+
- macOS and Linux: `source env/bin/activate`
17+
- Windows: `env/Scripts/activate.bat`
1418
3. Install requirements into the virtual environment: `pip3 install -r requirements.txt`
1519

20+
### taxii2client compatibility
21+
A recent update to the `taxii2client` python library changed the API for TAXII 2.0 requests. This repository has been updated to work with the latest version of taxii2client, however if your installed version is < 2.0.0 you may need to patch the scripts for them to run properly. Please see our [USAGE document on MITRE/CTI](https://github.com/mitre/cti/blob/master/USAGE.md#taxii2client) for more information.
22+
1623
## Related MITRE Work
1724
#### CTI
18-
[Cyber Threat Intelligence repository](https://github.com/mitre/cti) of the ATT&CK catalog expressed in STIX 2.0 JSON.
25+
[Cyber Threat Intelligence repository](https://github.com/mitre/cti) of the ATT&CK catalog expressed in STIX 2.0 JSON. This repository also contains [our USAGE document](https://github.com/mitre/cti/blob/master/USAGE.md) which includes additional examples of accessing and parsing our dataset in Python.
1926

2027
#### ATT&CK
2128
ATT&CK® is a curated knowledge base and model for cyber adversary behavior, reflecting the various phases of an adversary’s lifecycle and the platforms they are known to target. ATT&CK is useful for understanding security risk against known adversary behavior, for planning security improvements, and verifying defenses work as expected.

layers/exporters/matrix_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from stix2 import TAXIICollectionSource, Filter, MemoryStore
2-
from taxii2client import Server, Collection
2+
from taxii2client.v20 import Server, Collection
33

44

55
class DomainNotLoadedError(Exception):

requirements.txt

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
antlr4-python3-runtime==4.7.2
2+
cairocffi==1.1.0
3+
CairoSVG==2.4.2
24
certifi==2018.11.29
5+
cffi==1.14.1
36
chardet==3.0.4
7+
colour==0.1.5
8+
cssselect2==0.3.0
9+
defusedxml==0.6.0
10+
drawSvg==1.6.0
11+
et-xmlfile==1.0.1
412
idna==2.8
13+
imageio==2.9.0
14+
jdcal==1.4.1
15+
numpy==1.19.1
16+
openpyxl==3.0.3
17+
Pillow==7.2.0
18+
pycparser==2.20
519
python-dateutil==2.8.0
620
pytz==2018.9
721
requests==2.21.0
822
simplejson==3.16.0
9-
six==1.12.0
10-
stix2==1.1.2
23+
six==1.15.0
24+
stix2==2.0.2
1125
stix2-patterns==1.1.0
1226
tabulate==0.8.3
13-
taxii2-client==0.5.0
27+
taxii2-client==2.2.1
28+
tinycss2==1.0.2
1429
tqdm==4.31.1
1530
urllib3==1.24.2
16-
colour==0.1.5
17-
openpyxl==3.0.3
31+
webencodings==0.5.1

scripts/diff_stix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import argparse
22
from stix2 import MemoryStore, Filter, TAXIICollectionSource
3-
from taxii2client import Collection
3+
from taxii2client.v20 import Collection
44
import os
55
import json
66
from tqdm import tqdm

scripts/layers/samples/apt3_apt29_software.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import argparse
22
import requests
33
import json
4-
import stix2
4+
from stix2 import MemoryStore
55

66
def generate(show_nodetect=False):
77
"""
88
generate and return a layer dict showing techniques used by APT3 and APT29 as well as software used by those groups
99
param show_nodetect, if true, causes techniques that have no data-sources to be highlighted as well
1010
"""
1111
stix = requests.get("https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json").json()
12-
ms = stix2.MemoryStore(stix_data=stix["objects"])
12+
ms = MemoryStore(stix_data=stix["objects"])
1313
apt3 = ms.get("intrusion-set--0bbdf25b-30ff-4894-a1cd-49260d0dd2d9")
1414
apt29 = ms.get("intrusion-set--899ce53f-13a0-479b-a0e4-67d46e241542")
1515

scripts/layers/samples/bear_APT.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import argparse
22
import requests
33
import json
4-
import stix2
4+
from stix2 import MemoryStore, Filter
55
import re
66

77
def generate():
88
"""parse the STIX on MITRE/CTI and return a layer dict showing all techniques used by an APT group with phrase 'bear' in the group aliases."""
99
# import the STIX data from MITRE/CTI
1010
stix = requests.get("https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json").json()
11-
ms = stix2.MemoryStore(stix_data=stix["objects"])
11+
ms = MemoryStore(stix_data=stix["objects"])
1212

13-
groups = ms.query([ stix2.Filter("type", "=", "intrusion-set") ])
13+
groups = ms.query([ Filter("type", "=", "intrusion-set") ])
1414

1515
# find bear groups
1616
bear_groups = [] #list of groups with bear in name

scripts/layers/samples/heatmap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import argparse
22
import requests
33
import json
4-
import stix2
4+
from stix2 import MemoryStore, Filter
55
import random
66

77
def generate():
88
"""parse the STIX on MITRE/CTI and return a layer dict with techniques with randomized scores"""
99
# import the STIX data from MITRE/CTI
1010
stix = requests.get("https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json").json()
11-
ms = stix2.MemoryStore(stix_data=stix["objects"])
11+
ms = MemoryStore(stix_data=stix["objects"])
1212
# get all techniques in STIX
1313
techniques = ms.query([
14-
stix2.Filter("type", "=", "attack-pattern")
14+
Filter("type", "=", "attack-pattern")
1515
])
1616
# parse techniques into layer format
1717
techniques_list = []

scripts/layers/samples/software_execution.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import argparse
22
import requests
33
import json
4-
import stix2
4+
from stix2 import Filter, MemoryStore
55
from itertools import chain
66

77
def generate(softwaretype="software"):
@@ -10,13 +10,13 @@ def generate(softwaretype="software"):
1010
"""
1111
# import the STIX data from MITRE/CTI
1212
stix = requests.get("https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json").json()
13-
ms = stix2.MemoryStore(stix_data=stix["objects"])
13+
ms = MemoryStore(stix_data=stix["objects"])
1414
# software includes malware and tool types so perform two queries and merge the results
1515
software_filters = []
1616
if softwaretype == "malware" or softwaretype == "software":
17-
software_filters.append( [ stix2.Filter('type', '=', 'malware') ] )
17+
software_filters.append( [ Filter('type', '=', 'malware') ] )
1818
if softwaretype == "tool" or softwaretype == "software":
19-
software_filters.append( [ stix2.Filter('type', '=', 'tool') ] )
19+
software_filters.append( [ Filter('type', '=', 'tool') ] )
2020

2121
software = list(chain.from_iterable(
2222
ms.query(f) for f in software_filters

scripts/technique_mappings_to_csv.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import csv
33
import io
44

5-
import stix2
6-
import taxii2client
5+
from stix2 import TAXIICollectionSource, MemorySource, Filter
6+
from taxii2client.v20 import Collection
7+
78
import tqdm
89

910

@@ -15,18 +16,18 @@ def build_taxii_source(collection_name):
1516
"mobile_attack": "2f669986-b40b-4423-b720-4396ca6a462b"
1617
}
1718
collection_url = "https://cti-taxii.mitre.org/stix/collections/" + collection_map[collection_name] + "/"
18-
collection = taxii2client.Collection(collection_url)
19-
taxii_ds = stix2.TAXIICollectionSource(collection)
19+
collection = Collection(collection_url)
20+
taxii_ds = TAXIICollectionSource(collection)
2021

2122
# Create an in-memory source (to prevent multiple web requests)
22-
return stix2.MemorySource(stix_data=taxii_ds.query())
23+
return MemorySource(stix_data=taxii_ds.query())
2324

2425

2526
def get_all_techniques(src, source_name):
2627
"""Filters data source by attack-pattern which extracts all ATT&CK Techniques"""
2728
filters = [
28-
stix2.Filter("type", "=", "attack-pattern"),
29-
stix2.Filter("external_references.source_name", "=", source_name),
29+
Filter("type", "=", "attack-pattern"),
30+
Filter("external_references.source_name", "=", source_name),
3031
]
3132
results = src.query(filters)
3233
return remove_deprecated(results)
@@ -35,13 +36,13 @@ def get_all_techniques(src, source_name):
3536
def filter_for_term_relationships(src, relationship_type, object_id, target=True):
3637
"""Filters data source by type, relationship_type and source or target"""
3738
filters = [
38-
stix2.Filter("type", "=", "relationship"),
39-
stix2.Filter("relationship_type", "=", relationship_type),
39+
Filter("type", "=", "relationship"),
40+
Filter("relationship_type", "=", relationship_type),
4041
]
4142
if target:
42-
filters.append(stix2.Filter("target_ref", "=", object_id))
43+
filters.append(Filter("target_ref", "=", object_id))
4344
else:
44-
filters.append(stix2.Filter("source_ref", "=", object_id))
45+
filters.append(Filter("source_ref", "=", object_id))
4546

4647
results = src.query(filters)
4748
return remove_deprecated(results)
@@ -50,9 +51,9 @@ def filter_for_term_relationships(src, relationship_type, object_id, target=True
5051
def filter_by_type_and_id(src, object_type, object_id, source_name):
5152
"""Filters data source by id and type"""
5253
filters = [
53-
stix2.Filter("type", "=", object_type),
54-
stix2.Filter("id", "=", object_id),
55-
stix2.Filter("external_references.source_name", "=", source_name),
54+
Filter("type", "=", object_type),
55+
Filter("id", "=", object_id),
56+
Filter("external_references.source_name", "=", source_name),
5657
]
5758
results = src.query(filters)
5859
return remove_deprecated(results)

0 commit comments

Comments
 (0)