-
Notifications
You must be signed in to change notification settings - Fork 0
/
mal.py
47 lines (32 loc) · 1.19 KB
/
mal.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
import logging
import maltoolbox
from maltoolbox.language import classes_factory
from maltoolbox.language import specification, LanguageGraph
from maltoolbox import attackgraph
from maltoolbox.model import Model
from maltoolbox.ingestors import neo4j
from maltoolbox.attackgraph import AttackGraph
from os import path
exp = "exp5"
logger = logging.getLogger(__name__)
lang = path.join('langs','lang_spec.json')
model_path = path.join(exp,'model.json')
tmp = path.join(exp, 'tmp','attack_graph.json')
lang_spec = specification.load_language_specification_from_json(lang)
lang_classes_factory = classes_factory.LanguageClassesFactory(lang_spec)
lang_classes_factory.create_classes()
lang_graph = LanguageGraph(lang_spec)
model = Model("Test Model", lang_spec, lang_classes_factory)
model.load_from_file(model_path)
attack_graph = AttackGraph(lang_spec, model)
attack_graph.attach_attackers(model)
attack_graph.save_to_file(tmp)
'''
if maltoolbox.neo4j_configs['uri'] != "":
neo4j.ingest_model(model,
maltoolbox.neo4j_configs['uri'],
maltoolbox.neo4j_configs['username'],
maltoolbox.neo4j_configs['password'],
maltoolbox.neo4j_configs['dbname'],
delete=True)
'''