DNP3 traffic tells a story about who controls what. Masters poll outstations, outstations answer with measurements and events, and occasionally an outstation speaks first with an unsolicited response. Analysis means turning a capture into that story, then checking the security claims. The most common finding is that Secure Authentication is documented but not actually enabled, or enabled only on some links while others stay plain.
Safety warning. DNP3 controls are as sensitive as Modbus writes. A direct operate command can move a breaker or a valve. Analyze passively first, coordinate with operations, and never replay or inject control commands against a live outstation. Lab replay only, with the lab outstation isolated from any real process.
Quick Workflow
- Get written authorization naming the DNP3 segment, the test window, and whether any active probing is permitted at all.
- Capture passively from a span port. Prefer a full poll cycle so integrity polls, event polls, and unsolicited responses all appear.
- Identify masters and outstations by DNP3 address, not just by IP address. One IP gateway can carry several outstation addresses.
- Map the poll pattern. Which master polls which outstation, how often, and with which function codes.
- List the points in use. Binary inputs, analog inputs, counters, and binary outputs, with their DNP3 indexes.
- Check Secure Authentication. Look for challenge and response exchanges, and note every link where they are absent.
- Flag control function codes. SELECT, OPERATE, and DIRECT OPERATE deserve a separate finding with their source addresses.
- Report the map, the authentication verdict per link, and the network controls that should restrict who can speak DNP3.
1. Passive capture and decoding
Start with a capture, then decode it with display filters. The first pass answers who talks to whom, the second pass answers what they say.
# Passive DNP3 capture from a SPAN port (never inline on OT without approval)
sudo tshark -i eth0 -f "tcp port 20000" -w /tmp/dnp3_analysis.pcap &
echo $! > /tmp/dnp3_analysis.pid
# Let it run through a full poll cycle, then stop it
# kill $(cat /tmp/dnp3_analysis.pid)
# Who talks to whom, by DNP3 source and destination address
tshark -r /tmp/dnp3_analysis.pcap -Y "dnp3" \
-T fields -e ip.src -e ip.dst -e dnp3.src -e dnp3.dst \
| sort | uniq -c | sort -nr | head -40
# Control commands stand out and deserve their own review pass
tshark -r /tmp/dnp3_analysis.pcap -Y "dnp3.func == 3 || dnp3.func == 4 || dnp3.func == 5" \
-T fields -e frame.time_relative -e ip.src -e dnp3.src -e dnp3.dst -e dnp3.func
# Unsolicited responses, where the outstation speaks first
tshark -r /tmp/dnp3_analysis.pcap -Y "dnp3.func == 130" \
-T fields -e frame.time_relative -e ip.src -e dnp3.src -e dnp3.dst \
| head -40
2. Function code and point counting
Counting function codes turns a large capture into a short profile. A link that only ever reads is a different risk from a link that regularly issues direct operate commands.
#!/usr/bin/env python3
"""Summarize DNP3 function codes from a tshark field export."""
import collections
import csv
import sys
FUNC_NAMES = {
1: "read", 2: "write", 3: "select", 4: "operate",
5: "direct operate", 20: "enable unsolicited",
21: "disable unsolicited", 129: "response", 130: "unsolicited response",
}
counts = collections.Counter()
pairs = collections.Counter()
with open("/tmp/dnp3_fields.csv", newline="") as handle:
for row in csv.reader(handle):
if len(row) < 3:
continue
src, dst, func = row[0], row[1], row[2]
try:
code = int(func)
except ValueError:
continue
counts[code] += 1
pairs[(src, dst, code)] += 1
for code, total in counts.most_common():
print("function %d (%s): %d frames" % (
code, FUNC_NAMES.get(code, "other"), total))
print("\nTop master to outstation pairs:")
for (src, dst, code), total in pairs.most_common(10):
print("%s -> %s function %d: %d frames" % (src, dst, code, total))
# Build the field export the script above reads
tshark -r /tmp/dnp3_analysis.pcap -Y "dnp3" \
-T fields -e dnp3.src -e dnp3.dst -e dnp3.func \
-E separator=, > /tmp/dnp3_fields.csv
# Save the counting script above as /tmp/dnp3_count.py, then run it
# against the export, not the pcap directly
wc -l /tmp/dnp3_fields.csv
python3 /tmp/dnp3_count.py
3. Secure Authentication check
Secure Authentication adds a challenge and response before critical operations. Its absence on a link that carries controls is a finding on its own, even if the rest of the configuration looks tidy.
# Look for Secure Authentication exchanges in the capture
tshark -r /tmp/dnp3_analysis.pcap -Y "dnp3.al" \
-T fields -e frame.number -e dnp3.src -e dnp3.dst -e dnp3.func \
| head -40
echo "If no challenge or response frames appear on a control link,"
echo "record Secure Authentication as not observed on that link."
echo "Do not claim it is disabled everywhere from one capture alone."
# Gentle DNP3 TCP discovery on the authorized segment only
sudo nmap -sS -p 20000 --open -T2 --max-retries 1 \
192.168.10.0/24 -oN /tmp/dnp3_analysis_disc.txt
grep -B2 open /tmp/dnp3_analysis_disc.txt | head -20
Edge cases
- Serial DNP3. There is no TCP port and no IP address to filter on. Capture from the serial converter or gateway, and map addresses from the DNP3 header alone.
- Broadcast address 65535. A master may address all outstations at once. Do not mistake a broadcast poll for a single device reply.
- Fragmented application layer messages. Large responses arrive in fragments, so a function code count taken from link layer frames alone can mislead. Reassemble in Wireshark before counting points.
- Secure Authentication in aggressive mode. Some deployments use a reduced challenge exchange that is weaker than full challenge response. Note the mode explicitly rather than writing a blanket pass for authentication present.
- Outstations that never answer. A polled address with no response may be offline, filtered, or a stale configuration entry. Report it as unanswered, not as absent.
- Time synchronization traffic. DNP3 time writes look like ordinary writes but carry different risk. Separate them from control commands in the report so the finding is not overstated.
Key references
- IEEE 1815, the DNP3 standard, for function codes, addressing, and Secure Authentication behavior.
- NIST SP 800-82 Rev 3, Guide to Operational Technology Security, for OT capture constraints and assessment safety.
- IEC 62443 zone and conduit concepts, for restricting which hosts may speak DNP3 to an outstation at all.
- Parent skill dnp3-basics, for DNP3 architecture and the fundamentals this analysis sub-skill builds on.
