Xeno-rat
Loading...
Searching...
No Matches
xeno_rat_client.SocketHandler Class Reference
Collaboration diagram for xeno_rat_client.SocketHandler:

Public Member Functions

 SocketHandler (Socket socket, byte[] _EncryptionKey)
 
byte[] BTruncate (byte[] bytes, int offset)
 Truncates the input byte array from the specified offset and returns the truncated byte array.
 
async Task< bool > SendAsync (byte[] data)
 Asynchronously sends the specified data over the socket after compressing, encrypting, and adding necessary headers.
 
async Task< byte[]> ReceiveAsync ()
 Asynchronously receives data and performs various operations on it, such as decryption, decompression, and parsing headers, before returning the result.
 
int BytesToInt (byte[] data, int offset=0)
 Converts the specified byte array to an integer.
 
byte[] IntToBytes (int data)
 Converts an integer to a byte array.
 
void SetRecvTimeout (int ms)
 Sets the receive timeout for the socket.
 
void ResetRecvTimeout ()
 Resets the receive timeout for the socket to zero.
 

Static Public Member Functions

static byte[] Concat (byte[] b1, byte[] b2)
 Concatenates two byte arrays and returns the result.
 

Public Attributes

Socket sock
 
byte[] EncryptionKey
 

Private Member Functions

async Task< byte[]> RecvAllAsync_ddos_unsafer (int size)
 Asynchronously receives all the data of the specified size from the connected socket and returns it as a byte array.
 
async Task< byte[]> RecvAllAsync_ddos_safer (int size)
 Asynchronously receives all the data of the specified size from the connected socket and returns the received data as a byte array.
 
header ParseHeader (byte[] data)
 Parses the header from the given byte array and returns the header information.
 

Private Attributes

int socktimeout = 0
 

Constructor & Destructor Documentation

◆ SocketHandler()

xeno_rat_client.SocketHandler.SocketHandler ( Socket socket,
byte[] _EncryptionKey )
inline

Member Function Documentation

◆ BTruncate()

byte[] xeno_rat_client.SocketHandler.BTruncate ( byte[] bytes,
int offset )
inline

Truncates the input byte array from the specified offset and returns the truncated byte array.

Parameters
bytesThe input byte array from which the truncation will be performed.
offsetThe offset from which the truncation will start.
Returns
The truncated byte array starting from the specified offset .

This method creates a new byte array T_data with a length equal to the difference between the length of the input byte array bytes and the specified offset . It then uses the Buffer.BlockCopy method to copy the data from the input byte array starting from the specified offset to the newly created byte array T_data . The resulting truncated byte array T_data is then returned.

Here is the caller graph for this function:

◆ BytesToInt()

int xeno_rat_client.SocketHandler.BytesToInt ( byte[] data,
int offset = 0 )
inline

Converts the specified byte array to an integer.

Parameters
dataThe byte array to be converted.
offsetThe offset within the byte array where the conversion should start (default is 0).
Returns
The integer value converted from the specified byte array.

This method converts the specified byte array to an integer value, taking into account the endianness of the system. If the system is little-endian, the bytes are combined in little-endian order (least significant byte first). If the system is big-endian, the bytes are combined in big-endian order (most significant byte first).

Here is the caller graph for this function:

◆ Concat()

static byte[] xeno_rat_client.SocketHandler.Concat ( byte[] b1,
byte[] b2 )
inlinestatic

Concatenates two byte arrays and returns the result.

Parameters
b1The first byte array to be concatenated. If null, an empty byte array is used.
b2The second byte array to be concatenated.
Returns
A byte array containing the concatenated elements of b1 and b2 .

This method concatenates the elements of the input byte arrays b1 and b2 into a single byte array. If b1 is null, an empty byte array is used for concatenation.

Here is the caller graph for this function:

◆ IntToBytes()

byte[] xeno_rat_client.SocketHandler.IntToBytes ( int data)
inline

Converts an integer to a byte array.

Parameters
dataThe integer to be converted to a byte array.
Returns
A byte array representing the input integer.

This method converts the input integer data to a byte array of length 4. If the system architecture is little-endian, the bytes are arranged in little-endian order; otherwise, they are arranged in big-endian order.

Here is the caller graph for this function:

◆ ParseHeader()

header xeno_rat_client.SocketHandler.ParseHeader ( byte[] data)
inlineprivate

Parses the header from the given byte array and returns the header information.

Parameters
dataThe byte array containing the header information.
Returns
The parsed header information as an instance of the header class.

This method parses the header information from the input byte array and creates a new instance of the header class to store the parsed information. If the first byte of the input data is 1, it indicates that the data is compressed, and the method sets the corresponding properties of the header instance. The method also sets the original file size and T_offset properties based on the input data. If the first byte of the input data is not 0 or 1, the method returns null, indicating that the header parsing failed.

Exceptions
System.IndexOutOfRangeExceptionThrown if the input data array is empty or does not contain sufficient elements to parse the header.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReceiveAsync()

async Task< byte[]> xeno_rat_client.SocketHandler.ReceiveAsync ( )
inline

Asynchronously receives data and performs various operations on it, such as decryption, decompression, and parsing headers, before returning the result.

Returns
The received data after decryption, decompression, and parsing headers.
Exceptions
ExceptionThrown when an error occurs during the data receiving process.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecvAllAsync_ddos_safer()

async Task< byte[]> xeno_rat_client.SocketHandler.RecvAllAsync_ddos_safer ( int size)
inlineprivate

Asynchronously receives all the data of the specified size from the connected socket and returns the received data as a byte array.

Parameters
sizeThe size of the data to be received.
Returns
The received data as a byte array. Returns null if the socket is not connected, or if a timeout occurs while waiting for data.
Exceptions
System.ObjectDisposedExceptionThe socket has been closed.
System.Net.Sockets.SocketExceptionAn error occurred when attempting to access the socket.

This method asynchronously receives data from the connected socket until the specified size is reached. If the socket is not connected, it returns null. If a timeout occurs while waiting for data, it also returns null. The method also handles potential exceptions such as ObjectDisposedException and SocketException.

◆ RecvAllAsync_ddos_unsafer()

async Task< byte[]> xeno_rat_client.SocketHandler.RecvAllAsync_ddos_unsafer ( int size)
inlineprivate

Asynchronously receives all the data of the specified size from the connected socket and returns it as a byte array.

Parameters
sizeThe size of the data to be received.
Returns
The received data as a byte array. If the socket is not connected, returns null.
Exceptions
SocketExceptionThrown when an error occurs with the socket.

This method asynchronously receives data from the connected socket until the specified size is reached. It initializes the last send time and continuously receives data in a loop until the total received data size matches the specified size. If the socket is not connected, it returns null. If an error occurs with the socket, a SocketException is thrown.

Here is the caller graph for this function:

◆ ResetRecvTimeout()

void xeno_rat_client.SocketHandler.ResetRecvTimeout ( )
inline

Resets the receive timeout for the socket to zero.

This method sets the socktimeout to zero and also sets the ReceiveTimeout property of the socket to zero.

Here is the caller graph for this function:

◆ SendAsync()

async Task< bool > xeno_rat_client.SocketHandler.SendAsync ( byte[] data)
inline

Asynchronously sends the specified data over the socket after compressing, encrypting, and adding necessary headers.

Parameters
dataThe data to be sent over the socket.
Exceptions
ArgumentNullExceptionThrown when the input data is null.
Returns
True if the data is successfully sent over the socket; otherwise, false.

This method compresses the input data using the Compression class, and then encrypts it using the EncryptionKey. It adds necessary headers and protocol upgrade byte before sending the data over the socket.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetRecvTimeout()

void xeno_rat_client.SocketHandler.SetRecvTimeout ( int ms)
inline

Sets the receive timeout for the socket.

Parameters
msThe receive timeout value in milliseconds.

This method sets the receive timeout for the underlying socket to the specified value in milliseconds.

Here is the caller graph for this function:

Member Data Documentation

◆ EncryptionKey

byte [] xeno_rat_client.SocketHandler.EncryptionKey

◆ sock

Socket xeno_rat_client.SocketHandler.sock

◆ socktimeout

int xeno_rat_client.SocketHandler.socktimeout = 0
private

The documentation for this class was generated from the following file: