Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Industrial Control System Basics

The whole lesson is free and interactive. Read it here, or press Start lab to run it for real in a live lab, with no account needed.

Container lab9 min read6 commands

A water tank, a computer and no password

Water works, factories and power stations are run by small computers called PLCs. A PLC reads sensors, such as a tank's level, and drives actuators, such as a pump. Many PLCs speak Modbus, a protocol from 1979 that asks nobody who they are. This lab gives you a simulated tank to see why that matters and how plants are defended.

The one rule

Warning

This lab is a simulated plant of your own. Touch it, and nothing else. Never send a Modbus message, a scan or a probe to a real plant or to any device that is not yours: in the UK that is a crime under the Computer Misuse Act 1990, and on a real plant one write can hurt people.

By the end of this lesson

Note

I can explain why a safety function must sit where a network command cannot change it.

Key words

  • PLC: a programmable logic controller, the computer that runs a machine.
  • Sensor: a device that measures, such as a level sensor.
  • Actuator: a device that acts, such as a pump.
  • HMI: the operator's screen, which shows the plant.
  • Modbus: a simple protocol for reading and writing a PLC's values.
  • Safety trip: a stop that takes over when a limit is passed.

Starter: what you already know

Note

Answer in your head. 1. What does a password protect? 2. What is a port number for? 3. Why does a kettle switch itself off? Answers: who may use something; which program a connection is for; so it cannot boil dry, whatever anybody presses.

Before you start

Note

Press Start the lab on the bar at the top of this lesson and wait until it says it is running. There are four containers: plc, gateway (the conduit), hmi and work. The terminal reaches their Python with docker exec. The HMI link opens the operator's screen, port 8080. Each Run button below types its command into your lab's terminal, one after another in the same session. To watch them, or to type your own, press Open terminal on the bar.

Read the PLC, and change nothing

The script asks the PLC for its setpoints, its mode and its safety trip. The pump comes on at 20 per cent and goes off at 80, the mode is auto, the trip is False, and the level is between the setpoints. The script only reads.

Command
docker exec work python3 steps/plant.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

A Modbus request is twelve bytes

The script builds a request by hand and prints it: 00 01 00 00 00 06 01 03 00 00 00 02. The first seven bytes are the header. Then function 03 asks for holding registers, from address 0, two of them. The reply ends 00 14 00 50, which is 20 and 80.

Command
docker exec work python3 steps/frame.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Modbus asks nobody who they are

The script writes 81 into the high setpoint. The PLC echoes the request and the setpoint is now 81. Then it puts 80 back. No name, password or key was asked for. Anything that can reach port 5020 can do this.

Command
docker exec work python3 steps/noauth.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Tip

Why is a Modbus write from the wrong machine accepted? Answer: the protocol has no login, so the PLC cannot tell who sent it.

The safety trip holds against a forced pump

Now the script switches to manual and forces the pump on. The tank fills. At exactly 95 per cent the safety trip latches. The pump command coil still says on, but the pump is not running. The script puts auto mode back, and the trip stays latched.

Command
docker exec work python3 steps/override.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Only the panel can reset it

The trip is a constant in the PLC's program, not a Modbus value, so no network message can clear it. This script runs inside the PLC's own container, like a key on its panel. It waits for the level to fall below 90, then says the trip is cleared.

Command
docker exec plc python3 panel_reset.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

A conduit only lets reads through

The gateway is a conduit between zones. Through it, reading the setpoints works, but writing a setpoint or the pump coil gets exception 1. Straight to the PLC, the same write is accepted. A filter only protects the paths that go through it.

Command
docker exec work python3 steps/conduit.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

A common mistake

Warning

Many people think the HMI controls the plant. The PLC does. The HMI only shows what the PLC reports, and here it cannot write at all. If the HMI stops, the PLC keeps running the tank, and anyone who can reach the PLC can still change it.

Watch it on the HMI

Open HMI from the bar. It refreshes every second, showing the level, the pump, the mode and the trip. Run the forced pump again and watch the level climb to 95, the bar turn red and the trip say TRIPPED.

Exit check

Tip

Answer without looking back. 1. What does a PLC read and what does it drive? 2. What does Modbus ask before a write? 3. Why could the forced pump not pass 95? 4. Why did the write straight to the PLC work? Answers: sensors and actuators; nothing; the safety trip is outside Modbus; it did not go through the conduit.

For teachers

Tip

This lesson is a small example of a lesson worked in a lab: the steps and the Run buttons are the lesson, and the lab is each student's own copy. The lab is four services of the official Python image, a simulated PLC, a conduit, a read-only HMI and a box of scripts, and nothing here marks itself: the student hands in the commands and what they printed. Key learning points: 1. A PLC reads sensors and drives actuators. 2. Modbus has no authentication. 3. A safety function must sit outside what the network can write. Common mistake: thinking the HMI controls the plant. Equipment: the lab and a browser. Tip: say the one rule aloud before the first write. Copy it into your own module and change it, or build one from scratch with the Lab menu in the lesson builder.

About this lab and its source: Industrial control system security lab: a simulated PLC, Modbus, HMI and conduit

Teaching a class? Set these lessons for your students with marking and a lab for every student.