0

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.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
Aidan
  • 37
  • 1
  • 1
  • 12

1 Answers1

0

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.
Heath Kang
  • 71
  • 5
  • Hello. I am now having an issue where when I run the "synchronous-server.py" file, nothing seems to happen. Is this normal? – Aidan Dec 02 '17 at 21:02
  • Yeah, it's normal.Then you run the "client.py", you can see the log information in the both console. – Heath Kang Dec 03 '17 at 08:09
  • Okay, so I've gotten this working in one VM. Can I somehow connect two VMs and run the synchronous-server on one and the synchronous-client on another and get them to communicate that way? In other words, is there a way to use networking to accomplish this same test with two VMs instead of one? Thank you again for all your help. You're a godsend. – Aidan Dec 04 '17 at 18:18
  • Of course, you can build the connection by changing the address parameters to the server ip. I would update my answer and you can see the steps. – Heath Kang Dec 06 '17 at 12:44
  • That makes sense, and I appreciate your specificity in your answer. I am, however, having an issue on my two PCs where the IP address in both VMs is 127.0.0.1, which I understand is a localhost IP, correct? But if they don't have different IPs, I'm not sure how I'll be able to complete the steps above. Do you have any suggestions for ways to get this to work despite the localhost IP, or a way to change it? Like I said, I am very new to networking concepts, and your help has been immeasurable. Thank you so much. – Aidan Dec 08 '17 at 16:54
  • maybe you should watch this ["Connecting Two Virtual Machines"](https://www.vmware.com/support/ws5/doc/ws_devices_serial_2vms.html) and this ["Routing between Two Host-Only Networks"](https://www.vmware.com/support/ws5/doc/ws_net_advanced_2hostonly_routing.html) and some VM network configuration tutorials – Heath Kang Dec 14 '17 at 03:52
  • I've gotten it to work, thanks to your help! I was just wondering if you have any resources or suggestions about where I can do more research, specifically about the transactions that are send and received between the client and the server (the part on the above screenshot where it says "0x0 0x1 0x0 0x0 0x0 0x6.. etc.). I'm having trouble finding out what these transactions mean. Thank you so much! You're help has worked wonders on my project! – Aidan Dec 29 '17 at 22:41
  • Sorry for responsing so late, I suggest you can learn common modbus content by [simply modbus](http://www.simplymodbus.ca/). If you want learn more deeper about coding rule, you can learn CSAPP chapter 2 Representing and Manipulating Information. – Heath Kang Jan 19 '18 at 08:56