Three tools cover nearly every Modbus capture exercise, and the right choice depends on the question, not on habit.
Wireshark is the best tool for the first ten minutes. The protocol hierarchy, the conversation table and the colouring rules give you a map of an unfamiliar file quickly. Follow TCP stream is useful for seeing a request and response pair together. Its weakness is repetition: when the answer needs 4,000 register values converted and reordered, clicking becomes the bottleneck and errors creep in.
tshark is the command line sibling and is better for anything you want to record. The options we use in the course are -r to read a file, -Y for a display filter, -T fields with one or more -e field names to print columns, and -z for statistics such as io,phs (protocol hierarchy) and conv,tcp (conversations). Because the command is a line of text, you can paste it into your notes and a colleague can repeat it exactly. Its weakness is that it only knows what the dissector exposes. If the dissector does not break out a field, you get raw bytes and need a second tool.
Python with scapy, or a wrapper such as pyshark, is better for transformation. Reading a capture with scapy gives you every packet as an object, and you can sort, group, convert encodings and compare values without leaving the script. The weakness is cost: you write and debug the parser, and it may not decode Modbus the way the dissector does. A hand parser that assumes a fixed header length will be wrong the first time a frame is split across segments.
A practical rule is to use all three in order. Orient in Wireshark. Extract with tshark into a text file, one packet per line, with the time, source, destination, function code and the data field. Transform in Python, reading that text file rather than the capture, which also keeps you away from parsing mistakes in packet handling.
Some cautions. Display filters and capture filters use different syntax, so a filter that works in the Wireshark bar may not be valid on the command line with -f. Field names change between versions, so record the version you used. For large files, editcap can split by packet count, and tshark can be told to stop after a number of packets, but verify the options on your build with --help.
None of these tools should be pointed at a live controller. Reading is passive. A scripted client that opens a connection to a device and sends a request is another category entirely, and our exercises never ask for it.
Whatever tool you choose, keep a consistent working folder. Put the original capture in a read only location and record its SHA-256. Write extracted text files beside your notes, named for the filter that produced them, so that a result can always be traced to a command. Where a step takes more than a few seconds on a large file, say so in your notes, because a colleague repeating your work will want to know whether a slow run is expected. If you move between tools, check that the same packet number refers to the same frame in each, since filtering and splitting can renumber packets. Writing down the frame number together with the timestamp avoids confusion when you come back to a finding a week later.
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
