-
Notifications
You must be signed in to change notification settings - Fork 3
Code examples
Joakim Loxdal edited this page Jan 16, 2026
·
7 revisions
- Install mal-gui.
- Launch mal-gui using the command
malguifrom command line and select your language. - Drag and drop the assets you want and create associations between them by SHIFT+Left clicking and dragging from one asset to another.
- Export the model to either .yml or .json (you can export scenario files as well, this is for the
mal-simulator)
- Load your language using maltoolbox.language.LanguageGraph.
- Use the maltoolbox.model.Model class to create a model and add assets.
- Add associations to your assets using
asset.add_associated_assets.
"""Run the script from this directory"""
from maltoolbox.model import Model
from maltoolbox.language import LanguageGraph
# You can load language from .mar archives (created with 'malc')
# or directly from .mal-files
file_path = "org.mal-lang.coreLang-1.0.0.mar"
corelang_graph = LanguageGraph.load_from_file(file_path)
# Create an empty model from the language
model = Model("Test Model", corelang_graph)
# Add two assets to the model using the asset type name
# defined in your MAL Language
app1 = model.add_asset(asset_type = 'Application', name = 'Application 1')
app2 = model.add_asset(asset_type = 'Application', name = 'Application 2')
# Create an association between app1 and app2 using the field name of
# the association which was defined in your MAL Language
app1.add_associated_assets(fieldname='appExecutedApps', assets={app2})
# Save your model for later use
model.save_to_file('model.yml')from maltoolbox.attackgraph import create_attack_graph
# The .mar archive created with `malc`
lang_file = "../resources/org.mal-lang.coreLang-1.0.0.mar"
# The model file created by maltoolbox
model_file = "../resources/model.yml"
# Generate attack graph from language + model
attack_graph = create_attack_graph(lang_file, model_file)
# Save your attack graph for later use
attack_graph.save_to_file('attack_graph.yml')