Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tutorials/tutorial3/actions_effects_lang.mal
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// vim:ft=mal
#id: "test-actions-effects"
#version: "0.0.0"

category System{

asset Computer {
& physicalAccess
-> attemptAuthenticate

| attemptAuthenticate [HardAndCertain]
-> authenticate

& effect authenticate
-> computerApps.attemptExploit
}

asset Application {
# shutDown
-> exploit

| attemptExploit [HardAndCertain]
-> exploit

& effect exploit
-> toApplications.attemptExploit,
dataOnApp.read
}

asset Data {
| read
}

}

associations {
Computer [computerOfApp] * <-- appExecution --> * [computerApps] Application
Application [fromApplications] * <-- AppToAppCommunication --> * [toApplications] Application
Data [dataOnApp] * <-- AppData --> * [appWithData] Application
}
Binary file not shown.
Binary file added tutorials/tutorial3/actions_effects_model.gv.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions tutorials/tutorial3/tutorial3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Tutorial 3 - actions and effects

- Read through the language: actions_effects_lang.mal

- Read through the scenario file


Run the simulation with cli: `malsim tutorial3_scenario.yml`

Run the simulation with cli and TTCMode = expected_value: `malsim tutorial3_scenario.yml --ttc-mode 3`

Run the simulation with script: `python tutorial3.py`


TODO: make this into an actual tutorial walking through each step of the process (creating the MAL language, using the MAL gui, writing the script).
23 changes: 23 additions & 0 deletions tutorials/tutorial3/tutorial3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from maltoolbox.visualization import render_attack_graph, render_model
from malsim import Scenario, MalSimulator, run_simulation, MalSimulatorSettings
from malsim.config import TTCMode

def main():
scenario_file = "tutorial3_scenario.yml"
scenario = Scenario.load_from_file(scenario_file)
simulator = MalSimulator.from_scenario(
scenario,
sim_settings=MalSimulatorSettings(
ttc_mode=TTCMode.EXPECTED_VALUE,
# attack_surface_skip_unnecessary=False
)
)
run_simulation(simulator, scenario.agent_settings)
render_attack_graph(scenario.attack_graph)
render_model(scenario.model)
import pprint
pprint.pprint(simulator.recording)


if __name__ == '__main__':
main()
67 changes: 67 additions & 0 deletions tutorials/tutorial3/tutorial3_scenario.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
lang_file: /home/joakim-loxdal/Documents/mal-toolbox-tutorial/tutorials/tutorial3/actions_effects_lang.mal
agents:
Attacker:
name: Attacker
type: attacker
entry_points: !!set
ComputerA:physicalAccess: null
goals: !!set
DataOnAppB:read: null
policy: RandomAgent
model:
metadata:
name: actions_effects_model
langVersion: 0.0.0
langID: test-actions-effects
malVersion: 0.1.0-SNAPSHOT
MAL-Toolbox Version: 2.0.0
info: Created by the mal-toolbox model python module.
assets:
0:
name: ComputerA
type: Computer
associated_assets:
computerApps:
2: AppA
extras:
position:
x: -498.0
y: -247.0
2:
name: AppA
type: Application
associated_assets:
computerOfApp:
0: ComputerA
toApplications:
3: AppB
fromApplications:
3: AppB
extras:
position:
x: -495.0
y: -427.0
3:
name: AppB
type: Application
associated_assets:
fromApplications:
2: AppA
dataOnApp:
4: DataOnAppB
toApplications:
2: AppA
extras:
position:
x: -495.0
y: -618.0
4:
name: DataOnAppB
type: Data
associated_assets:
appWithData:
3: AppB
extras:
position:
x: 56.0
y: -616.0