Reputation: 27
The problem is that when using a PYQT5 Gui on the server side, I am unable to send commands to remotely controlled devices (Agents on the host) and have the results (information) sent back to the server with a client identification. The clients will not have a gui. I will have to pick and choose which clients get specific commands based on the client identification or session. I am using the Pyqt5 designer and my python code is decoupled from the main application.
The scenario is that I have a pyqt5 network security incident handling framework that starts a server and then listnes for connections. Then I have a python agent(client.py) that connects back to the server. The connection happens and I can currently only send one command (one variable) to the client and have the results transmitted back to the framework. I am not able to send multiple commands to multiple clients based on client id or session.
One of the biggest problems is that I have a working terminal within my server gui and I am not able to transmit the QLineEdit text to the clients based on sessions. If I add in the python input(->) then everything works great however the users would not be able to use the Gui and I want the users to use the Gui.
while I work on the solution my code examples are located below
https://github.com/jinverar/multiconn-client-server
and the code example at the github is based off the following python tutorial
https://realpython.com/python-sockets/#application-client-and-server
The top links that have helped me the most are listed below.
PyQt5: Sending and receiving messages between client and server
https://github.com/jinverar/TCP-ReverseShell
Server-client connection in PyQt
http://www.mranuran.com/blog/2017/08/04/creating-graphical-chat-application-using-pyqt-and-socket/
Some additional links that have helped me get thus far are listed below.
https://www.riverbankcomputing.com/static/Docs/PyQt5/gotchas.html
https://het.as.utexas.edu/HET/Software/PyQt/qabstractsocket.html#setSocketDescriptor
http://www.mranuran.com/blog/2017/08/04/creating-graphical-chat-application-using-pyqt-and-socket/
https://www.zeolearn.com/magazine/getting-started-guis-with-python-pyqt-qthread-class
The following steps have been recommended to move forward and are a possible solution.
1) instead of an advanced GUI build an extremely simply one that has a button -- when you click the button it sends a message to the server -- then click the button more than once maybe sending a counter value for each button click to the server this way you can test continued connection communication.
2) Then on the server do something similar and see if the server can send a message to your client receiving function and in both cases just print you received the message -- this should help you work those kinks out then you can build from there.
the following points are additional guidance.
1) The Server side should be running as a service on the server -- without a GUI and initially just sending output to your normal console window
2) The simple GUI with Client-Communicator you do first make sure you can send multiple messages to the server and it receives them all
3) Then you build a simple server GUI that talks to your Service program (or you can integrate it if you are not sure how to do that) then click the button a few times to make sure you are talking to the client okay
Once you have that going you should have the communicator tested and working then we just plug in the more robust functionality and more complete GUIs
Then 1) Create the Communicator as a Service
2) Add an API aspect to the Communicator
3) Create the GUI to take commands
4) Have the GUI send the information to the Communicator through a call to the API that you created
to do that
1) Implement the Service by pressing a button if it has not been implemented yet
2) Start/Stop the Service via a call
3) Get data from that Service (or in your case send data to and receive data from)
Upvotes: 0
Views: 508