secskills
secskills / offense / testing-ics-ot-protocols

testing-ics-ot-protocols

offense verified 2026-07-27

Test Industrial Control Systems and Operational Technology protocols — Modbus, DNP3, OPC UA, BACnet, EtherNet/IP, S7comm, MQTT — with safety-first methodology for SCADA and ICS environments. Use when assessing OT network security, testing ICS protocol authentication, reviewing IT-OT segmentation, or performing authorized ICS penetration testing.

$ /plugin install secskills-offense $ /plugin install secskills-core

ICS/OT protocols were designed for reliability in isolated networks, not security on connected ones. Most have no authentication, no encryption, and no integrity checking. The danger is not that they are hard to exploit — it is that exploitation can have physical consequences, which is why safety constraints govern everything you do here.

When to Use

When NOT to Use

Safety-First Principles

OT pentesting is not IT pentesting with different ports. The rules of engagement are fundamentally different because the targets control physical processes.

Why active scanning is dangerous in OT:

Mandatory constraints:

  1. Always have an OT engineer or plant operator present or on immediate call during active testing.
  2. Obtain written authorization that explicitly covers ICS/OT assets — general network pentest scope does not imply OT scope.
  3. Test in maintenance windows whenever possible. Never test safety-instrumented systems (SIS) without explicit, separate authorization.
  4. Start with passive observation. Move to active enumeration only after the passive phase confirms device types and the OT engineer approves.
  5. Distinguish read-only operations (reading registers, querying device info) from write operations (setting coils, writing registers, issuing commands). Write operations require per-device approval.
  6. Have a rollback plan for every write operation. Know the expected state before you change anything.
  7. Document every interaction with every device, including timestamps and the exact commands sent.

Protocol Overview

ProtocolDefault PortAuth by DesignEncryptionNotes
Modbus TCP502NoNoMost common ICS protocol; any host on the network can read/write
DNP320000Optional (SA)NoSCADA polling; Secure Authentication is rarely deployed
EtherNet/IP (CIP)44818NoNoRockwell/Allen-Bradley ecosystem
OPC UA4840Yes (multiple modes)Optional (TLS)Modern; security depends entirely on configuration
BACnet/IP47808 (UDP)NoNoBuilding automation — HVAC, lighting, access control
S7comm102NoNoSiemens S7 PLCs; replaced by S7comm-plus with some protection
MQTT1883 / 8883 (TLS)OptionalOptional (TLS)IoT/ICS messaging; brokers often left open

Passive Reconnaissance

Start here. Passive observation carries no risk of disrupting devices and provides the asset inventory you need before touching anything.

Wireshark with ICS dissectors:

# Capture on the OT network interface (mirror/span port or tap)
tcpdump -i eth0 -w ics_capture.pcap -n

# Wireshark filters for ICS protocols
# Modbus
modbus

# DNP3
dnp3

# EtherNet/IP
enip

# OPC UA
opcua

# BACnet
bacnet

# S7comm
s7comm

# MQTT
mqtt

What to extract from passive captures:

Asset inventory from passive observation:

Build a table: IP, MAC, vendor (from OUI), protocol(s) observed, role (master/slave/HMI/historian), firmware version if visible. This becomes the basis for active enumeration scope.

Active Enumeration (When Authorized)

Only proceed after: (1) passive recon is complete, (2) OT engineer has reviewed the asset list and approved active testing, (3) scope explicitly includes active ICS enumeration.

Safe nmap usage for ICS:

# NEVER use aggressive timing or default scripts against OT devices
# Use slow timing and specific ICS scripts only

# Modbus device discovery
nmap -Pn -sT -p 502 --script modbus-discover TARGET

# Siemens S7 device info (read-only query)
nmap -Pn -sT -p 102 --script s7-info TARGET

# BACnet device enumeration
nmap -Pn -sU -p 47808 --script bacnet-info TARGET

# EtherNet/IP enumeration
nmap -Pn -sT -p 44818 --script enip-info TARGET

# OPC UA discovery
nmap -Pn -sT -p 4840 --script opcua-endpoints TARGET

# IMPORTANT: Use -Pn (skip host discovery), -sT (full connect, not SYN scan),
# and NEVER use -A, -sV with high intensity, or broad script categories
# against OT devices.

Dedicated ICS scanning tools:

# plcscan — lightweight PLC scanner
plcscan -t TARGET

# Redpoint Nmap scripts (Digital Bond)
# These are ICS-specific and safer than generic nmap scripts
nmap --script redpoint/ -p 502,44818,47808,102,20000 TARGET

Protocol-Specific Testing

Modbus TCP (Port 502)

Modbus has no authentication. Any host that can reach port 502 can read sensors, write to coils, and control the PLC. This is by design — it was created in 1979 for serial links in isolated environments.

Reading coils and registers (read-only, lower risk):

# Using modbus-cli
modbus read TARGET 0 10          # Read 10 holding registers starting at address 0
modbus read -s coil TARGET 0 10  # Read 10 coils starting at address 0

# Using mbtget
mbtget -a 1 -r1 -n 10 TARGET    # Read 10 holding registers, unit ID 1
mbtget -a 1 -r2 -n 10 TARGET    # Read 10 input registers

# Python with pymodbus
python3 -c "
from pymodbus.client import ModbusTcpClient
client = ModbusTcpClient('TARGET')
client.connect()
result = client.read_holding_registers(0, 10, unit=1)
print(result.registers)
client.close()
"

Key Modbus function codes:

FC 01 - Read Coils (digital outputs)
FC 02 - Read Discrete Inputs (digital inputs)
FC 03 - Read Holding Registers (analog outputs / config)
FC 04 - Read Input Registers (analog inputs)
FC 05 - Write Single Coil              ← WRITE — requires explicit approval
FC 06 - Write Single Register           ← WRITE — requires explicit approval
FC 15 - Write Multiple Coils            ← WRITE — requires explicit approval
FC 16 - Write Multiple Registers        ← WRITE — requires explicit approval
FC 43 - Read Device Identification

The finding to report: If you can reach port 502 from outside the process control network, the control system has no access control. This is almost always Critical — document the network path and what registers you could read.

OPC UA (Port 4840)

OPC UA is the one ICS protocol that was designed with security in mind. Whether it is actually secure depends on how it is configured.

Discovery and endpoint enumeration:

# List OPC UA endpoints and their security modes
# Using opcua-client-gui or UaExpert

# Python with opcua library
python3 -c "
from opcua import Client
client = Client('opc.tcp://TARGET:4840')
endpoints = client.connect_and_get_server_endpoints()
for ep in endpoints:
    print(f'Endpoint: {ep.EndpointUrl}')
    print(f'  Security Mode: {ep.SecurityMode}')
    print(f'  Security Policy: {ep.SecurityPolicyUri}')
    print(f'  User Token: {[t.TokenType for t in ep.UserIdentityTokens]}')
"

Authentication modes to check:

Common OPC UA findings:

DNP3 (Port 20000)

# DNP3 enumeration — identify master/outstation roles
nmap -Pn -sT -p 20000 --script dnp3-info TARGET

# Check for DNP3 Secure Authentication (rarely deployed)
# Most DNP3 implementations have no authentication at all

BACnet (Port 47808 UDP)

# BACnet device discovery
nmap -Pn -sU -p 47808 --script bacnet-info TARGET

# BACnet enumeration with BAC0
python3 -c "
import BAC0
bacnet = BAC0.lite(ip='YOUR_IP/24')
devices = bacnet.whois()
print(devices)
"

S7comm (Port 102)

# Siemens S7 PLC information
nmap -Pn -sT -p 102 --script s7-info TARGET

# Identifies: module name, serial number, plant identification,
# firmware version, hardware version, CPU state

Common Findings

These appear in the majority of ICS assessments:

1. Flat networks (IT-OT convergence) The single most impactful finding. No segmentation between corporate IT and control systems means any compromised workstation can reach PLCs directly. Test by attempting to reach ICS ports from IT network segments.

2. Default credentials on HMIs and engineering workstations HMI web interfaces, VNC servers on operator stations, and engineering software often use factory defaults. Check vendor documentation for default credentials before testing.

3. Unauthenticated protocols exposed to non-process networks Modbus, S7comm, and BACnet have no authentication. If these ports are reachable from outside the process control network, any compromised host can control physical processes.

4. Unencrypted protocols carrying sensitive data Credentials, process values, and configuration data transmitted in cleartext. Demonstrate with a packet capture showing readable data.

5. Remote access gateways with weak controls VPN concentrators, jump hosts, or cellular modems providing remote access to OT networks. Check for multi-factor authentication, session logging, and access restrictions.

6. Outdated firmware with known vulnerabilities ICS devices often run firmware years behind current releases because patching requires downtime. Document versions and map to known CVEs, but do not attempt exploitation without explicit approval.

7. Historian and data diode misconfigurations Historians bridging IT and OT should be in a DMZ. Data diodes should enforce unidirectional flow. Verify with traffic analysis.

Network Segmentation Review

Assess against the Purdue Enterprise Reference Architecture:

Level 5  Enterprise network (corporate IT)
Level 4  Site business planning (ERP, email)
         ─── IT/OT DMZ ───
Level 3  Site operations (historians, OPC servers)
Level 2  Area supervisory control (HMI, engineering workstations)
Level 1  Basic control (PLCs, RTUs, controllers)
Level 0  Process (sensors, actuators, field devices)

What to verify:

Defensive Review Checklist

When reviewing ICS security posture rather than attacking:

Rationalizations to Reject

crash a PLC and stop a physical process. OT scanning requires device-specific knowledge, slow timing, and an engineer who can intervene.

contact with reality. USB drives, maintenance laptops, cellular modems, and vendor VPNs create paths that bypass the gap.

only — traffic capture and architecture review still produce high-value findings. Do not skip the engagement.

registers you could read, and what they control. "Port 502 open" is a scan result, not a finding.

operations on some devices have side effects. The engineer knows which devices are sensitive. Keep them in the loop.

environment can cause physical damage. Demonstrate the ability to write without actually writing, or test in a maintenance window with the process safely shut down.

protocol security are not evidence. Test it. Many "proprietary" protocols are trivially reverse-engineered or provide security through obscurity only.

References