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

Public Member Functions

 Node (SocketHandler _sock, Action< Node > _OnDisconnect)
 
void AddSubNode (Node subNode)
 Adds a sub-node to the current node.
 
async void Disconnect ()
 Disconnects the current socket and clears the subNodes list, and invokes the OnDisconnect event if it is not null.
 
async Task< NodeConnectSubSockAsync (int type, int retid, Action< Node > OnDisconnect=null)
 Asynchronously connects a sub socket and sets up the connection with the specified parameters.
 
bool Connected ()
 Checks if the socket is connected and returns a boolean value indicating the connection status.
 
async Task< byte[]> ReceiveAsync ()
 Asynchronously receives data from the socket and returns the received data as a byte array.
 
async Task< bool > SendAsync (byte[] data)
 Asynchronously sends the specified data over the socket connection.
 
void SetRecvTimeout (int ms)
 Sets the receive timeout for the socket.
 
void ResetRecvTimeout ()
 Resets the receive timeout for the socket.
 
async Task< bool > AuthenticateAsync (int type, int id=0)
 Authenticates the connection based on the specified type and optional ID.
 

Public Attributes

List< NodesubNodes = new List<Node>()
 
SocketHandler sock
 
Node Parent
 
int ID = -1
 
int SetId = -1
 
int SockType = -1
 

Private Member Functions

static int memcmp (byte[] b1, byte[] b2, long count)
 Compares two byte arrays and returns an integer that indicates their relationship in terms of order.
 
bool ByteArrayCompare (byte[] b1, byte[] b2)
 Compares two byte arrays and returns true if they are equal, otherwise returns false.
 

Private Attributes

Action< NodeOnDisconnect
 

Constructor & Destructor Documentation

◆ Node()

xeno_rat_client.Node.Node ( SocketHandler _sock,
Action< Node > _OnDisconnect )
inline

Member Function Documentation

◆ AddSubNode()

void xeno_rat_client.Node.AddSubNode ( Node subNode)
inline

Adds a sub-node to the current node.

Parameters
subNodeThe sub-node to be added.

This method adds the specified sub-node to the list of sub-nodes associated with the current node.

Here is the caller graph for this function:

◆ AuthenticateAsync()

async Task< bool > xeno_rat_client.Node.AuthenticateAsync ( int type,
int id = 0 )
inline

Authenticates the connection based on the specified type and optional ID.

Parameters
typeThe type of authentication. 0 for main, 1 for heartbeat, 2 for anything else.
idThe optional ID for authentication. Defaults to 0.
Returns
A boolean value indicating whether the authentication was successful.

This method asynchronously authenticates the connection based on the specified type and optional ID. It sets a receive timeout of 5000 milliseconds, receives data from the socket, sends the received data back, and resets the receive timeout. If the received data matches a predefined byte array, it further processes the authentication based on the type. If the type is 0, it receives data from the socket to obtain a connection ID and sets the ID property. If the type is not 0, it sets the ID property with the specified ID and sends the ID back to the socket. The method returns true if the authentication is successful; otherwise, it returns false.

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

◆ ByteArrayCompare()

bool xeno_rat_client.Node.ByteArrayCompare ( byte[] b1,
byte[] b2 )
inlineprivate

Compares two byte arrays and returns true if they are equal, otherwise returns false.

Parameters
b1The first byte array to be compared.
b2The second byte array to be compared.
Returns
True if the byte arrays are equal in length and content, otherwise false.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Connected()

bool xeno_rat_client.Node.Connected ( )
inline

Checks if the socket is connected and returns a boolean value indicating the connection status.

Returns
True if the socket is connected; otherwise, false.

This method checks the connection status of the socket and returns a boolean value indicating whether the socket is connected or not. If an exception occurs during the check, the method returns false.

Here is the caller graph for this function:

◆ ConnectSubSockAsync()

async Task< Node > xeno_rat_client.Node.ConnectSubSockAsync ( int type,
int retid,
Action< Node > OnDisconnect = null )
inline

Asynchronously connects a sub socket and sets up the connection with the specified parameters.

Parameters
typeThe type of the socket connection.
retidThe return ID for the connection.
OnDisconnectAn optional action to be performed on disconnection.
Returns
A Node representing the connected sub socket.

This method creates a new socket with the specified address family, socket type, and protocol type. It then asynchronously connects to the remote endpoint of the socket. After successful connection, it sets up the connection using the Utils.ConnectAndSetupAsync method with the provided encryption key, type, and ID. It then sends the return ID to the connected sub socket and returns the sub socket. If an exception occurs during the process, a byte array with value 0 is sent asynchronously and null is returned.

Exceptions
ExceptionThrown if an error occurs during the connection and setup process.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Disconnect()

async void xeno_rat_client.Node.Disconnect ( )
inline

Disconnects the current socket and clears the subNodes list, and invokes the OnDisconnect event if it is not null.

This method asynchronously disconnects the current socket using Task.Factory.FromAsync method, and then clears the subNodes list and disconnects each subNode recursively. If an exception occurs during the disconnection process, the socket is closed and disposed.

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

◆ memcmp()

static int xeno_rat_client.Node.memcmp ( byte[] b1,
byte[] b2,
long count )
private

Compares two byte arrays and returns an integer that indicates their relationship in terms of order.

Parameters
b1The first byte array to be compared.
b2The second byte array to be compared.
countThe number of bytes to compare.
Returns
An integer that indicates the relationship between the two byte arrays. Returns 0 if the contents of the arrays are equal, a value less than 0 if the first differing byte in b1 is less than the corresponding byte in b2, and a value greater than 0 if the first differing byte in b1 is greater than the corresponding byte in b2.
Here is the caller graph for this function:

◆ ReceiveAsync()

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

Asynchronously receives data from the socket and returns the received data as a byte array.

Returns
The received data as a byte array. Returns null if the received data is null, and disconnects the socket.
Exceptions
ExceptionThrown when there is an issue with receiving data from the socket.

This method asynchronously receives data from the socket using the ReceiveAsync method and returns the received data as a byte array. If the received data is null, the method disconnects the socket and returns null.

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

◆ ResetRecvTimeout()

void xeno_rat_client.Node.ResetRecvTimeout ( )
inline

Resets the receive timeout for the socket.

This method resets the receive timeout for the underlying socket to the default value.

Here is the call graph for this function:

◆ SendAsync()

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

Asynchronously sends the specified data over the socket connection.

Parameters
dataThe byte array containing the data to be sent.
Returns
A Task<TResult> representing the asynchronous operation. The task result is true if the data was sent successfully; otherwise, false.
Exceptions
SocketExceptionThrown when an error occurs during the socket operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetRecvTimeout()

void xeno_rat_client.Node.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. A receive timeout value of 0 indicates an infinite timeout.

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

Member Data Documentation

◆ ID

int xeno_rat_client.Node.ID = -1

◆ OnDisconnect

Action<Node> xeno_rat_client.Node.OnDisconnect
private

◆ Parent

Node xeno_rat_client.Node.Parent

◆ SetId

int xeno_rat_client.Node.SetId = -1

◆ sock

SocketHandler xeno_rat_client.Node.sock

◆ SockType

int xeno_rat_client.Node.SockType = -1

◆ subNodes

List<Node> xeno_rat_client.Node.subNodes = new List<Node>()

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