kihtrak
Hello there, 
Is it possible to make the OpenPLC work under various other protocols like the ones listed in this : https://www.promotic.eu/en/pmdoc/Subsystems/Comm/PLC/AllenBradley.htm

The main idea is to check the vulnerabilities in these protocols. 
If possible, kindly guide how can these be implemented, in detail. 
Thanks in advance. 
Reply 0 0
thiagoralves
It is possible if someone implement the code for it. Currently OpenPLC talks Modbus and DNP3 (DNP3 support is still experimental on a test branch).

If you find an open source library that implements these protocols, it should be fairly easy to add them to OpenPLC.
Reply 0 0
kihtrak
Hello there, 
Will something like this library work with OpenPLC? ( https://sourceforge.net/projects/libpccc/ ) . If yes, how to add it to the OpenPLC?
If not, is there any criteria that I need to look for when searching for libraries that could be added to OpenPLC project?
Also, I assume we might not be able to communicate using more than one protocol. In order to handle all the protocols that we use, do we have to have any other device like arduino or such to handle the bus protocols? Since, we might have to penetrate and test the protocol for vulnerabilities. 
Kindly find some time to reply. Thanks in advance.
Reply 0 0
thiagoralves
It should be possible. The implementation depends on how the library works. You must understand the library and then combine its functionality with OpenPLC. I don't know anything about this library, so I don't know how the integration should be made, however, I can give you a basic explanation about OpenPLC so that you can integrate the library once you understand how it works.

The best way to start digging into the OpenPLC is to look at its code. I can give you a brief overview, but only after you start reading the code you'll understand what's going on. As always I'm open for questions, so please let me know if you need clarification on a specific topic.

The OpenPLC basically has 3 independent pieces: graphical editor, web server and compiler

The graphical editor (PLCopen Editor) is what you use to write your PLC programs. No mysteries in it. It was written in python for the Beremiz project, and its main function is to generate a Structured Text file out of your PLC program. We can say that the Structured Text file is the first step of the compilation process.

The web server is an utility to help you upload the Structured Text file generated by the graphical editor to the OpenPLC. It was written in NodeJS and therefore requires NodeJS to run. The code is simple (although not very clean), and it's located at the /server.js file. Looking at this file will help you understand how the Structured Text is compiled into a final binary application

The compiler is called by the web server to generate a C program out of your uploaded Structured Text file. After the C program is generated, it is moved into the /core/ folder and then the compilation scripts calls GCC to compile all files inside the /core/ folder into a final executable file for your platform. This means that every time you upload a new Structured Text file to the OpenPLC, a new executable is generated that replaces the old one.

Now that you have a generic overview of how OpenPLC works, take a look inside the /core/ folder. The files there are pretty much self-explanatory, and contain the entire source code for the OpenPLC. The route to integrate a new protocol into OpenPLC is basically to mimic the Modbus/TCP implementation that you will find in the modbus.cpp file. The purpose of any SCADA protocol is to basically read and write contents into PLC memory. OpenPLC has a few global buffers that hold your program's variables and I/O. The library should be able to read and write to these buffers as well. If you look at the files hardware_layer.cpp and modbus.cpp you will see code interfacing with these buffers to read and write data to them.

Your implementation for PCCC should be similar to my Modbus implementation, and you might be able to reuse a lot of code. Try to avoid rewriting code. It not only makes the project more complicated to read, but also introduces bugs. For example, for the TCP/IP layer, you might be able to reuse the server.cpp implementation entirely if the library doesn't already implement its own. If modifications are needed for the TCP/IP layer, modify the server.cpp implementation instead of creating your own implementation from scratch.

OpenPLC can handle multiple protocols running at the same time if they run on top of the TCP/IP network. Right now it has Modbus running on port 502 and DNP3 running on port 20000.
Reply 0 0
Reply