linuxmodbusdenial-of-serviceman-in-the-middlepymodbus3

PYMODBUS: How to get master to communicate with slave?


I'm working on a project where I have two Debian VMs that both have Pymodbus installed. I'm trying to setup a virtual testing environment where I can perform various cyber attacks on the two from a third Kali VM while they communicate. Unfortunately, I'm very new to unix and PLC programming, and am having some difficulty getting the two to communicate with each other. Ideally, the master should send data to the slave, who then updates some information and sends a response back. Does anyone know how to begin to get these two to work together? I'm really at a loss here, and I have no idea where to begin. Thank you so much, I really appreciate it.

I got pymodbus from here: https://pypi.python.org/pypi/pymodbus Documentation located here: https://github.com/riptideio/pymodbus

P.S. I used pip to install the above .whl file, but I've seen other people install pymodbus by simply running a command, which makes me worry that I've done this all wrong.


Solution

  • You can run a test in one Debian VM system.

    1. run the server file, and set the ip and port.

    2. run the client file, and connect to the ip and port.

    That is tcp/ip method and you can do serial method by the same file.Just look the comments in the above files. If any questions, let me know.

    server picture: enter image description here client picture: enter image description here

    updated:

    1.connect two PCs by local area network.Make sure two PCs can ping each other. 2.set synchronous-server.py:

    StartTcpServer(context, identity=identity, address=("0.0.0.0", 5020)) which means listen all the coming connection requests from all ip.

    3.setsynchronous-client.py(let's assume the server pc ip is "192.168.1.10", you should replace this ip to real server ip):

    client = ModbusClient('192.168.1.10', port=5020)

    4.run the two py files and it should works now.