Xeno-rat
|
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< 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 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< Node > | killnodes = 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" |
|
inline |
|
inlineprivate |
Asynchronously accepts incoming connections and handles proxy creation.
new_socket | The 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 .
|
inlinestaticprivate |
Binds the specified socket to the given local port and address.
sock | The socket to bind. |
LOCAL_PORT | The local port to bind to. |
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.
|
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.
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.
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. |
|
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.
|
inlinestaticprivate |
Creates a new socket with the specified address family, socket type, and protocol type, and sets the receive timeout option.
SocketException | Thrown when the creation of the socket fails. |
|
inlineprivate |
Creates a sub-sub node for the given client node and returns the created node.
client | The client node for which the sub-sub node is to be created. |
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.
|
inlineprivate |
Asynchronously disconnects the specified socket.
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).
ObjectDisposedException | Thrown if the sock has already been disposed. |
SocketException | Thrown if an error occurs when attempting to disconnect the sock . |
|
inlineprotected |
Releases the unmanaged resources used by the component and optionally releases the managed resources.
disposing | True 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.
|
inlineprivate |
Handles the connection and proxy for the given client socket.
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.
Exception | Thrown when there is an error in handling the connection and proxy. |
|
inlineprivate |
Handles the creation of a proxy for the given client socket by initiating negotiations, establishing connection and proxying data.
client_sock | The client socket to handle proxy creation for. |
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.
|
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.
|
inlineprivate |
Receives all the data from the socket of the specified size and returns it as a byte array.
sock | The socket from which to receive the data. |
size | The size of the data to be received. |
ArgumentNullException | Thrown when the sock is null. |
ObjectDisposedException | Thrown when the sock has been closed. |
|
inlineprivate |
Asynchronously receives and sends data between the client socket and the subnode using the specified buffer size.
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. |
SocketException | Thrown when an error occurs with the sockets. |
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.
|
inlineprivate |
Sends a reply method selection to the specified socket and returns a boolean indicating the success of the operation.
sock | The socket to which the reply method selection will be sent. |
method_code | The method code to be included in the reply. |
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.
|
inlineprivate |
Replies with an error to the request on the specified socket.
sock | The socket to reply to. |
rep_err_code | The error code to be included in the reply. |
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
.
|
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.
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.
|
inlineprivate |
Sets the DoubleBuffered property of the listView1 control to true, which reduces flickering during redrawing.
sender | The object that raised the event. |
e | The EventArgs containing the event data. |
|
inlineprivate |
Starts the negotiation process with the client socket for SOCKS5 protocol.
client_sock | The client socket to start negotiations with. |
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.
|
inline |
Handles the disconnection of a node.
node | The 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.
|
inlineprivate |
Event handler for the TextChanged event of textBox2.
sender | The object that raised the event. |
e | The event data. |
This method is called when the text in textBox2 changes. It can be used to perform actions based on the changed text.
|
private |
|
private |
|
private |
|
private |
|
private |
Required designer variable.
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
staticprivate |