-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathakamaru.py
112 lines (97 loc) · 5.67 KB
/
akamaru.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from colorama import init, Fore
from argparse import ArgumentParser, HelpFormatter
from traceback import format_exc as print_traceback
from utils.mitre_visibility import perform_mitre_visibility
from utils.util import create_csv_report, print_supported_sectors
from utils.sentinelone_visibility import performs_sentinel_visibility
from utils.ransomlook_visibility import performs_ransomlook_visibility
class CustomHelpFormatter(HelpFormatter):
def __init__(self, prog):
super().__init__(prog, max_help_position=50, width=100)
def format_action_invocation(self, action) -> str:
if not action.option_strings or action.nargs == 0:
return super().format_action_invocation(action)
default = self._get_default_metavar_for_optional(action)
args_string = self._format_args(action, default)
return ", ".join(action.option_strings) + " " + args_string
def main(args_: ArgumentParser) -> None:
"""
Manages all Akamaru's process
:argument args_: arguments from the command line
:return: None
"""
parser, mitre_results, sentinel_results, ransomlook_results = args_.parse_args(), {}, {}, {}
if parser.ttp and parser.sector:
mitre_results = perform_mitre_visibility(sector=parser.sector, ttp=True)
sentinel_results = performs_sentinel_visibility(sector=parser.sector)
elif parser.sector:
mitre_results = perform_mitre_visibility(sector=parser.sector)
sentinel_results = performs_sentinel_visibility(sector=parser.sector)
elif parser.group:
mitre_results = perform_mitre_visibility(group=parser.group)
sentinel_results = performs_sentinel_visibility(group=parser.group)
elif parser.ransomware_activities:
performs_ransomlook_visibility(general_activity=True)
elif parser.supported_sectors:
print_supported_sectors()
if parser.output:
create_csv_report(mitre=mitre_results, sentinel=sentinel_results, ttp=parser.ttp)
if not parser.sector \
and not parser.group \
and not parser.ttp \
and not parser.ransomware_activities \
and not parser.supported_sectors \
and not parser.output:
args_.print_help()
if __name__ == '__main__':
arg_style = lambda prog: CustomHelpFormatter(prog)
args = ArgumentParser(description="", add_help=False, formatter_class=arg_style)
# well known threat groups
group_required = args.add_argument_group(title="Well Known Threat Groups")
group_required.add_argument("-s", "--sector", metavar="<sector>", type=str, required=False, help="Receives the sector name of your interesting and returns the well-known groups related. Use the -ss option to know whats sectors are supported.")
group_required.add_argument("-ss", "--supported-sectors", action="store_true", help="Returns the supported sectors by Akamaru.")
group_required.add_argument("-t", "--ttp", action="store_true", help="Returns TTPs associated with groups collected from MITRE ATT&CK. It must be used with the <sector> flag. Due to information overload, using this option without the <output> flag is not recommended.")
group_required.add_argument("-g", "--group", metavar="<group>", type=str, required=False, help="Receives the name of the threat group and returns the known information about them.")
# ransomware activities
group_required = args.add_argument_group(title="Ransomware Activities")
group_required.add_argument("-r", "--ransomware-activities", action="store_true", help="Returns the most active ransomware groups over a time range.")
# outputs
group_required = args.add_argument_group(title="Outputs")
group_required.add_argument("-o", "--output", action="store_true", help="Returns the <sector> or <group> results in a CSV file, separated by semicolon.")
# help
group_required = args.add_argument_group(title="Help")
group_required.add_argument("-h", "--help", action="help", help="Show this help screen.")
# perform coloroma multiplatform
init(strip=False)
print(r"""{}
_
,/A\,
.//`_`\\,
,//`____-`\\,
,//`[{}Akamaru{}]`\\,
,//`= == __- _`\\,
//|__= __- == _ __|\\
` | __ .-----. _ | `
| - _/ \- |
|__ |{} .-"-. {}| __=|
| _=|{}/) (\{}| |
|-__ {}(/ {}- -{} \){} -__|
|___ {}/`\_Y_/`\{}____|
{}\) (/
{}[{}>{}] Sniffing out relevant threat groups
[{}>{}] [email protected]
""".format(Fore.LIGHTBLACK_EX, Fore.MAGENTA,
Fore.LIGHTBLACK_EX, Fore.LIGHTWHITE_EX,
Fore.LIGHTBLACK_EX, Fore.LIGHTWHITE_EX,
Fore.LIGHTBLACK_EX, Fore.LIGHTWHITE_EX,
Fore.LIGHTRED_EX, Fore.LIGHTWHITE_EX,
Fore.LIGHTBLACK_EX, Fore.LIGHTWHITE_EX,
Fore.LIGHTBLACK_EX, Fore.LIGHTWHITE_EX,
Fore.WHITE, Fore.MAGENTA, Fore.WHITE,
Fore.MAGENTA, Fore.WHITE))
try:
main(args_=args)
except KeyboardInterrupt:
print(f"\n{Fore.WHITE}[{Fore.MAGENTA}!{Fore.WHITE}] OK! I will cancel operations and await your commands.\n")
except Exception:
print(f"\n{Fore.WHITE}[{Fore.MAGENTA}!{Fore.WHITE}] An error forced Akamaru to stop: {repr(print_traceback())}")