Sending Multiple Network Streams Simultaneously...
-
I am working on a RAT (Remote Administration Tool)... Below is an explanation and the question... If you'd like you can skip the rest and read the question :) [Program Explanation] A program working on the Admin-side sends a command to the Client-side program (through TCP/IP), and after interpreting the instruction, it does the requested action. For example, if the Admin-side sends "list drives", the Client-side program interprets the command and sends a string[] back to the Admin as a byte[]... The admin-side would convert the byte[] to a string[] That's no big deal... [End of Program Explanation] [Question] The question is... Can I send multiple Network Streams at one time, and each are separately recognized by the receiving-end? This is important if more than one task are performed at one time - such as getting a file and keyboard logs... (Since the conversion at the receiving-end needs to be made for the relevant response... Last I tried, I sent two different Network Streams exactly after each other and the receiving end had thought that it was the same stream!! - It resulted in total chaos ;) [End of Question] [Program Coding] To send a command, there are two important methods
public byte[] Serialize(object oSerialize)
{
ms = new MemoryStream();
bf = new BinaryFormatter();
bf.Serialize(ms, oSerialize);
return ms.ToArray();
}public byte[] Serialize(object oSerialize)
{
ms = new MemoryStream();
bf = new BinaryFormatter();
bf.Serialize(ms, oSerialize);
return ms.ToArray();
}On the receiving end, a similar system is used, being Receive and DeSerialize... [End of Program Coding]
-
I am working on a RAT (Remote Administration Tool)... Below is an explanation and the question... If you'd like you can skip the rest and read the question :) [Program Explanation] A program working on the Admin-side sends a command to the Client-side program (through TCP/IP), and after interpreting the instruction, it does the requested action. For example, if the Admin-side sends "list drives", the Client-side program interprets the command and sends a string[] back to the Admin as a byte[]... The admin-side would convert the byte[] to a string[] That's no big deal... [End of Program Explanation] [Question] The question is... Can I send multiple Network Streams at one time, and each are separately recognized by the receiving-end? This is important if more than one task are performed at one time - such as getting a file and keyboard logs... (Since the conversion at the receiving-end needs to be made for the relevant response... Last I tried, I sent two different Network Streams exactly after each other and the receiving end had thought that it was the same stream!! - It resulted in total chaos ;) [End of Question] [Program Coding] To send a command, there are two important methods
public byte[] Serialize(object oSerialize)
{
ms = new MemoryStream();
bf = new BinaryFormatter();
bf.Serialize(ms, oSerialize);
return ms.ToArray();
}public byte[] Serialize(object oSerialize)
{
ms = new MemoryStream();
bf = new BinaryFormatter();
bf.Serialize(ms, oSerialize);
return ms.ToArray();
}On the receiving end, a similar system is used, being Receive and DeSerialize... [End of Program Coding]
You can never be sure that the message sent is recieved as one piece at the client. To be sure, you may use some Start and End indentifier for each message you send. At the client side, write a function which makes sure that stream is completely recieved and if not retrieve the remaining message from the next received.
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.