Build a Safe AI OT Attack Test Environment
In this article
This guide walks through creating an isolated, safe lab for evaluating AI-driven attacks on operational technology (OT) systems like PLCs, SCADA, and industrial networks. You'll learn how to set up a virtualized environment with realistic simulations, monitoring, and containment so you can study attack behaviors without risking real infrastructure. Before starting, you need basic familiarity with virtual machines, networking, and OT concepts like Modbus or DNP3.
What You'll Need
- A computer with at least 16 GB RAM and 100 GB free disk space (or a dedicated server).
- Virtualization software: VMware Workstation, VirtualBox, or Proxmox VE.
- An OT simulation platform: e.g., OpenPLC, Factory I/O, or a SCADA testbed like Conpot (honeypot).
- Network emulation tools: GNS3 or EVE-NG for creating realistic industrial network topologies.
- AI/ML frameworks: Python with TensorFlow/PyTorch, plus libraries like Scapy for packet crafting.
- Monitoring tools: Wireshark, Suricata (IDS), and ELK stack for logging.
- Isolation tools: A separate VLAN or a dedicated physical machine with no internet access.
- Backup software (e.g., snapshots in your hypervisor).
Step-by-Step
- Design the architecture. Sketch a typical OT network: a control center with HMI, a PLC, and field devices. Decide which components you'll simulate and how they connect. Keep it simple initially—one PLC and one HMI is enough to start.
- Set up the hypervisor and base VMs. Install your chosen virtualization platform. Create three VMs: one for the OT simulation (e.g., OpenPLC on Linux), one for the HMI/SCADA (e.g., a Windows VM with a free SCADA trial), and one for the AI attacker (Kali Linux with Python). Ensure each VM has at least 2 GB RAM.
- Build the virtual network. In your hypervisor, create a host-only network (or a NAT network with no internet). Assign static IPs: PLC at 192.168.10.10, HMI at 192.168.10.20, Attacker at 192.168.10.100. Disable DHCP to avoid surprises.
- Install and configure the OT simulator. Install OpenPLC on the PLC VM. Load a simple ladder logic program (e.g., a motor start/stop). Verify the HMI can read/write to the PLC using Modbus TCP (default port 502). Test with a tool like Modbus Poll.
- Set up the HMI/SCADA. Install a SCADA software like Ignition (free trial) or use a simple Python script that polls the PLC. Ensure the HMI displays real-time data and allows control commands. This mimics a real operator interface.
- Prepare the AI attacker VM. Install Python, TensorFlow/PyTorch, Scapy, and a Modbus library (pymodbus). Write a baseline script that sends normal Modbus read requests to understand normal traffic patterns.
- Add monitoring and logging. On a separate VM (or the HMI), install Wireshark for packet capture. Set up Suricata with OT-specific rules (e.g., detect unauthorized writes to Modbus coils). Use ELK to centralize logs from all VMs.
- Isolate the environment. Ensure the host-only network has no internet access. Disable any default gateway on the VMs. If you need internet for package installs, do it before isolation or use a separate temporary NAT.
- Snapshot the baseline. Take a snapshot of all VMs in a clean state. This allows you to revert after each attack test, ensuring repeatability.
- Develop AI attack scripts. Start with simple attacks: a brute-force Modbus write attack that randomly flips coils. Train a simple AI model (e.g., a neural network) to predict which registers to target based on normal traffic patterns. Use reinforcement learning to optimize the attack sequence.
- Run controlled attacks. Execute the AI attack while monitoring with Wireshark and Suricata. Record the attack's impact on the PLC (e.g., does it stop the motor?). Save all logs for analysis.
- Evaluate and refine. Analyze the attack success rate and detection rate. Adjust the AI model based on results. Try different attack vectors (e.g., false data injection, denial of service).
- Document findings. Keep a lab notebook detailing each test, the AI configuration, and outcomes. This is crucial for research or reporting.
Common Mistakes
- Skipping isolation. The biggest risk is leaving a network bridge to the internet. Always use host-only networking and verify no external connectivity.
- Using real OT hardware. Real PLCs are expensive and dangerous if misused. Stick to simulators until you're confident.
- Ignoring normal traffic baseline. Without understanding normal behavior, you can't evaluate AI attacks effectively. Spend time generating realistic traffic.
- Not taking snapshots. If you don't snapshot, you'll waste hours rebuilding after a crash.
- Overcomplicating the AI model. Start with simple scripts; complex models can be added later. The goal is to learn the process, not build a production AI.
Tips
- Use a dedicated physical machine if possible—this eliminates hypervisor overhead and simplifies isolation.
- Automate traffic generation with Scapy to create realistic Modbus traffic patterns.
- Incorporate a honeypot like Conpot to see how AI attacks behave against decoy systems.
- Keep your AI training data separate from the test environment to avoid bias.
- Document every configuration change; you'll thank yourself later.
Troubleshooting
- VMs can't communicate. Check virtual network adapter settings—ensure all VMs are on the same host-only network. Verify IP addresses and firewalls (disable firewalls on the PLC VM initially).
- Modbus connection fails. Confirm the Modbus TCP port (502) is open. Test with a simple Python script using pymodbus. Check that OpenPLC is running and the ladder logic is loaded.
- AI script runs slowly. Reduce the state space or use a simpler model. Ensure your VM has enough CPU/RAM allocated.
- Suricata doesn't detect attacks. Update rules or write custom Modbus rules. Verify Suricata is actually capturing traffic (check its logs).
- Snapshots fail. Ensure you have enough disk space. Close all VMs before taking a snapshot.
- Accidental internet access. Immediately disconnect the VM's network adapter and check the hypervisor's network settings. Revert to snapshot if needed.
Frequently Asked Questions
Is it legal to build such an environment?
Yes, as long as you own the hardware and software, and you don't attack any third-party systems. Keep the lab isolated and don't connect it to the internet.
Can I use real PLCs?
You can, but it's not recommended for beginners. Simulators like OpenPLC are safer and cheaper, and they behave similarly for most attack scenarios.
What is the minimum hardware?
16 GB RAM and a quad-core CPU are comfortable. You can run with 8 GB but it will be slow.
How do I generate realistic OT traffic?
Use Scapy to craft Modbus packets and schedule them at realistic intervals. You can also use the HMI to poll the PLC periodically.
Can I use cloud VMs?
It's possible but risky—cloud providers may detect malicious activity and terminate services. A local lab is safer and cheaper.
How do I protect my lab from malware escaping?
Use host-only networking, keep the host OS patched, and never share files between the lab and your main system. Also, use snapshots to revert if something goes wrong.