Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

Multiple clients connected with server?

Hello HF,
Thanks to you I have a fully working RAT (with very basic functions atm), for now the server listens on a port and once a client is connected it stops listening and start commanding the client.
How can i enable it to deal with one client while keep listening on the port for other clients, I have no idea how to go about this please guide me a little.
My aim is to code it so that multiple clients can connect to the server and the server can decide which client it wants to send command to.
Hope I am clear,
thanks :)
I +3 rep4rep <3
For website hacking, custom malware, private RAT source code, dumps etc contact me on TG: @yealink2
(May 14, 2018 12:45 PM)stdio Wrote:  Hello HF,
Thanks to you I have a fully working RAT (with very basic functions atm), for now the server listens on a port and once a client is connected it stops listening and start commanding the client.
How can i enable it to deal with one client while keep listening on the port for other clients, I have no idea how to go about this please guide me a little.
My aim is to code it so that multiple clients can connect to the server and the server can decide which client it wants to send command to.
Hope I am clear,
thanks :)

instead of having the server stop listening have it loop to wait for another client.
[Image: 5Iq5rDJ.gif]

winapi, and winsock programmer

(May 14, 2018 01:19 PM)aeiro Wrote:  instead of having the server stop listening have it loop to wait for another client.

Then i would be stuck in the loop forever, how do I talk with connected client in parallel while listening on port?
I +3 rep4rep <3
For website hacking, custom malware, private RAT source code, dumps etc contact me on TG: @yealink2
(May 14, 2018 01:38 PM)stdio Wrote:  Then i would be stuck in the loop forever, how do I talk with connected client in parallel while listening on port?

look into creating threads.
[Image: 5Iq5rDJ.gif]

winapi, and winsock programmer

You should probably look into multiple threads, or something of that nature? I haven't really played with networking much.
(May 14, 2018 01:55 PM)stdio Wrote:  Great thanks.



So server keeps listening on port, once a client is connected I create a thread (send/recv commands). If there are 10 clients connected I will have 10 threads, can you tell me how do I select a specific client to talk to from a list of say 10 clients? This is console based application so I am thinking server creates a list of connected clients and any one can be selected to send commands.
Thanks again for your help.

Probably a naive method, but you can have a vector of threads. Each thread in the vector has a specific index, so you could either use that for client ID, or somehow map the indexes to your client IDs. When you know what client you want by ID, you find the related index for the thread, and act upon it.
(May 14, 2018 01:55 PM)stdio Wrote:  Great thanks.



So server keeps listening on port, once a client is connected I create a thread (send/recv commands). If there are 10 clients connected I will have 10 threads, can you tell me how do I select a specific client to talk to from a list of say 10 clients? This is console based application so I am thinking server creates a list of connected clients and any one can be selected to send commands.
Thanks again for your help.


and older post of mine shows how you can do this with hash tables.
i wouldn't recommend copy and pasting this. just use it to get an idea.

https://hackforums.net/showthread.php?tid=5808906
[Image: 5Iq5rDJ.gif]

winapi, and winsock programmer

(May 14, 2018 01:38 PM)stdio Wrote:  Then i would be stuck in the loop forever, how do I talk with connected client in parallel while listening on port?

And what's wrong with that? Should a server stop listening for connections to accept? :/ The only thing to consider here is the max clients limit if you want control over that.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
Thank you, I am able to process multiple clients now successfully.
I think I might need to manage the multiple opened threads properly, otherwise it would become a mess once 100-200 clients are connected.
How do you propose I go about this?
I +3 rep4rep <3
For website hacking, custom malware, private RAT source code, dumps etc contact me on TG: @yealink2
(May 16, 2018 02:28 PM)stdio Wrote:  Thank you, I am able to process multiple clients now successfully.
I think I might need to manage the multiple opened threads properly, otherwise it would become a mess once 100-200 clients are connected.
How do you propose I go about this?

Thread synchronization, atomic operations on a reference count for number of connected clients, and check the reference count to determine whether to accept new clients. Essentially what you're trying to build is a semaphore lock.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(May 16, 2018 04:27 PM)0xDEAD10CC Wrote:  Thread synchronization, atomic operations on a reference count for number of connected clients, and check the reference count to determine whether to accept new clients. Essentially what you're trying to build is a semaphore lock.

Great thanks everyone who helped. Consider this help thread closed.
I +3 rep4rep <3
For website hacking, custom malware, private RAT source code, dumps etc contact me on TG: @yealink2
I think the best option would be to use threads and mutexes you could use the select function.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by john ronaldsadJul 20, 2022 06:49 PM 4 238 Jul 20, 2022 06:49 PM
Last Post: john ronaldsad
[C#] by mayar2020Apr 22, 2020 01:01 AM 8 174 Apr 22, 2020 01:01 AM
Last Post: Accord
[Python] by PGTipsJul 13, 2017 10:04 AM 5 183 Jul 13, 2017 10:04 AM
Last Post: Davian