2019-03-29 14:26:25 +00:00
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import signal
|
2019-12-09 14:26:48 +00:00
|
|
|
from interactive_menu import *
|
2020-03-10 07:48:03 +00:00
|
|
|
from editor import DeTTECTEditor
|
2020-06-29 13:52:26 +00:00
|
|
|
import generic
|
2019-03-29 14:26:25 +00:00
|
|
|
|
|
|
|
|
2019-07-31 08:14:47 +00:00
|
|
|
def _init_menu():
|
2019-03-29 14:26:25 +00:00
|
|
|
"""
|
|
|
|
Initialise the command line parameter menu.
|
|
|
|
:return:
|
|
|
|
"""
|
2019-04-08 05:24:38 +00:00
|
|
|
menu_parser = argparse.ArgumentParser(description='Detect Tactics, Techniques & Combat Threats',
|
2019-07-08 08:39:15 +00:00
|
|
|
epilog='Source: https://github.com/rabobank-cdc/DeTTECT')
|
2019-03-29 14:26:25 +00:00
|
|
|
menu_parser.add_argument('--version', action='version', version='%(prog)s ' + VERSION)
|
|
|
|
menu_parser.add_argument('-i', '--interactive', help='launch the interactive menu, which has support for all modes',
|
|
|
|
action='store_true')
|
|
|
|
|
|
|
|
# add subparsers
|
|
|
|
subparsers = menu_parser.add_subparsers(title='MODE',
|
|
|
|
description='Select the mode to use. Every mode has its own arguments and '
|
2020-02-20 11:02:27 +00:00
|
|
|
'help info displayed using: {editor, datasource, visibility, detection, '
|
|
|
|
'group, generic} --help', metavar='', dest='subparser')
|
|
|
|
|
2020-03-04 09:45:00 +00:00
|
|
|
parser_editor = subparsers.add_parser('editor', aliases=['e'], help='DeTT&CT Editor',
|
|
|
|
description='Start the DeTT&CT Editor for easy editing the YAML administration files.')
|
2020-02-20 11:02:27 +00:00
|
|
|
parser_editor.add_argument('-p', '--port', help='port where the webserver listens on (default is 8080)', required=False, default=8080)
|
2019-03-29 14:26:25 +00:00
|
|
|
|
|
|
|
# create the data source parser
|
|
|
|
parser_data_sources = subparsers.add_parser('datasource', help='data source mapping and quality',
|
|
|
|
aliases=['ds'],
|
|
|
|
description='Create a heat map based on data sources, output data '
|
|
|
|
'sources to Excel or generate a data source improvement '
|
|
|
|
'graph.')
|
2019-07-31 08:14:47 +00:00
|
|
|
parser_data_sources.add_argument('-ft', '--file-tech', help='path to the technique administration YAML file '
|
2019-08-08 12:17:31 +00:00
|
|
|
'(used with the option \'-u, --update\' to update '
|
|
|
|
'the visibility scores)',
|
2019-07-31 08:14:47 +00:00
|
|
|
required=False)
|
|
|
|
parser_data_sources.add_argument('-fd', '--file-ds', help='path to the data source administration YAML file',
|
2019-03-29 14:26:25 +00:00
|
|
|
required=True)
|
2019-08-08 12:17:31 +00:00
|
|
|
parser_data_sources.add_argument('-s', '--search', help='only include data sources which match the provided EQL '
|
|
|
|
'query')
|
2019-03-29 14:26:25 +00:00
|
|
|
parser_data_sources.add_argument('-l', '--layer', help='generate a data source layer for the ATT&CK navigator',
|
|
|
|
action='store_true')
|
|
|
|
parser_data_sources.add_argument('-e', '--excel', help='generate an Excel sheet with all data source',
|
|
|
|
action='store_true')
|
|
|
|
parser_data_sources.add_argument('-g', '--graph', help='generate a graph with data sources added through time',
|
|
|
|
action='store_true')
|
|
|
|
parser_data_sources.add_argument('-y', '--yaml', help='generate a technique administration YAML file with '
|
|
|
|
'visibility scores based on the number of available data '
|
2019-07-31 08:14:47 +00:00
|
|
|
'sources', action='store_true')
|
2019-12-09 14:26:48 +00:00
|
|
|
parser_data_sources.add_argument('-ya', '--yaml-all-techniques', help='include all ATT&CK techniques in the '
|
2019-12-11 09:43:08 +00:00
|
|
|
'generated YAML file (when the argument -y, --yaml is provided) that apply '
|
|
|
|
'to the platform(s) specified in the data source YAML file', action='store_true')
|
2019-07-31 08:14:47 +00:00
|
|
|
parser_data_sources.add_argument('-u', '--update', help='update the visibility scores within a technique '
|
|
|
|
'administration YAML file based on changes within any of '
|
|
|
|
'the data sources. Past visibility scores are preserved in '
|
2019-08-08 12:17:31 +00:00
|
|
|
'the \'score_logbook\', and manually assigned scores are '
|
|
|
|
'not updated without your approval. The updated visibility '
|
2019-07-31 08:14:47 +00:00
|
|
|
'scores are calculated in the same way as with the option: '
|
2019-08-08 12:17:31 +00:00
|
|
|
'-y, --yaml', action='store_true')
|
2020-06-08 14:56:56 +00:00
|
|
|
parser_data_sources.add_argument('-of', '--output-filename', help='set the output filename')
|
|
|
|
parser_data_sources.add_argument('-ln', '--layer-name', help='set the name of the Navigator layer')
|
2019-08-20 09:14:07 +00:00
|
|
|
parser_data_sources.add_argument('--health', help='check the YAML file(s) for errors', action='store_true')
|
2020-06-29 13:52:26 +00:00
|
|
|
parser_data_sources.add_argument('--local-stix-path', help='path to a local STIX repository to use DeTT&CT offline '
|
|
|
|
'or to use a specific version of STIX objects.')
|
2020-07-10 06:14:51 +00:00
|
|
|
parser_data_sources.add_argument('--update-to-sub-techniques', help='Update the technique administration YAML file '
|
2020-06-29 13:52:26 +00:00
|
|
|
'to ATT&CK with sub-techniques.', action='store_true')
|
2019-03-29 14:26:25 +00:00
|
|
|
|
|
|
|
# create the visibility parser
|
|
|
|
parser_visibility = subparsers.add_parser('visibility', aliases=['v'],
|
|
|
|
help='visibility coverage mapping based on techniques and data sources',
|
2019-05-20 12:49:35 +00:00
|
|
|
description='Create a heat map based on visibility scores, overlay '
|
|
|
|
'visibility with detections, output to Excel or check the '
|
|
|
|
'health of the technique administration YAML file.')
|
2019-03-29 14:26:25 +00:00
|
|
|
parser_visibility.add_argument('-ft', '--file-tech', help='path to the technique administration YAML file (used to '
|
|
|
|
'score the level of visibility)', required=True)
|
|
|
|
parser_visibility.add_argument('-fd', '--file-ds', help='path to the data source administration YAML file (used to '
|
2019-04-10 08:08:30 +00:00
|
|
|
'add metadata on the involved data sources)')
|
2019-08-08 12:17:31 +00:00
|
|
|
parser_visibility.add_argument('-sd', '--search-detection', help='only include detection objects which match the '
|
|
|
|
'provided EQL query')
|
|
|
|
parser_visibility.add_argument('-sv', '--search-visibility', help='only include visibility objects which match the '
|
|
|
|
'provided EQL query')
|
|
|
|
parser_visibility.add_argument('--all-scores', help='include all \'score\' objects from the \'score_logbook\' in '
|
|
|
|
'the EQL search. The default behaviour is to only include the '
|
|
|
|
'most recent \'score\' objects',
|
|
|
|
action='store_true', default=False)
|
2019-03-29 14:26:25 +00:00
|
|
|
parser_visibility.add_argument('-l', '--layer', help='generate a visibility layer for the ATT&CK navigator',
|
|
|
|
action='store_true')
|
2019-04-10 08:08:30 +00:00
|
|
|
parser_visibility.add_argument('-e', '--excel', help='generate an Excel sheet with all administrated techniques',
|
2019-07-31 08:14:47 +00:00
|
|
|
action='store_true')
|
2019-05-20 12:54:16 +00:00
|
|
|
parser_visibility.add_argument('-o', '--overlay', help='generate a visibility layer overlaid with detections for '
|
2019-04-24 07:50:19 +00:00
|
|
|
'the ATT&CK navigator', action='store_true')
|
2019-08-20 09:14:07 +00:00
|
|
|
parser_visibility.add_argument('-g', '--graph', help='generate a graph with visibility added through time',
|
|
|
|
action='store_true')
|
2020-06-08 14:56:56 +00:00
|
|
|
parser_visibility.add_argument('-of', '--output-filename', help='set the output filename')
|
|
|
|
parser_visibility.add_argument('-ln', '--layer-name', help='set the name of the Navigator layer')
|
2019-08-20 09:14:07 +00:00
|
|
|
parser_visibility.add_argument('--health', help='check the YAML file for errors', action='store_true')
|
2020-06-29 13:52:26 +00:00
|
|
|
parser_visibility.add_argument('--local-stix-path', help='path to a local STIX repository to use DeTT&CT offline '
|
|
|
|
'or to use a specific version of STIX objects.')
|
2020-07-10 06:14:51 +00:00
|
|
|
parser_visibility.add_argument('--update-to-sub-techniques', help='Update the technique administration YAML file '
|
2020-06-29 13:52:26 +00:00
|
|
|
'to ATT&CK with sub-techniques.', action='store_true')
|
2019-03-29 14:26:25 +00:00
|
|
|
|
|
|
|
# create the detection parser
|
|
|
|
parser_detection = subparsers.add_parser('detection', aliases=['d'],
|
|
|
|
help='detection coverage mapping based on techniques',
|
|
|
|
description='Create a heat map based on detection scores, overlay '
|
2020-06-29 13:52:26 +00:00
|
|
|
'detections with visibility, generate a detection '
|
|
|
|
'improvement graph, output to Excel or check the health of '
|
2019-05-20 12:49:35 +00:00
|
|
|
'the technique administration YAML file.')
|
2019-03-29 14:26:25 +00:00
|
|
|
parser_detection.add_argument('-ft', '--file-tech', help='path to the technique administration YAML file (used to '
|
2019-07-31 08:14:47 +00:00
|
|
|
'score the level of detection)', required=True)
|
2019-03-29 14:26:25 +00:00
|
|
|
parser_detection.add_argument('-fd', '--file-ds', help='path to the data source administration YAML file (used in '
|
|
|
|
'the overlay with visibility to add metadata on the '
|
|
|
|
'involved data sources)')
|
2019-08-08 12:17:31 +00:00
|
|
|
parser_detection.add_argument('-sd', '--search-detection', help='only include detection objects which match the '
|
|
|
|
'provided EQL query')
|
|
|
|
parser_detection.add_argument('-sv', '--search-visibility', help='only include visibility objects which match the '
|
|
|
|
'provided EQL query')
|
|
|
|
parser_detection.add_argument('--all-scores', help='include all \'score\' objects from the \'score_logbook\' in '
|
|
|
|
'the EQL search. The default behaviour is to only include the '
|
|
|
|
'most recent \'score\' objects',
|
|
|
|
action='store_true', default=False)
|
2019-04-18 13:32:35 +00:00
|
|
|
parser_detection.add_argument('-l', '--layer', help='generate detection layer for the ATT&CK navigator',
|
2019-03-29 14:26:25 +00:00
|
|
|
action='store_true')
|
2019-04-10 08:08:30 +00:00
|
|
|
parser_detection.add_argument('-e', '--excel', help='generate an Excel sheet with all administrated techniques',
|
2019-07-31 08:14:47 +00:00
|
|
|
action='store_true')
|
2019-05-20 12:54:16 +00:00
|
|
|
parser_detection.add_argument('-o', '--overlay', help='generate a detection layer overlaid with visibility for '
|
2019-04-24 07:50:19 +00:00
|
|
|
'the ATT&CK navigator', action='store_true')
|
2019-08-20 09:14:07 +00:00
|
|
|
parser_detection.add_argument('-g', '--graph', help='generate a graph with detections added through time',
|
2019-03-29 14:26:25 +00:00
|
|
|
action='store_true')
|
2020-06-08 14:56:56 +00:00
|
|
|
parser_detection.add_argument('-of', '--output-filename', help='set the output filename')
|
|
|
|
parser_detection.add_argument('-ln', '--layer-name', help='set the name of the Navigator layer')
|
2019-08-20 09:14:07 +00:00
|
|
|
parser_detection.add_argument('--health', help='check the YAML file(s) for errors', action='store_true')
|
2020-06-29 13:52:26 +00:00
|
|
|
parser_detection.add_argument('--local-stix-path', help='path to a local STIX repository to use DeTT&CT offline '
|
|
|
|
'or to use a specific version of STIX objects.')
|
2020-07-10 06:14:51 +00:00
|
|
|
parser_detection.add_argument('--update-to-sub-techniques', help='Update the technique administration YAML file '
|
2020-06-29 13:52:26 +00:00
|
|
|
'to ATT&CK with sub-techniques.', action='store_true')
|
2019-03-29 14:26:25 +00:00
|
|
|
|
|
|
|
# create the group parser
|
|
|
|
parser_group = subparsers.add_parser('group', aliases=['g'],
|
|
|
|
description='Create threat actor group heat maps, compare group(s) and '
|
2020-06-29 13:52:26 +00:00
|
|
|
'compare group(s) with visibility and detection coverage.',
|
2019-03-29 14:26:25 +00:00
|
|
|
help='threat actor group mapping')
|
2019-08-08 12:17:31 +00:00
|
|
|
parser_group.add_argument('-g', '--groups', help='specify the ATT&CK Groups to include separated using commas. '
|
2019-03-29 14:26:25 +00:00
|
|
|
'Group can be their ID, name or alias (default is all groups). '
|
|
|
|
'Other option is to provide a YAML file with a custom group(s) '
|
|
|
|
'(default = all)',
|
|
|
|
default='all')
|
|
|
|
parser_group.add_argument('-o', '--overlay', help='specify what to overlay on the group(s) (provided using the '
|
|
|
|
'arguments \'-g/--groups\'): group(s), visibility or detection. '
|
2019-08-08 12:17:31 +00:00
|
|
|
'When overlaying a GROUP: the group can be their ATT&CK ID, name '
|
|
|
|
'or alias separated using commas. Or provide a file path of a '
|
|
|
|
'YAML file with a custom group(s). When overlaying VISIBILITY or '
|
|
|
|
'DETECTION provide a YAML with the technique administration.')
|
2019-03-29 14:26:25 +00:00
|
|
|
parser_group.add_argument('-t', '--overlay-type', help='specify the type of overlay (default = group)',
|
|
|
|
choices=['group', 'visibility', 'detection'], default='group')
|
|
|
|
parser_group.add_argument('--software-group', help='add techniques to the heat map by checking which software is '
|
|
|
|
'used by group(s), and hence which techniques the software '
|
|
|
|
'supports (does not influence the scores). If overlay group(s) '
|
|
|
|
'are provided, only software related to those group(s) are '
|
|
|
|
'included', action='store_true', default=False)
|
|
|
|
parser_group.add_argument('-p', '--platform', help='specify the platform (default = Windows)',
|
2019-11-04 13:48:58 +00:00
|
|
|
choices=['all'] + list(PLATFORMS.values()), default='Windows')
|
2019-03-29 14:26:25 +00:00
|
|
|
parser_group.add_argument('-s', '--stage', help='specify the stage (default = attack)',
|
|
|
|
choices=['attack', 'pre-attack'], default='attack')
|
2019-08-08 12:17:31 +00:00
|
|
|
parser_group.add_argument('-sd', '--search-detection', help='only include detection objects which match the '
|
|
|
|
'provided EQL query')
|
|
|
|
parser_group.add_argument('-sv', '--search-visibility', help='only include visibility objects which match the '
|
|
|
|
'provided EQL query')
|
|
|
|
parser_group.add_argument('--all-scores', help='include all \'score\' objects from the \'score_logbook\' in '
|
|
|
|
'the EQL search. The default behaviour is to only include the '
|
|
|
|
'most recent \'score\' objects',
|
|
|
|
action='store_true', default=False)
|
2020-06-08 14:56:56 +00:00
|
|
|
parser_group.add_argument('-of', '--output-filename', help='set the output filename')
|
|
|
|
parser_group.add_argument('-ln', '--layer-name', help='set the name of the Navigator layer')
|
2019-08-20 09:14:07 +00:00
|
|
|
parser_group.add_argument('--health', help='check the YAML file(s) for errors', action='store_true')
|
2020-06-29 13:52:26 +00:00
|
|
|
parser_group.add_argument('--local-stix-path', help='path to a local STIX repository to use DeTT&CT offline '
|
|
|
|
'or to use a specific version of STIX objects.')
|
2020-07-10 06:14:51 +00:00
|
|
|
parser_group.add_argument('--update-to-sub-techniques', help='Update the technique administration YAML file '
|
2020-06-29 13:52:26 +00:00
|
|
|
'to ATT&CK with sub-techniques.', action='store_true')
|
2019-03-29 14:26:25 +00:00
|
|
|
|
|
|
|
# create the generic parser
|
|
|
|
parser_generic = subparsers.add_parser('generic', description='Generic functions which will output to stdout.',
|
|
|
|
help='includes: statistics on ATT&CK data source and updates on techniques'
|
2020-06-29 13:52:26 +00:00
|
|
|
', groups and software', aliases=['ge'])
|
2019-03-29 14:26:25 +00:00
|
|
|
|
2019-08-01 13:02:06 +00:00
|
|
|
parser_generic.add_argument('-ds', '--datasources', help='get a sorted count on how many ATT&CK Enterprise '
|
|
|
|
'techniques are covered by a particular Data Source',
|
|
|
|
action='store_true')
|
|
|
|
parser_generic.add_argument('-m', '--mitigations', help='get a sorted count on how many ATT&CK Enterprise or '
|
|
|
|
'Mobile techniques are covered by a Mitigation',
|
|
|
|
choices=['enterprise', 'mobile'])
|
2019-03-29 14:26:25 +00:00
|
|
|
parser_generic.add_argument('-u', '--updates', help='get a sorted list for when updates were released for '
|
|
|
|
'techniques, groups or software',
|
|
|
|
choices=['techniques', 'groups', 'software'])
|
|
|
|
parser_generic.add_argument('--sort', help='sorting of the output from \'-u/--update\' on modified or creation '
|
|
|
|
'date (default = modified)', choices=['modified', 'created'],
|
|
|
|
default='modified')
|
2020-06-29 13:52:26 +00:00
|
|
|
parser_generic.add_argument('--local-stix-path', help='path to a local STIX repository to use DeTT&CT offline '
|
|
|
|
'or to use a specific version of STIX objects.')
|
2019-03-29 14:26:25 +00:00
|
|
|
|
|
|
|
return menu_parser
|
|
|
|
|
|
|
|
|
2019-07-31 08:14:47 +00:00
|
|
|
def _menu(menu_parser):
|
2019-03-29 14:26:25 +00:00
|
|
|
"""
|
|
|
|
Parser for the command line parameter menu and calls the appropriate functions.
|
2019-07-31 08:14:47 +00:00
|
|
|
:param menu_parser: the argparse menu as created with '_init_menu()'
|
2019-03-29 14:26:25 +00:00
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
args = menu_parser.parse_args()
|
|
|
|
|
2020-06-29 13:52:26 +00:00
|
|
|
if 'local_stix_path' in args and args.local_stix_path:
|
|
|
|
generic.local_stix_path = args.local_stix_path
|
|
|
|
|
|
|
|
if 'update_to_sub_techniques' in args and args.update_to_sub_techniques:
|
|
|
|
from upgrade import upgrade_to_sub_techniques
|
|
|
|
upgrade_to_sub_techniques(args.file_tech)
|
|
|
|
|
2019-03-29 14:26:25 +00:00
|
|
|
if args.interactive:
|
|
|
|
interactive_menu()
|
|
|
|
|
2020-02-20 11:02:27 +00:00
|
|
|
elif args.subparser in ['editor', 'e']:
|
2020-03-04 09:45:00 +00:00
|
|
|
DeTTECTEditor(int(args.port)).start()
|
2020-02-20 11:02:27 +00:00
|
|
|
|
2019-03-29 14:26:25 +00:00
|
|
|
elif args.subparser in ['datasource', 'ds']:
|
2019-08-20 09:14:07 +00:00
|
|
|
if check_file(args.file_ds, FILE_TYPE_DATA_SOURCE_ADMINISTRATION, args.health):
|
2019-08-08 12:17:31 +00:00
|
|
|
file_ds = args.file_ds
|
|
|
|
|
|
|
|
if args.search:
|
2019-11-19 10:28:01 +00:00
|
|
|
file_ds = data_source_search(args.file_ds, args.search)
|
2019-08-13 12:28:43 +00:00
|
|
|
if not file_ds:
|
|
|
|
quit() # something went wrong in executing the search or 0 results where returned
|
2019-08-20 09:14:07 +00:00
|
|
|
if args.update and check_file(args.file_tech, FILE_TYPE_TECHNIQUE_ADMINISTRATION, args.health):
|
2019-08-08 12:17:31 +00:00
|
|
|
update_technique_administration_file(file_ds, args.file_tech)
|
2019-03-29 14:26:25 +00:00
|
|
|
if args.layer:
|
2020-06-08 14:56:56 +00:00
|
|
|
generate_data_sources_layer(file_ds, args.output_filename, args.layer_name)
|
2019-03-29 14:26:25 +00:00
|
|
|
if args.excel:
|
2020-05-25 09:44:13 +00:00
|
|
|
export_data_source_list_to_excel(file_ds, args.output_filename, eql_search=args.search)
|
2019-03-29 14:26:25 +00:00
|
|
|
if args.graph:
|
2020-05-25 09:44:13 +00:00
|
|
|
plot_data_sources_graph(file_ds, args.output_filename)
|
2019-03-29 14:26:25 +00:00
|
|
|
if args.yaml:
|
2020-05-25 09:44:13 +00:00
|
|
|
generate_technique_administration_file(file_ds, args.output_filename, all_techniques=args.yaml_all_techniques)
|
2019-03-29 14:26:25 +00:00
|
|
|
|
|
|
|
elif args.subparser in ['visibility', 'v']:
|
2019-04-10 08:08:30 +00:00
|
|
|
if args.layer or args.overlay:
|
|
|
|
if not args.file_ds:
|
2019-08-08 12:17:31 +00:00
|
|
|
print('[!] Generating a visibility layer or an overlay requires the data source '
|
|
|
|
'administration YAML file (\'-fd, --file-ds\')')
|
2019-04-10 08:08:30 +00:00
|
|
|
quit()
|
2019-07-31 08:14:47 +00:00
|
|
|
if not check_file(args.file_ds, FILE_TYPE_DATA_SOURCE_ADMINISTRATION, args.health):
|
|
|
|
quit()
|
2019-04-10 08:08:30 +00:00
|
|
|
|
2019-05-19 12:10:25 +00:00
|
|
|
if check_file(args.file_tech, FILE_TYPE_TECHNIQUE_ADMINISTRATION, args.health):
|
2019-08-08 12:17:31 +00:00
|
|
|
file_tech = args.file_tech
|
|
|
|
|
|
|
|
if args.search_detection or args.search_visibility:
|
|
|
|
file_tech = techniques_search(args.file_tech, args.search_visibility, args.search_detection,
|
|
|
|
include_all_score_objs=args.all_scores)
|
2019-08-13 12:28:43 +00:00
|
|
|
if not file_tech:
|
|
|
|
quit() # something went wrong in executing the search or 0 results where returned
|
2019-07-31 08:14:47 +00:00
|
|
|
if args.layer:
|
2020-06-08 14:56:56 +00:00
|
|
|
generate_visibility_layer(file_tech, args.file_ds, False, args.output_filename, args.layer_name)
|
2019-07-31 08:14:47 +00:00
|
|
|
if args.overlay:
|
2020-06-08 14:56:56 +00:00
|
|
|
generate_visibility_layer(file_tech, args.file_ds, True, args.output_filename, args.layer_name)
|
2019-08-15 14:00:06 +00:00
|
|
|
if args.graph:
|
2020-05-25 09:44:13 +00:00
|
|
|
plot_graph(file_tech, 'visibility', args.output_filename)
|
2019-08-08 12:17:31 +00:00
|
|
|
if args.excel:
|
2020-05-25 09:44:13 +00:00
|
|
|
export_techniques_list_to_excel(file_tech, args.output_filename)
|
2019-03-29 14:26:25 +00:00
|
|
|
|
2019-12-12 14:50:27 +00:00
|
|
|
# todo add search capabilities
|
2019-03-29 14:26:25 +00:00
|
|
|
elif args.subparser in ['group', 'g']:
|
2020-06-18 15:01:16 +00:00
|
|
|
generate_group_heat_map(args.groups, args.overlay, args.overlay_type, args.stage, args.platform,
|
|
|
|
args.software_group, args.search_visibility, args.search_detection, args.health,
|
|
|
|
args.output_filename, args.layer_name, include_all_score_objs=args.all_scores)
|
2019-03-29 14:26:25 +00:00
|
|
|
|
|
|
|
elif args.subparser in ['detection', 'd']:
|
|
|
|
if args.overlay:
|
|
|
|
if not args.file_ds:
|
2019-08-08 12:17:31 +00:00
|
|
|
print('[!] An overlay requires the data source administration YAML file (\'-fd, --file-ds\')')
|
2019-03-29 14:26:25 +00:00
|
|
|
quit()
|
2019-05-19 12:10:25 +00:00
|
|
|
if not check_file(args.file_ds, FILE_TYPE_DATA_SOURCE_ADMINISTRATION, args.health):
|
2019-03-29 14:26:25 +00:00
|
|
|
quit()
|
|
|
|
|
2019-05-19 12:10:25 +00:00
|
|
|
if check_file(args.file_tech, FILE_TYPE_TECHNIQUE_ADMINISTRATION, args.health):
|
2019-08-08 12:17:31 +00:00
|
|
|
file_tech = args.file_tech
|
|
|
|
|
|
|
|
if args.search_detection or args.search_visibility:
|
|
|
|
file_tech = techniques_search(args.file_tech, args.search_visibility, args.search_detection,
|
|
|
|
include_all_score_objs=args.all_scores)
|
2019-08-13 12:28:43 +00:00
|
|
|
if not file_tech:
|
|
|
|
quit() # something went wrong in executing the search or 0 results where returned
|
2019-03-29 14:26:25 +00:00
|
|
|
if args.layer:
|
2020-06-08 14:56:56 +00:00
|
|
|
generate_detection_layer(file_tech, args.file_ds, False, args.output_filename, args.layer_name)
|
2019-05-19 12:10:25 +00:00
|
|
|
if args.overlay and check_file(args.file_ds, FILE_TYPE_DATA_SOURCE_ADMINISTRATION, args.health):
|
2020-06-08 14:56:56 +00:00
|
|
|
generate_detection_layer(file_tech, args.file_ds, True, args.output_filename, args.layer_name)
|
2019-03-29 14:26:25 +00:00
|
|
|
if args.graph:
|
2020-05-25 09:44:13 +00:00
|
|
|
plot_graph(file_tech, 'detection', args.output_filename)
|
2019-08-08 12:17:31 +00:00
|
|
|
if args.excel:
|
2020-05-25 09:44:13 +00:00
|
|
|
export_techniques_list_to_excel(file_tech, args.output_filename)
|
2019-03-29 14:26:25 +00:00
|
|
|
|
|
|
|
elif args.subparser in ['generic', 'ge']:
|
2019-08-01 13:02:06 +00:00
|
|
|
if args.datasources:
|
|
|
|
get_statistics_data_sources()
|
|
|
|
elif args.mitigations:
|
|
|
|
get_statistics_mitigations(args.mitigations)
|
2019-03-29 14:26:25 +00:00
|
|
|
elif args.updates:
|
|
|
|
get_updates(args.updates, args.sort)
|
|
|
|
|
2019-05-08 06:42:32 +00:00
|
|
|
else:
|
|
|
|
menu_parser.print_help()
|
2019-03-29 14:26:25 +00:00
|
|
|
|
2019-05-19 12:10:25 +00:00
|
|
|
|
2019-07-31 08:14:47 +00:00
|
|
|
def _prepare_folders():
|
2019-03-29 14:26:25 +00:00
|
|
|
"""
|
|
|
|
Create the folders 'cache' and 'output' if they do not exist.
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
if not os.path.exists('cache'):
|
|
|
|
os.mkdir('cache')
|
|
|
|
if not os.path.exists('output'):
|
|
|
|
os.mkdir('output')
|
|
|
|
|
2019-12-09 14:26:48 +00:00
|
|
|
# pylint: disable=unused-argument
|
2020-02-20 11:02:27 +00:00
|
|
|
|
|
|
|
|
2019-07-31 08:14:47 +00:00
|
|
|
def _signal_handler(signum, frame):
|
2019-03-29 14:26:25 +00:00
|
|
|
"""
|
|
|
|
Function to handles exiting via Ctrl+C.
|
|
|
|
:param signum:
|
|
|
|
:param frame:
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2019-07-31 08:14:47 +00:00
|
|
|
signal.signal(signal.SIGINT, _signal_handler)
|
|
|
|
_prepare_folders()
|
|
|
|
_menu(_init_menu())
|