Xeno-rat
|
Public Member Functions | |
File_manager (Node _client) | |
async Task | InitializeAsync () |
Initializes the object asynchronously by creating a FileViewer, sending type, and updating the list view. | |
void | TempOnDisconnect (Node node) |
Handles the disconnection of a node. | |
async Task | FileUpload (string filepath, string savepath) |
Uploads a file from the specified filepath to the given savepath using the asynchronous protocol. | |
async Task | FileDownload (string path, string savepath) |
Downloads a file from the specified path and saves it to the provided save path. | |
async Task | StartFile (string path) |
Starts a file operation using the specified path. | |
async Task | DeleteFile (string path) |
Deletes a file at the specified path. | |
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 | UpdateListViewNonInvoke (string path) |
Updates the list view without invoking the UI thread, using the provided file path. | |
async Task< Node > | CreateSubSubNode (Node client) |
Creates a sub-sub node for the given client node and returns the created node. | |
void | listView1_SelectedIndexChanged (object sender, EventArgs e) |
Occurs when the selected index of the ListView control changes. | |
async void | listView1_MouseDoubleClick (object sender, MouseEventArgs e) |
Handles the event when the user double-clicks on an item in the list view. | |
async void | textBox1_KeyDown (object sender, KeyEventArgs e) |
Handles the KeyDown event for textBox1 and updates the ListView if the Enter key is pressed. | |
void | listView2_SelectedIndexChanged (object sender, EventArgs e) |
Occurs when the selected index of the ListView2 control changes. | |
void | DownloadMenuItem_Click (object sender, EventArgs e) |
Handles the click event of the download menu item by initiating the file download process. | |
async void | OpenMenuItem_Click (object sender, EventArgs e) |
Opens the file associated with the selected menu item. | |
async void | DeleteMenuItem_Click (object sender, EventArgs e) |
Deletes the file associated with the selected menu item and updates the list view. | |
void | listView1_MouseClick (object sender, MouseEventArgs e) |
Handles the mouse click event on the listView1 control, and displays a context menu with options based on the selected item. | |
async void | button1_Click (object sender, EventArgs e) |
Asynchronously updates the list view with the contents of the specified directory without requiring an invoke. | |
void | button2_Click (object sender, EventArgs e) |
Handles the click event of button2. Launches a new thread to open a file dialog, select a file, and upload it to a specified location. | |
void | InitializeComponent () |
Initializes the components of the form, including tab controls, buttons, text boxes, labels, and list views. | |
Private Attributes | |
Node | client |
FileView | FileViewer |
string | currentDirectory = "" |
System.ComponentModel.IContainer | components = null |
Required designer variable. | |
System.Windows.Forms.TabControl | tabControl1 |
System.Windows.Forms.TabPage | tabPage1 |
System.Windows.Forms.ListView | listView1 |
System.Windows.Forms.TabPage | tabPage2 |
System.Windows.Forms.ColumnHeader | columnHeader1 |
System.Windows.Forms.ColumnHeader | columnHeader2 |
System.Windows.Forms.TextBox | textBox1 |
System.Windows.Forms.Label | label1 |
System.Windows.Forms.ListView | listView2 |
System.Windows.Forms.ColumnHeader | columnHeader3 |
System.Windows.Forms.ColumnHeader | columnHeader4 |
System.Windows.Forms.ColumnHeader | columnHeader5 |
System.Windows.Forms.ColumnHeader | columnHeader6 |
System.Windows.Forms.Button | button2 |
System.Windows.Forms.Button | button1 |
|
inline |
|
inlineprivate |
Asynchronously updates the list view with the contents of the specified directory without requiring an invoke.
currentDirectory | The directory whose contents will be displayed in the list view. |
This method updates the list view with the contents of the specified directory without requiring an invoke, allowing for asynchronous execution.
|
inlineprivate |
Handles the click event of button2. Launches a new thread to open a file dialog, select a file, and upload it to a specified location.
sender | The object that raised the event. |
e | The event data. |
System.InvalidOperationException | Thrown when the thread is in an invalid state for the requested operation. |
This method creates a new thread to handle the file selection and upload process. It sets the thread's apartment state to STA (Single-Threaded Apartment) to ensure proper interaction with the UI components. The method uses an OpenFileDialog to allow the user to select a file. Once a file is selected, it retrieves the file path, extracts the file name, and combines it with the current directory to create a save path. The method then calls the FileUpload method to upload the selected file to the specified location.
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. |
Exception | Thrown when an error occurs during the creation of the sub-sub node. |
|
inline |
Deletes a file at the specified path.
path | The path of the file to be deleted. |
Exception | Thrown when the file deletion process fails. |
This method sends a delete request to the server for the file located at the specified path . If the deletion process fails, an exception is thrown.
|
inlineprivate |
Deletes the file associated with the selected menu item and updates the list view.
sender | The object that raised the event. |
e | The event data. |
InvalidCastException | Thrown when the sender or tag is not of the expected type. |
This method deletes the file specified by the filePath and then updates the list view to reflect the changes. The file path is obtained from the tag of the selected item in the list view. The method uses asynchronous operations to delete the file and update the list view without blocking the UI thread.
|
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 disposes of the managed resources.
|
inlineprivate |
Handles the click event of the download menu item by initiating the file download process.
sender | The object that raised the event. |
e | The event arguments. |
This method retrieves the necessary information from the selected item in the ListView, creates and configures a SaveFileDialog in a new STA thread, and initiates the file download process by calling the FileDownload method with the selected file's path and the chosen save path.
|
inline |
Downloads a file from the specified path and saves it to the provided save path.
path | The path of the file to be downloaded. |
savepath | The path where the downloaded file will be saved. |
Exception | Thrown when the download start fails or if there is an error accessing the file or if the file does not exist or if there is an error with file read or writing to the save file path. |
This method initiates a download of the file from the specified path and saves it to the savepath . It updates the progress of the download in a list view, showing the percentage of completion. If the download fails, it displays an appropriate message in the list view.
|
inline |
Uploads a file from the specified filepath to the given savepath using the asynchronous protocol.
filepath | The path of the file to be uploaded. |
savepath | The path where the file will be saved on the server. |
Exception | Thrown when the upload start fails or when there is an error reading the file. |
This method initiates the upload process by creating a sub-sub node and sending the file data in blocks to the server using asynchronous communication. It updates the progress of the upload in a list view and handles various error scenarios such as failed connections and file write errors.
|
inline |
Initializes the object asynchronously by creating a FileViewer, sending type, and updating the list view.
This method initializes the FileViewer by creating a new instance using the result of the asynchronous operation from CreateSubSubNode method. It then sends the type using the FileViewer.SendType method and updates the list view using the UpdateListViewNonInvoke method with the current directory.
|
inlineprivate |
Initializes the components of the form, including tab controls, buttons, text boxes, labels, and list views.
|
inlineprivate |
Handles the mouse click event on the listView1 control, and displays a context menu with options based on the selected item.
sender | The object that raised the event. |
e | A MouseEventArgs that contains the event data. |
This method checks if the right mouse button is clicked, and if so, it retrieves the selected item from the listView1 control. If the selected item is not null and its second subitem's text is "File", a context menu is created with options for Download, Open, and Delete. Each option is associated with a specific action and is added to the context menu. The context menu is then displayed at the position of the mouse click within the listView1 control.
|
inlineprivate |
Handles the event when the user double-clicks on an item in the list view.
sender | The source of the event. |
e | A MouseEventArgs that contains the event data. |
This method retrieves the path, directory, and type of the selected item in the list view. If the type is not a directory, the method returns. If the directory is "..", it constructs a new path based on the parent directory and updates the list view asynchronously. Otherwise, it constructs a new path based on the current directory and the selected directory, and updates the list view asynchronously.
|
inlineprivate |
Occurs when the selected index of the ListView control changes.
sender | The source of the event. |
e | An EventArgs that contains the event data. |
|
inlineprivate |
Occurs when the selected index of the ListView2 control changes.
sender | The source of the event. |
e | An EventArgs that contains the event data. |
|
inlineprivate |
Opens the file associated with the selected menu item.
sender | The object that raised the event. |
e | The event arguments. |
This method retrieves the file path associated with the selected menu item and asynchronously starts the file.
|
inline |
Starts a file operation using the specified path.
path | The path of the file to be operated on. |
Exception | Thrown when the file operation fails. |
This method initiates a file operation using the provided path . It creates a sub-sub-node using the client and sends a byte array with a type value of 3 to the node. It then sends the UTF-8 encoded bytes of the path to the node and receives a response. If the received data is null, it displays a message box indicating that the file operation start has failed and disconnects the node. If the received data's first byte is 0, it displays a message box indicating that the file could not be opened or does not exist and disconnects the node.
|
inline |
Handles the disconnection of a node.
node | The node to be handled. |
If the provided node is the client, it disconnects the FileViewer client if it exists. If the current instance is not disposed, it closes the form using the System.Windows.Forms.Control.Invoke(Delegate) method.
|
inlineprivate |
Handles the KeyDown event for textBox1 and updates the ListView if the Enter key is pressed.
sender | The object that raised the event. |
e | A KeyEventArgs that contains the event data. |
This method asynchronously updates the ListView with the text from textBox1 if the Enter key is pressed. It sets the KeyEventArgs.Handled and KeyEventArgs.SuppressKeyPress properties to true after updating the ListView.
|
inlineprivate |
Updates the list view without invoking the UI thread, using the provided file path.
path | The path of the directory to be updated in the list view. |
This method asynchronously retrieves file information using the FileViewer.GetInfo method and updates the list view with the directories and files found at the specified path. If the file information retrieval is unsuccessful, a message box is displayed indicating the problem, and the method returns without further processing. The current directory is updated to the specified path, and the text box displaying the current directory is also updated. The list view is then updated by clearing its items, adding a parent directory item if the path is not empty, and adding items for each directory and file found in the retrieved file data. Finally, the list view update is completed by ending the update operation.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Required designer variable.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |