Execution example
Now, we will walk through a simple scenario execution.
In case you need a testing environment or an advanced example, feel free to use the playground.
Prerequisites
It is assumed that you've followed the quick-start guide.
Create a plan template¶
The first step to run an automated scenario is to create its description - template.
We will be using this example.
It describes a scenario with one stage and a single step (action).
Download the template
curl -O https://gitlab.ics.muni.cz/cryton/cryton/-/raw/stable/3/examples/functionality/basic/template.yml
wget https://gitlab.ics.muni.cz/cryton/cryton/-/raw/stable/3/examples/functionality/basic/template.yml
Before we upload the template to Cryton, we should validate it. This can be done with:
cryton-cli plans validate template.yml
Example
cryton-cli plans validate template.yml
Expected output:
Plan successfully validated! (<response>)
If we are satisfied with our template, we can upload it using CLI:
cryton-cli plan-templates create template.yml
Example
cryton-cli plan-templates create template.yml
Expected output:
Template successfully created! ({'id': 1})
Create a plan instance¶
Now we need to create a plan instance we will use for our attack/run. Since our template has no inventory variables, we will be only using the template (its ID we got from the previous step) to create it.
To create a new Plan instance use:
cryton-cli plans create <TEMPLATE_ID>
Example
cryton-cli plans create 1 -i inventory.yml
Expected output:
Plan Instance successfully created! ({'id': 1})
Register a Worker¶
To be able to run the scenario, we need to register a new Worker. Keep in mind that WORKER_NAME must match the Worker’s CRYTON_WORKER_NAME
setting:
cryton-cli workers create <WORKER_NAME> -d <WORKER_DESCRIPTION>
Example
cryton-cli workers create worker -d "my worker on localhost"
Expected output:
Worker successfully created! ({'id': 1})
To check if the Worker is responding, run a health check:
cryton-cli workers health-check <WORKER_ID>
Example
cryton-cli workers health-check 1
Expected output:
The Worker successfully checked! (<response>)
Create a run¶
Finally, we create a new Run using the previously created plan instance and Worker:
cryton-cli runs create <PLAN_INSTANCE_ID> <WORKER_ID>
Example
cryton-cli runs create 1 1
Expected output:
Run successfully created! ({'id': 1})
Execute the run¶
It works... but at what cost?
Before you proceed with running any scenario, make sure you are allowed to do so. Otherwise, there may be consequences.
Now that everything is prepared, we can execute our Run immediately or schedule it for later.
To execute the Run immediately:
cryton-cli runs execute <RUN_ID>
Example
cryton-cli runs execute 1
Expected output:
Run successfully executed! (Run 1 was executed.)
Run executions can be scheduled to a specific date and time. By default, the system timezone will be used. To use the UTC timezone, use the --utc-timezone
flag.
cryton-cli runs schedule <RUN_ID> <DATE> <TIME>
Example
cryton-cli runs schedule 1 2020-06-08 10:00:00
Expected output:
Run successfully scheduled! (Run 1 is scheduled for 2020-06-08 10:00:00.)
Show run information¶
Check Run's state and other useful information:
cryton-cli runs show <RUN_ID>
Example
cryton-cli runs show 1
Expected output:
id: 1, schedule_time: None, start_time: 2021-05-24T00:08:45.200025, pause_time: None, finish_time: 2021-05-24T00:09:18.397199, state: RUNNING
Get a report¶
Get a report of your Run and its results anytime during its execution:
cryton-cli runs report <RUN_ID>
Example
cryton-cli runs report 1
Expected output:
Successfully created Run's report! (file saved at: /tmp/report_run_1_2020-06-08-10-15-00-257994_xdQeV)
Read the report directly
Reports can be viewed directly in cryton-cli (to quit, press Q):
cryton-cli runs report <RUN_ID> --less
Example
cryton-cli runs report 1 --less