Exporting ATT&CK Group Navigator Layers
Contents
Get Relationship STIX Objects - (Automatic)#
Retrieve all relationships#
from attackcti import attack_client
lift = attack_client()
%time all_relationships = lift.get_relationships()
all_relationships[0]
Retrieve all relationships from an specific STIX object#
groups = lift.get_groups()
%time group_relationships = lift.get_relationships_by_object(groups[0])
group_relationships[0]
Retrive Techniques used by one Group - (Manual)#
In this case we want relationship objects that have target_ref values of type attack-pattern. Following the manual code I shared above, and the results from the get_relationships_by_object()
function, you can simply query the ATT&CK Enterprise TAXIICollection source with the filter below
filter_objects = [
Filter('type', '=', 'attack-pattern'),
Filter('id', '=', [r.target_ref for r in group_relationships])
]
techniques_used = TC_ENTERPRISE_SOURCE.query(filter_objects)
techniques_used[0]
Retrive Techniques used by one Group - (Automatic)#
from attackcti import attack_client
lift = attack_client()
groups = lift.get_groups()
group_techniques = lift.get_techniques_used_by_group(groups[0])
group_techniques[0]
Retrive all Techniques used by all Groups - (Manual)#
You can apply the same get_techniques_used_by_group() function, but against all the groups STIX objects that the get_groups() function retrieves. You can do a simple for loop over more than 90 groups. However, it takes longer than what I would like it to take. Therefore, I decided to go a different route and started testing some code.
Get all groups and techniques#
from attackcti import attack_client
lift = attack_client()
groups = lift.get_groups()
techniques = lift.get_techniques()
Filter Group objects using techniques#
from stix2.utils import get_type_from_id
group_relationships = []
for rel in all_relationships:
if get_type_from_id(rel.source_ref) == 'intrusion-set'\
and get_type_from_id(rel.target_ref) == 'attack-pattern':
group_relationships.append(rel)
len(group_relationships)
print(group_relationships[0])
Match Group -> Relationships Intrusion-set ID#
Then, I just take all the group_relationships I got, and look for the specific intrusion-set (Group)
id in the groups STIX objects. Once there is a match, I create new fields on the intrusion-set (Group)
STIX object to add additional information about the attack-pattern (Technique)
in the relationship object. The most important additional metadata is the target_ref field which points to the specific attack-pattern (Technique)
id involving the group
. The results are then added to a new list named group_techniques_ref
.
import json
group_techniques_ref = []
for g in groups:
for rel in group_relationships:
if g['id'] == rel['source_ref']:
gs = json.loads(g.serialize())
gs
gs['technique_ref'] = rel['target_ref']
gs['relationship_description'] = rel['description']
gs['relationship_id'] = rel['id']
group_techniques_ref.append(gs)
Match Attack-patterns -> Intrusion-set object ID#
I apply the same concept as before, and just loop through all the attack-pattern objects and look for the specific attack-pattern id in the initial relationships STIX objects. Once there is a match, I add additional information from the attack-pattern itself to the python dictionaries in the group_techniques_ref
list. The results then get added to a new list named groups_use_techniques
.
groups_use_techniques = []
for gt in group_techniques_ref:
for t in techniques:
if gt['technique_ref'] == t['id']:
tactic_list = list()
for phase in t['kill_chain_phases']:
tactic_list.append(phase['phase_name'])
gt['technique'] = t['name']
gt['technique_description'] = t['description']
gt['tactic'] = tactic_list
gt['technique_id'] = t['external_references'][0]['external_id']
gt['matrix'] = t['external_references'][0]['source_name']
if 'x_mitre_platforms' in t.keys():
gt['platform'] = t['x_mitre_platforms']
if 'x_mitre_data_sources' in t.keys():
gt['data_sources'] = t['x_mitre_data_sources']
if 'x_mitre_permissions_required' in t.keys():
gt['permissions_required'] = t['x_mitre_permissions_required']
if 'x_mitre_effective_permissions' in t.keys():
gt['effective_permissions'] = t['x_mitre_effective_permissions']
groups_use_techniques.append(gt)
groups_use_techniques[0]
Retrive all Techniques used by all Groups - (Automatic)#
from attackcti import attack_client
lift = attack_client()
%time techniques_used = lift.get_techniques_used_by_all_groups()
len(techniques_used)
techniques_used[0]