Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

modbus write-coil

Writes a boolean value to a single Modbus coil using function code 05 (Write Single Coil).

Coils typically control digital outputs : relays, solenoid valves, motor starters, indicator lights and similar actuators. Unauthenticated coil writes can directly affect physical processes.

Warning: Writing to coils can immediately actuate physical devices!

Status

ResultMeaning
passWrite accepted by the device
failWrite rejected, invalid value, or connection failed

Severity classification

SeverityCondition
CriticalWrite succeeded (unauthenticated control of a digital output)
InfoWrite failed, invalid value, or connection failed

Usage

iottack modbus write-coil --host <HOST> --value <VALUE> [OPTIONS]
iottack modbus write-coil --serial <DEVICE> --value <VALUE> [OPTIONS]

--value is required.

Options

FlagShortDefaultDescription
--host <HOST>-H(required or –serial)Target hostname or IP for Modbus/TCP
--tcp-port <PORT>-502Modbus/TCP port
--serial <DEVICE>-s(required or –host)Serial device for Modbus RTU (e.g., /dev/ttyUSB0)
--baud <BAUD>-9600Baud rate for RTU serial
--unit <ID>-u1Modbus unit/slave ID (1-247)
--timeout-ms <MS>-t3000Timeout in milliseconds
--address <ADDR>-a0Coil address (0-65535)
--value <VALUE>-v(required)Coil state: on/off, 1/0 or true/false
--output <FILE>-o-Save result to a file
--format <FORMAT>-ftexttext or json
--verbose-v-Increase log verbosity

Accepted values for --value

InputMeaning
on, 1, true, yesCoil ON (0xFF00 on the wire)
off, 0, false, noCoil OFF (0x0000 on the wire)

Examples

Turn coil 5 on:

iottack modbus write-coil --host 192.168.1.100 --address 5 --value on

Turn coil 5 off:

iottack modbus write-coil --host 192.168.1.100 --address 5 --value off

Write over RTU serial, unit 2:

iottack modbus write-coil --serial /dev/ttyUSB0 --unit 2 \
  --address 0 --value 1

Example output

Plugin name:    modbus/write-coil
Execution time: 0.06 s
Status:         pass

[CRITICAL] Modbus/TCP: coil 5 set to ON without authentication (FC05)
  Unit 1: coil at address 5 written to ON.
  This may directly affect a physical actuator or digital output.
  Evidence: "address=5 value=ON"