Modbus/TCP is a thin protocol, which is why it makes a good hiding place and a good teaching one. A frame is a seven byte header followed by a function code and its data. That small surface still offers a surprising number of places to carry something. Here are nine.
- Register values. A run of holding register reads whose values are all printable ASCII when viewed as bytes. Check by converting the values to hex and looking at the byte pairs.
- Coil patterns. A sequence of coil writes or reads whose on and off states, taken in order, spell out bits. The order of packets matters, so sort by time or transaction identifier, not by address.
- File records. Function codes for reading and writing file records are rare in normal polling, so any use stands out. The data field can hold anything.
- Unit identifier. The unit identifier byte is meant to select a device behind a gateway. A sequence of unusual identifiers can encode a message one byte at a time.
- Transaction identifier. A client normally increments it. A client that sets it deliberately can carry two bytes per packet.
- Exception responses. A device that returns an exception for a request it could have answered normally may be signalling by choice of exception code. Filter on
modbus.exception_code: do not testmodbus.func_code > 127, because Wireshark strips the exception bit frommodbus.func_codeand that filter matches nothing. - User defined and reserved function codes. The specification sets aside ranges. Traffic in them has no standard meaning, so the payload is whatever the sender decided.
- Device identification and diagnostic requests. These return strings or counters, and the returned text can be altered.
- Timing. The gaps between otherwise identical requests can encode bits. This is covered in its own article in this series.
To find them you do not need nine different tools. Start by listing function codes and their counts, which isolates places 3, 7 and 8. Then pull out the values from the busiest function with tshark, using one packet per line and the fields you need. Field names can change between Wireshark versions, so run tshark -G fields | grep -i modbus to list what your build exposes rather than trusting an article, including this one.
Decoding is the last step, not the first. Establish that a place is suspicious by statistics before spending time converting it. A register that always holds a plausible temperature is a process value. A register that cycles through values with a high bit clear and a low byte between 0x20 and 0x7e is worth a conversion. Keep your method notes: which carrier, which filter, which conversion, which result.
A worked habit helps here. Suppose a capture shows 300 reads of the same register range and one client whose values differ slightly on every poll. Do not decode yet. Count the distinct values per address, then check whether the number of distinct values is far higher than the process would explain. A temperature that moves by a degree is normal. A register that takes 90 different values in a row, none repeated, is either a very busy process or a carrier. Only then convert. The same order of work applies to every place on the list: establish that it is odd, then establish what it carries, then record how you know. Following that order keeps the effort proportional and keeps your notes reproducible by a colleague.
One boundary applies. These are observations on a capture. Writing to a coil or register on a real device to test a theory is an operation on a live system, not forensics, and is outside what we teach.
For structured practice on this topic, see the OnlySecurity course Modbus Packet Forensics: Hidden Data, Odd Operations and Covert Channels.
More from this author
- One capture, three questions2 December, 2026
- Payload channels versus timing channels2 December, 2026
