Modbus Unit ID and Station ID Enumerator - Metasploit
This page contains detailed information about how to use the auxiliary/scanner/scada/modbus_findunitid metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Modbus Unit ID and Station ID Enumerator
Module: auxiliary/scanner/scada/modbus_findunitid
Source code: modules/auxiliary/scanner/scada/modbus_findunitid.rb
Disclosure date: 2012-10-28
Last modification time: 2022-01-23 15:28:32 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 502
List of CVEs: -
Modbus is a cleartext protocol used in common SCADA systems, developed originally as a serial-line (RS232) async protocol, and later transformed to IP, which is called ModbusTCP. default tcp port is 502. This module sends a command (0x04, read input register) to the modbus endpoint. If this command is sent to the correct unit-id, it returns with the same function-id. if not, it should be added 0x80, so that it sys 0x84, and an exception-code follows which do not interest us. This does not always happen, but at least the first 4 bytes in the return-packet should be exact the same as what was sent. You can change port, ip and the scan-range for unit-id. There is also added a value - BENICE - to make the scanner sleep a second or more between probes. We have seen installations where scanning too many too fast works like a DoS.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
msf > use auxiliary/scanner/scada/modbus_findunitid
msf auxiliary(modbus_findunitid) > show targets
... a list of targets ...
msf auxiliary(modbus_findunitid) > set TARGET target-id
msf auxiliary(modbus_findunitid) > show options
... show and set options ...
msf auxiliary(modbus_findunitid) > exploit
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Go back to menu.
Msfconsole Usage
Here is how the scanner/scada/modbus_findunitid auxiliary module looks in the msfconsole:
msf6 > use auxiliary/scanner/scada/modbus_findunitid
msf6 auxiliary(scanner/scada/modbus_findunitid) > show info
Name: Modbus Unit ID and Station ID Enumerator
Module: auxiliary/scanner/scada/modbus_findunitid
License: Metasploit Framework License (BSD)
Rank: Normal
Disclosed: 2012-10-28
Provided by:
EsMnemon <[email protected]>
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
BENICE 1 yes Seconds to sleep between StationID-probes, just for beeing nice
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 502 yes The target port (TCP)
TIMEOUT 2 yes Timeout for the network probe, 0 means no timeout
UNIT_ID_FROM 1 yes ModBus Unit Identifier scan from value [1..254]
UNIT_ID_TO 254 yes ModBus Unit Identifier scan to value [UNIT_ID_FROM..254]
Description:
Modbus is a cleartext protocol used in common SCADA systems,
developed originally as a serial-line (RS232) async protocol, and
later transformed to IP, which is called ModbusTCP. default tcp port
is 502. This module sends a command (0x04, read input register) to
the modbus endpoint. If this command is sent to the correct unit-id,
it returns with the same function-id. if not, it should be added
0x80, so that it sys 0x84, and an exception-code follows which do
not interest us. This does not always happen, but at least the first
4 bytes in the return-packet should be exact the same as what was
sent. You can change port, ip and the scan-range for unit-id. There
is also added a value - BENICE - to make the scanner sleep a second
or more between probes. We have seen installations where scanning
too many too fast works like a DoS.
References:
http://www.saia-pcd.com/en/products/plc/pcd-overview/Pages/pcd1-m2.aspx
http://en.wikipedia.org/wiki/Modbus:TCP
Module Options
This is a complete list of options available in the scanner/scada/modbus_findunitid auxiliary module:
msf6 auxiliary(scanner/scada/modbus_findunitid) > show options
Module options (auxiliary/scanner/scada/modbus_findunitid):
Name Current Setting Required Description
---- --------------- -------- -----------
BENICE 1 yes Seconds to sleep between StationID-probes, just for beeing nice
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 502 yes The target port (TCP)
TIMEOUT 2 yes Timeout for the network probe, 0 means no timeout
UNIT_ID_FROM 1 yes ModBus Unit Identifier scan from value [1..254]
UNIT_ID_TO 254 yes ModBus Unit Identifier scan to value [UNIT_ID_FROM..254]
Advanced Options
Here is a complete list of advanced options supported by the scanner/scada/modbus_findunitid auxiliary module:
msf6 auxiliary(scanner/scada/modbus_findunitid) > show advanced
Module advanced options (auxiliary/scanner/scada/modbus_findunitid):
Name Current Setting Required Description
---- --------------- -------- -----------
CHOST no The local client address
CPORT no The local client port
ConnectTimeout 10 yes Maximum number of seconds to establish a TCP connection
FuzzChar X yes Sets the character to use for generating long strings
FuzzTracer MSFROCKS yes Sets the magic string to embed into fuzzer string inputs
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
SSL false no Negotiate SSL/TLS for outgoing connections
SSLCipher no String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
SSLVerifyMode PEER no SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the scanner/scada/modbus_findunitid module can do:
msf6 auxiliary(scanner/scada/modbus_findunitid) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the scanner/scada/modbus_findunitid auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(scanner/scada/modbus_findunitid) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
TCP::max_send_size 0 no Maxiumum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Adjusting UNIT_ID_TO to <UNIT_ID_FROM>
Here is a relevant code snippet related to the "Adjusting UNIT_ID_TO to <UNIT_ID_FROM>" error message:
55: datastore['UNIT_ID_FROM']=1
56: end
57:
58: unless (1..255).include? datastore['UNIT_ID_TO']
59: print_status("Unit ID must be between #{datastore['UNIT_ID_FROM']} and 255")
60: print_warning("Adjusting UNIT_ID_TO to #{datastore['UNIT_ID_FROM']} ")
61: datastore['UNIT_ID_TO'] = datastore['UNIT_ID_FROM']
62: end
63:
64: if datastore['UNIT_ID_FROM'] > datastore['UNIT_ID_TO'] then
65: print_warning("UNIT_ID_TO is less than UNIT_ID_FROM, setting them equal")
UNIT_ID_TO is less than UNIT_ID_FROM, setting them equal
Here is a relevant code snippet related to the "UNIT_ID_TO is less than UNIT_ID_FROM, setting them equal" error message:
60: print_warning("Adjusting UNIT_ID_TO to #{datastore['UNIT_ID_FROM']} ")
61: datastore['UNIT_ID_TO'] = datastore['UNIT_ID_FROM']
62: end
63:
64: if datastore['UNIT_ID_FROM'] > datastore['UNIT_ID_TO'] then
65: print_warning("UNIT_ID_TO is less than UNIT_ID_FROM, setting them equal")
66: datastore['UNIT_ID_TO'] = datastore['UNIT_ID_FROM']
67: end
68:
69: datastore['UNIT_ID_FROM'].upto(datastore['UNIT_ID_TO']) do |counter|
70: sploit = start
Received: incorrect/none data from stationID <COUNTER> (probably not in use)
Here is a relevant code snippet related to the "Received: incorrect/none data from stationID <COUNTER> (probably not in use)" error message:
80: end
81:
82: if data[0,4] == "\x21\x00\x00\x00" #return of the same trans-id+proto-id
83: print_good("Received: correct MODBUS/TCP from stationID #{counter}")
84: else
85: print_status("Received: incorrect/none data from stationID #{counter} (probably not in use)")
86: end
87:
88: disconnect()
89: end
90: end
Go back to menu.
Related Pull Requests
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #8888 Merged Pull Request: spelling/grammar fixes part 1
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #2525 Merged Pull Request: Change module boilerplate
- #967 Merged Pull Request: added a fix for modbusdetect.rb and a new utility modbusFindunitID.rb
References
- CVE: Not available
- http://www.saia-pcd.com/en/products/plc/pcd-overview/Pages/pcd1-m2.aspx
- http://en.wikipedia.org/wiki/Modbus:TCP
See Also
Check also the following modules related to this module:
- auxiliary/scanner/scada/modbus_banner_grabbing
- auxiliary/scanner/scada/bacnet_l3
- auxiliary/scanner/scada/digi_addp_reboot
- auxiliary/scanner/scada/digi_addp_version
- auxiliary/scanner/scada/digi_realport_serialport_scan
- auxiliary/scanner/scada/digi_realport_version
- auxiliary/scanner/scada/indusoft_ntwebserver_fileaccess
- auxiliary/scanner/scada/koyo_login
- auxiliary/scanner/scada/modbusclient
- auxiliary/scanner/scada/modbusdetect
- auxiliary/scanner/scada/moxa_discover
- auxiliary/scanner/scada/pcomclient
- auxiliary/scanner/scada/profinet_siemens
- auxiliary/scanner/scada/sielco_winlog_fileaccess
- auxiliary/analyze/modbus_zip
- auxiliary/admin/scada/advantech_webaccess_dbvisitor_sqli
- auxiliary/admin/scada/ge_proficy_substitute_traversal
- auxiliary/admin/scada/modicon_command
- auxiliary/admin/scada/modicon_password_recovery
- auxiliary/admin/scada/modicon_stux_transfer
- auxiliary/admin/scada/moxa_credentials_recovery
- auxiliary/admin/scada/multi_cip_command
- auxiliary/admin/scada/pcom_command
- auxiliary/admin/scada/phoenix_command
- auxiliary/admin/scada/yokogawa_bkbcopyd_client
- auxiliary/dos/scada/allen_bradley_pccc
- auxiliary/dos/scada/beckhoff_twincat
- auxiliary/dos/scada/d20_tftp_overflow
- auxiliary/dos/scada/igss9_dataserver
- auxiliary/dos/scada/siemens_siprotec4
- auxiliary/dos/scada/yokogawa_logsvr
Authors
- EsMnemon <esm[at]mnemonic.no>
Version
This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.