Twenty seconds of a plant talking
Reading Modbus traffic means decoding each request on a control network and asking whether it belongs there. A plant's network is quiet and regular, which makes a stranger easy to see.
An HMI asks the same questions every second. A request that writes, from a machine nobody expected, stands out. You read a fixed capture in your own lab, never a real plant's network.
By the end of this lesson
Note
I can spot a Modbus write that an allow-list does not expect.
Key words
| Word | What it means | Example |
|---|---|---|
| Capture | a saved record of the requests on a network | |
| Polling | asking the same question again and again on a timer | |
| Allow-list | a list of what is expected, so anything else stands out | |
| Writer | a machine allowed to send writes | eng |
| Reconnaissance | looking around before an attack |
The cells students fill in are left blank in this preview.
The one rule
Warning
Capture and read traffic only on networks you own or have written permission to watch. The captures here are made up and fixed. Listening on somebody else's network can be a crime, and on a plant even a careless scan can stop a device.
Normal traffic is regular and boring
The capture in the lab is twenty seconds of requests to the PLC, one per line: the time, the source and the bytes in hex.
Most lines come from the HMI. Every second it reads the input registers and the discrete inputs, so the same two requests repeat twenty times. That rhythm is what normal looks like.
Decode the capture and count the requests
docker exec work python3 steps/decode.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Worked example: the requests not from the HMI
| Time | Source | Function | What it did |
|---|---|---|---|
| 6.5 | laptop | 3 | Read the setpoints |
| 7.5 | laptop | 8 | Asked for diagnostics |
| 8.5 | laptop | 3 | Read address 40, which does not exist |
| 9.5 and 9.7 | laptop | 5 | Wrote manual mode, then pump on |
| 12.5 | eng | 6 | Wrote 78 into the high setpoint |
| 14.5 | laptop | 6 | Wrote 100 into the high setpoint |
The cells students fill in are left blank in this preview.
Try it: tell reads from writes
capture = ["0.0 hmi 000100000006010400000005",
"9.5 laptop 00040000000601050001ff00",
"12.5 eng 00010000000601060001004e"]
for line in capture:
parts = line.split()
data = bytes.fromhex(parts[2])
fc = data[7]
kind = "write" if fc in (5, 6, 15, 16) else "read"
print(parts[0], parts[1], "function", fc, kind)
# Add the line "14.5 laptop 000600000006010600010064". What does it write, and where?
An allow-list says which writes are expected
Reads are rarely dangerous. Writes change the plant, so each one is checked against an allow-list.
The lab's list says three things. Only the engineering workstation, eng, may write. It may write only holding registers 0 and 1. The low setpoint must be 10 to 40, and the high one 60 to 85.
Check every write against the allow-list
docker exec work python3 steps/spot.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
What the check found
Three writes came from the laptop, which is not an allowed writer: manual mode, pump on and a high setpoint of 100. Each is flagged.
The engineering write of 78 was from an allowed writer, to an expected register and inside its range. It is marked expected.
A common mistake
Warning
Many people think only writes matter, so reads can be ignored. Writes do the damage, but reads usually come first. The laptop read the setpoints and probed addresses before it wrote anything. Spotting those reads gives a warning before the plant is touched.