|
async Task< Node > | CreateSubSubNode (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 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
-
sock | The socket to bind. |
LOCAL_PORT | The 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.
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
-
sender | The object that raised the event. |
e | The 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.FormatException | Thrown if the input port number is not in a valid format. |
System.Net.Sockets.SocketException | Thrown if the socket could not be bound to the specified port. |
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.
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
-
client | The client node for which the sub-sub node is to be created. |
- Returns
- The created sub-sub node if successful; otherwise, null.
- Exceptions
-
System.NullReferenceException | Thrown when the parent node of the client is null. |
System.InvalidOperationException | Thrown 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.
async Task xeno_rat_server.Forms.Reverse_Proxy.DisconnectSockAsync |
( |
Socket | sock | ) |
|
|
inlineprivate |
Asynchronously disconnects the specified socket.
- Parameters
-
sock | The 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
-
ObjectDisposedException | Thrown if the sock has already been disposed. |
SocketException | Thrown if an error occurs when attempting to disconnect the sock . |
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_sock | The 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
-
Exception | Thrown when there is an error in handling the connection and proxy. |
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_sock | The 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.
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.
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_sock | The client socket for receiving data. |
subnode | The subnode for sending data. |
bufferSize | The size of the buffer to be used for receiving and sending data. |
- Exceptions
-
SocketException | Thrown 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.
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
-
sender | The object that raised the event. |
e | A 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.
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_sock | The 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.