SAFARI is a framework for running ransomware safely and reproducibly, to study how it behaves and to test countermeasures against it. It applies infrastructure-as-code to security research. In the current incarnation, SAFARI targets Proxmox VE and uses Terraform to create disposable virtual machines, Ansible to infect them, cut their network (to isolate them), run possible countermeasures under test, and collect the results. Every experiment is a set of configuration files, so one can repeat them and arrays of parametric experiments and run them in parallel on many machines.
We used SAFARI to profile the encryption patterns of seven ransomware strains, including WannaCry and LockBit, and to evaluate Ranflood against five of them.
Caution
SAFARI's main use case is the execution of live ransomware. Run it only on a dedicated Proxmox host that is isolated from production networks and storage, keep samples in password-protected archives, and check your institution's rules on handling malware before you start. SAFARI disconnects the victim machines from the network before it runs the sample, but isolating the host is your responsibility.
An experiment has two phases. Each phase is driven by a shell script that applies a Terraform configuration and then runs an Ansible playbook.
1. Infection (Infected/infected.sh). Terraform clones vms_count Windows VMs from a template and writes their IP addresses, IDs, and disk names to Infected/vm_ip_address.txt, vm_id.txt, and vm_disk.txt. The external playbook then copies the ransomware archive, an internal playbook, and its variables into each VM over WinRM, and starts the internal playbook inside the VM through WSL. The internal playbook:
- disables all network bindings of the VM, cutting it off from the network;
- starts the Ranflood daemon and, for the strategies that need it, takes a snapshot of the target directory;
- extracts the ransomware and runs it;
- after a configurable delay, starts Ranflood's flooding.
To run the ransomware without any countermeasure, as a baseline, use internal_playbook_only_rans.yml as the internal playbook. Finally, after a configurable delay, the external playbook shuts the victims down from the Proxmox host.
2. Checking (Checker/checker.sh). Terraform clones one Linux checker VM per victim. Each checker receives the disk of its victim as a passthrough device, plus a small disk for the results. The playbook mounts the victim's disk, runs Ranflood's filechecker to compare the user's files with the checksums of a clean installation, and copies the report to the results disk.
Since the victims are shut down and a separate machine analyses their disks, the ransomware cannot interfere with the analysis.
Controller (the machine that runs the scripts)
- Terraform, which installs the
Telmate/proxmoxprovider (version3.0.1-rc4) atterraform init - Ansible with
pywinrmand the collectionsansible.windows,community.windows,community.general, andansible.posix
Proxmox VE host
- an API token for Terraform, and SSH access for Ansible, which shuts the VMs down with
qm shutdown - a storage for the results disks
Victim template (Windows 10)
- QEMU guest agent, so that Terraform can read the VM's IP address
- WinRM enabled, with the credentials listed in
Infected/Ansible/external_inventory - WSL with Ansible, which runs the internal playbook from inside the VM
- Ranflood, if you test it
Checker template (Linux)
- QEMU guest agent and SSH, with the credentials listed in
Checker/Ansible/inventory - Java and a build of Ranflood, which provides
filechecker.jar - the checksums of the clean victim template, created with Ranflood's
filechecker
Git does not track the variable files or the samples (see .gitignore).
- Terraform variables. In both
Infected/TerraformandChecker/Terraform, create a file ending in.auto.tfvarsthat sets the variables declared invariables.tf: the Proxmox API URL and token, the template to clone, the number of VMs, and their resources. For the checker,vm_disk_to_check_name_filepoints to theInfected/vm_disk.txtfile produced by the first phase. - Ansible variables. Create
Infected/Ansible/ansible_variables.ymlwith the paths of the sample and the playbooks on the controller and inside the VM, the name of the sample archive, the Ranflood strategy and target directory, and the two delays (before flooding, and before shutting down). The playbooks show the names of the variables they expect. - Inventories. Set the address and credentials of the Proxmox host in
Infected/Ansible/external_inventory. - Paths. The scripts and playbooks assume that the repository is in
~/Coding/SAFARI. Update the paths ininfected.sh,checker.sh, and the playbooks if you cloned it elsewhere. The checker's results disk uses the Proxmox storage namedstorage-condivisoinChecker/Terraform/checker.tf.
# Phase 1: create the victims, infect them, and shut them down
./Infected/infected.sh
# Phase 2: analyse the victims' disks
./Checker/checker.shTerraform appends to vm_ip_address.txt, vm_id.txt, and vm_disk.txt. Before a new experiment, delete these files and destroy the previous VMs with
terraform destroy.
Setting pm_timeout = 600 in the provider "proxmox" block of the provider.tf files helps when cloning machines with large disks, especially on slow storage. With shorter timeouts, the cloning may succeed but the VM becomes ready too late for the scripts that depend on timings, such as sequential tests on the same node.
If you use SAFARI, please cite:
- T. Compagnucci, S. Giallorenzo, A. Melis, S. Melloni, M. Prandini, A. Vannini. SAFARI: A Scalable Air-gapped Framework for Automated Ransomware Investigation. Computers & Security 170, 2026. doi:10.1016/j.cose.2026.105032
Related work:
- T. Compagnucci, F. Callegati, S. Giallorenzo, A. Melis, S. Melloni, A. Vannini. SAFARI: A Scalable Air-Gapped Framework for Automated Ransomware Investigation. IFIP SEC 2025. doi:10.1007/978-3-031-92882-6_15
- F. Callegati, S. Giallorenzo, A. Melis, S. Melloni, M. Prandini, A. Vannini. Investigating Operational Technology Attacks as Code. Empirical Software Engineering 30, 2025. doi:10.1007/s10664-025-10713-2. It extends SAFARI to industrial Operational Technology environments; see OT_case_studies.
- D. Berardi, S. Giallorenzo, A. Melis, S. Melloni, L. Onori, M. Prandini. Data Flooding against Ransomware: Concepts and Implementations. Computers & Security 131, 2023. doi:10.1016/j.cose.2023.103295
SAFARI is free software, released under the GNU Lesser General Public License v2.1.