Xeno-rat
Loading...
Searching...
No Matches
xeno_rat_server.Forms.Reverse_Proxy Class Reference
Inheritance diagram for xeno_rat_server.Forms.Reverse_Proxy:
Collaboration diagram for xeno_rat_server.Forms.Reverse_Proxy:

Public Member Functions

 Reverse_Proxy (Node _client)
 
void TempOnDisconnect (Node node)
 Handles the disconnection of a node.
 

Protected Member Functions

override void Dispose (bool disposing)
 Releases the unmanaged resources used by the component and optionally releases the managed resources.
 

Private Member Functions

async Task< NodeCreateSubSubNode (Node client)
 Creates a sub-sub node for the given client node and returns the created node.
 
async Task< byte[]> RecvAll (Socket sock, int size)
 Receives all the data from the socket of the specified size and returns it as a byte array.
 
async Task< bool > replyMethodSelection (Socket sock, byte method_code)
 Sends a reply method selection to the specified socket and returns a boolean indicating the success of the operation.
 
async Task< bool > replyRequestError (Socket sock, byte rep_err_code)
 Replies with an error to the request on the specified socket.
 
async Task< bool > StartNegotiations (Socket client_sock)
 Starts the negotiation process with the client socket for SOCKS5 protocol.
 
async Task DisconnectSockAsync (Socket sock)
 Asynchronously disconnects the specified socket.
 
async Task HandleConnectAndProxy (Socket client_sock)
 Handles the connection and proxy for the given client socket.
 
async Task RecvSendLoop (Socket client_sock, Node subnode, int bufferSize)
 Asynchronously receives and sends data between the client socket and the subnode using the specified buffer size.
 
async Task HandleProxyCreation (Socket client_sock)
 Handles the creation of a proxy for the given client socket by initiating negotiations, establishing connection and proxying data.
 
async Task AcceptLoop (Socket new_socket)
 Asynchronously accepts incoming connections and handles proxy creation.
 
void button1_Click (object sender, EventArgs e)
 Handles the button click event to create and bind a socket to the specified port, and start an accept loop on a new thread.
 
void button2_Click (object sender, EventArgs e)
 Clears the killnodes list, disconnects each node, closes the new_socket if not null, and enables button1 while disabling button2.
 
void Reverse_Proxy_FormClosing (object sender, FormClosingEventArgs e)
 Handles the form closing event and disconnects all nodes in the killnodes list, clears the killnodes list, and closes the new_socket if it is not null.
 
void textBox2_TextChanged (object sender, EventArgs e)
 Event handler for the TextChanged event of textBox2.
 
void Reverse_Proxy_Load (object sender, EventArgs e)
 Sets the DoubleBuffered property of the listView1 control to true, which reduces flickering during redrawing.
 
void InitializeComponent ()
 Initializes the components of the form including text boxes, labels, buttons, and list view.
 

Static Private Member Functions

static Socket CreateSocket ()
 Creates a new socket with the specified address family, socket type, and protocol type, and sets the receive timeout option.
 
static bool BindPort (Socket sock, int LOCAL_PORT)
 Binds the specified socket to the given local port and address.
 

Private Attributes

Node client
 
List< Nodekillnodes = new List<Node>()
 
Socket new_socket = null
 
System.ComponentModel.IContainer components = null
 Required designer variable.
 
System.Windows.Forms.TextBox textBox1
 
System.Windows.Forms.Label label1
 
System.Windows.Forms.Button button1
 
System.Windows.Forms.Button button2
 
System.Windows.Forms.ListView listView1
 
System.Windows.Forms.ColumnHeader columnHeader1
 

Static Private Attributes

const int TIMEOUT_SOCKET = 10
 
const string LOCAL_ADDR = "127.0.0.1"
 

Constructor & Destructor Documentation

◆ Reverse_Proxy()

xeno_rat_server.Forms.Reverse_Proxy.Reverse_Proxy ( Node _client)
inline
Here is the call graph for this function:

Member Function Documentation

◆ AcceptLoop()

async Task xeno_rat_server.Forms.Reverse_Proxy.AcceptLoop ( Socket new_socket)
inlineprivate

Asynchronously accepts incoming connections and handles proxy creation.

Parameters
new_socketThe socket used for accepting incoming connections.

This method continuously accepts incoming connections using the specified new_socket and handles the creation of a proxy for each connection. If an exception occurs during the acceptance of a connection, the method continues to accept new connections. Once the button2 is disabled, the method stops accepting new connections and awaits the asynchronous disconnection of the new_socket .

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

◆ BindPort()

static bool xeno_rat_server.Forms.Reverse_Proxy.BindPort ( Socket sock,
int LOCAL_PORT )
inlinestaticprivate

Binds the specified socket to the given local port and address.

Parameters
sockThe socket to bind.
LOCAL_PORTThe local port to bind to.
Returns
True if the binding is successful; otherwise, false.

This method attempts to bind the provided socket to the specified local port and address. It sets the socket option to reuse the address and then binds the socket to the provided local endpoint. If a SocketException occurs during the binding process, the method catches the exception, logs the error message, closes the socket, and returns false. If an exception occurs while attempting to listen on the socket, the method catches the exception, closes the socket, and returns false.

Here is the caller graph for this function:

◆ button1_Click()

void xeno_rat_server.Forms.Reverse_Proxy.button1_Click ( object sender,
EventArgs e )
inlineprivate

Handles the button click event to create and bind a socket to the specified port, and start an accept loop on a new thread.

Parameters
senderThe object that raised the event.
eThe event arguments.

This method attempts to parse the port number from the input text box. If the parsing fails, it displays an error message and returns. It then creates a new socket and attempts to bind it to the specified port. If the binding fails, it displays an error message and returns. If the binding is successful, it disables the current button and enables another button, and starts an accept loop on a new thread.

Exceptions
System.FormatExceptionThrown if the input port number is not in a valid format.
System.Net.Sockets.SocketExceptionThrown if the socket could not be bound to the specified port.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ button2_Click()

void xeno_rat_server.Forms.Reverse_Proxy.button2_Click ( object sender,
EventArgs e )
inlineprivate

Clears the killnodes list, disconnects each node, closes the new_socket if not null, and enables button1 while disabling button2.

This method iterates through the killnodes list and calls the Disconnect method on each node. It then clears the killnodes list. If the new_socket is not null, it is closed with a linger state of 0 and set to null. Finally, it enables button1 and disables button2.

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

◆ CreateSocket()

static Socket xeno_rat_server.Forms.Reverse_Proxy.CreateSocket ( )
inlinestaticprivate

Creates a new socket with the specified address family, socket type, and protocol type, and sets the receive timeout option.

Returns
A new Socket instance with the specified configuration.
Exceptions
SocketExceptionThrown when the creation of the socket fails.
Here is the caller graph for this function:

◆ CreateSubSubNode()

async Task< Node > xeno_rat_server.Forms.Reverse_Proxy.CreateSubSubNode ( Node client)
inlineprivate

Creates a sub-sub node for the given client node and returns the created node.

Parameters
clientThe client node for which the sub-sub node is to be created.
Returns
The created sub-sub node if successful; otherwise, null.
Exceptions
System.NullReferenceExceptionThrown when the parent node of the client is null.
System.InvalidOperationExceptionThrown when the type 2 ID cannot be set for the sub-sub node.

This method creates a sub-sub node for the given client node by calling the CreateSubNodeAsync method on the parent node of the client. It then sets the type 2 ID for the sub-sub node using the Utils.SetType2setIdAsync method and sends the type 2 return using the Utils.Type2returnAsync method. If successful, it sends the ID to the client and waits for a response. If the response indicates success, the sub-sub node is returned; otherwise, it is disconnected and null is returned.

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

◆ DisconnectSockAsync()

async Task xeno_rat_server.Forms.Reverse_Proxy.DisconnectSockAsync ( Socket sock)
inlineprivate

Asynchronously disconnects the specified socket.

Parameters
sockThe socket to be disconnected.

This method asynchronously disconnects the specified sock . It first checks if the sock is not null, then waits for 10 milliseconds using Task.Delay(int) before initiating the disconnect operation using Task.Factory.FromAsync(System.AsyncCallback, System.AsyncCallback, System.Net.Sockets.Socket, object). If an exception occurs during the disconnect operation, the method attempts to close the sock using Socket.Close(int).

Exceptions
ObjectDisposedExceptionThrown if the sock has already been disposed.
SocketExceptionThrown if an error occurs when attempting to disconnect the sock .
Here is the caller graph for this function:

◆ Dispose()

override void xeno_rat_server.Forms.Reverse_Proxy.Dispose ( bool disposing)
inlineprotected

Releases the unmanaged resources used by the component and optionally releases the managed resources.

Parameters
disposingTrue to release both managed and unmanaged resources; false to release only unmanaged resources.

This method releases the unmanaged resources used by the component and optionally releases the managed resources. If disposing is true, this method releases all resources held by any managed objects that this T:System.ComponentModel.Component references. This method is called by the public M:System.ComponentModel.Component.Dispose method and the M:System.ComponentModel.Component.Finalize method.

◆ HandleConnectAndProxy()

async Task xeno_rat_server.Forms.Reverse_Proxy.HandleConnectAndProxy ( Socket client_sock)
inlineprivate

Handles the connection and proxy for the given client socket.

Parameters
client_sockThe client socket to handle the connection and proxy for.

This method handles the SOCKS5 protocol for proxying connections. It first receives the version header from the client socket and checks if it is SOCKS5. If not, it replies with a method selection message and disconnects the socket. If it is SOCKS5, it proceeds to receive the command, reserved byte, and address type bytes. It then validates the command and address type, and based on the address type, receives the destination address and port. It then creates a subnode for proxying the connection, sends the destination address and port to the subnode, and receives a response message. Based on the response message, it either replies with an error or sends the connected payload to the client socket. If the payload is sent properly, it adds the destination address and port to a list view, initiates a receive-send loop, and finally disconnects the client socket and subnode.

Exceptions
ExceptionThrown when there is an error in handling the connection and proxy.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleProxyCreation()

async Task xeno_rat_server.Forms.Reverse_Proxy.HandleProxyCreation ( Socket client_sock)
inlineprivate

Handles the creation of a proxy for the given client socket by initiating negotiations, establishing connection and proxying data.

Parameters
client_sockThe client socket to handle proxy creation for.
Returns
An asynchronous task representing the handling of proxy creation for the client socket.

This method asynchronously starts negotiations with the client socket. If negotiations are successful, it proceeds to handle the connection and proxy data for the client socket. If negotiations fail, it disconnects the client socket asynchronously.

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

◆ InitializeComponent()

void xeno_rat_server.Forms.Reverse_Proxy.InitializeComponent ( )
inlineprivate

Initializes the components of the form including text boxes, labels, buttons, and list view.

This method sets up the visual components of the form including text boxes, labels, buttons, and list view. It also sets up event handlers for button clicks and form closing.

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

◆ RecvAll()

async Task< byte[]> xeno_rat_server.Forms.Reverse_Proxy.RecvAll ( Socket sock,
int size )
inlineprivate

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

Parameters
sockThe socket from which to receive the data.
sizeThe size of the data to be received.
Returns
The received data as a byte array.
Exceptions
ArgumentNullExceptionThrown when the sock is null.
ObjectDisposedExceptionThrown when the sock has been closed.
Here is the caller graph for this function:

◆ RecvSendLoop()

async Task xeno_rat_server.Forms.Reverse_Proxy.RecvSendLoop ( Socket client_sock,
Node subnode,
int bufferSize )
inlineprivate

Asynchronously receives and sends data between the client socket and the subnode using the specified buffer size.

Parameters
client_sockThe client socket for receiving data.
subnodeThe subnode for sending data.
bufferSizeThe size of the buffer to be used for receiving and sending data.
Exceptions
SocketExceptionThrown when an error occurs with the sockets.
Returns
An asynchronous task representing the receive and send operation.

This method continuously checks for available data on the client socket and the subnode socket using the Poll method with a timeout of 1000 milliseconds. If data is available on the client socket, it is received into a buffer and then sent to the subnode. If data is available on the subnode, it is received and then sent to the client socket. The method also includes a delay of 100 milliseconds between iterations.

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

◆ replyMethodSelection()

async Task< bool > xeno_rat_server.Forms.Reverse_Proxy.replyMethodSelection ( Socket sock,
byte method_code )
inlineprivate

Sends a reply method selection to the specified socket and returns a boolean indicating the success of the operation.

Parameters
sockThe socket to which the reply method selection will be sent.
method_codeThe method code to be included in the reply.
Returns
True if the reply method selection was successfully sent; otherwise, false.

This method constructs a reply message containing the specified method code and sends it to the provided socket. If the socket is not connected, the method returns false. The method uses asynchronous I/O to send the reply message and awaits the completion of the operation.

Here is the caller graph for this function:

◆ replyRequestError()

async Task< bool > xeno_rat_server.Forms.Reverse_Proxy.replyRequestError ( Socket sock,
byte rep_err_code )
inlineprivate

Replies with an error to the request on the specified socket.

Parameters
sockThe socket to reply to.
rep_err_codeThe error code to be included in the reply.
Returns
A Task<TResult> representing the asynchronous operation. The task result is true if the reply was sent successfully; otherwise, false.

This method constructs a reply with the specified error code and sends it over the provided socket. If the socket is not connected, the method returns false.

Here is the caller graph for this function:

◆ Reverse_Proxy_FormClosing()

void xeno_rat_server.Forms.Reverse_Proxy.Reverse_Proxy_FormClosing ( object sender,
FormClosingEventArgs e )
inlineprivate

Handles the form closing event and disconnects all nodes in the killnodes list, clears the killnodes list, and closes the new_socket if it is not null.

Parameters
senderThe object that raised the event.
eA FormClosingEventArgs that contains the event data.

This method iterates through the killnodes list and disconnects each node if it is not null. Then it clears the killnodes list. If the new_socket is not null, it is closed and set to null.

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

◆ Reverse_Proxy_Load()

void xeno_rat_server.Forms.Reverse_Proxy.Reverse_Proxy_Load ( object sender,
EventArgs e )
inlineprivate

Sets the DoubleBuffered property of the listView1 control to true, which reduces flickering during redrawing.

Parameters
senderThe object that raised the event.
eThe EventArgs containing the event data.
Here is the caller graph for this function:

◆ StartNegotiations()

async Task< bool > xeno_rat_server.Forms.Reverse_Proxy.StartNegotiations ( Socket client_sock)
inlineprivate

Starts the negotiation process with the client socket for SOCKS5 protocol.

Parameters
client_sockThe client socket to start negotiations with.
Returns
True if negotiation is successful, otherwise false.

This method initiates the negotiation process with the client socket for the SOCKS5 protocol. It first checks the version header received from the client and if it is not 5, it replies with a method selection indicating no acceptable methods and returns false. If the version header is 5, it proceeds to receive the number of methods to use, ranging from 0 to 256. If the number of methods is not received, it returns false. It then iterates through the requested methods and adds them to a list. If the list does not contain the method for no authentication required, it replies with a method selection indicating no acceptable methods and returns false. If the method for no authentication required is present, it replies with a method selection indicating no authentication required and returns true.

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

◆ TempOnDisconnect()

void xeno_rat_server.Forms.Reverse_Proxy.TempOnDisconnect ( Node node)
inline

Handles the disconnection of a node.

Parameters
nodeThe node that has been disconnected.

If the disconnected node is the client, it closes the new socket if it exists and disposes it. If the current object is not disposed, it invokes the close method using the UI thread.

Here is the caller graph for this function:

◆ textBox2_TextChanged()

void xeno_rat_server.Forms.Reverse_Proxy.textBox2_TextChanged ( object sender,
EventArgs e )
inlineprivate

Event handler for the TextChanged event of textBox2.

Parameters
senderThe object that raised the event.
eThe event data.

This method is called when the text in textBox2 changes. It can be used to perform actions based on the changed text.

Member Data Documentation

◆ button1

System.Windows.Forms.Button xeno_rat_server.Forms.Reverse_Proxy.button1
private

◆ button2

System.Windows.Forms.Button xeno_rat_server.Forms.Reverse_Proxy.button2
private

◆ client

Node xeno_rat_server.Forms.Reverse_Proxy.client
private

◆ columnHeader1

System.Windows.Forms.ColumnHeader xeno_rat_server.Forms.Reverse_Proxy.columnHeader1
private

◆ components

System.ComponentModel.IContainer xeno_rat_server.Forms.Reverse_Proxy.components = null
private

Required designer variable.

◆ killnodes

List<Node> xeno_rat_server.Forms.Reverse_Proxy.killnodes = new List<Node>()
private

◆ label1

System.Windows.Forms.Label xeno_rat_server.Forms.Reverse_Proxy.label1
private

◆ listView1

System.Windows.Forms.ListView xeno_rat_server.Forms.Reverse_Proxy.listView1
private

◆ LOCAL_ADDR

const string xeno_rat_server.Forms.Reverse_Proxy.LOCAL_ADDR = "127.0.0.1"
staticprivate

◆ new_socket

Socket xeno_rat_server.Forms.Reverse_Proxy.new_socket = null
private

◆ textBox1

System.Windows.Forms.TextBox xeno_rat_server.Forms.Reverse_Proxy.textBox1
private

◆ TIMEOUT_SOCKET

const int xeno_rat_server.Forms.Reverse_Proxy.TIMEOUT_SOCKET = 10
staticprivate

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