private void SaveButton_Click(object sender, EventArgs e) { //Checks file name validation then saves file into chosen folder ListView fileView = Class_FileManager.FolderFiles[folderView.SelectedNode]; // Validate file name, no empty name, no invalid characters if (fileNameTextBox.Text != null) { if (fileNameTextBox.Text.Length > 0) { foreach (ListViewItem file in fileView.Items) // check that there are no other similar named files within current level { if (file.Text == fileNameTextBox.Text) { MessageBox.Show("This destination already contains a file named '" + fileNameTextBox.Text + "'"); } } if (fileNameTextBox.Text.IndexOfAny(new char[] { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }) == -1) //does not contain invalid characters { Class_File.Save(folderView.SelectedNode, fileNameTextBox.Text, fileTypeComboBox.Text, Class_File.SaveAsIsMalicious, Class_File.SaveAsContent); Close(); } else //contains invalid characters { MessageBox.Show("A file name can't contain any of the following characters:\n \\ / : * ? \" < > |"); //mimicing windows invalid characters message } } else { MessageBox.Show("A file name can't be blank"); //cannot be blank name } } }
public static void RansomwareAttack() { //Event Trigger Desktop_BKEND.CloseOpenForms(); //close all open forms Class_File.Save(Class_FileManager.root, "not ransomware", "Totally Not Ransomware", true, null); //create a file in filemanager Form_TitleScreen.formDesktop.BackgroundRefresh(); //start the attack by changing desktop bg and disable icons }
private void saveLinkAsToolStripMenuItem_Click(object sender, System.EventArgs e) { string fileName = String.Join("", Link.Text.Split('\\', '/', ':', '*', '?', '"', '<', '>', '|')); //remove invalid characters if (fileName == "firewall.com") { Class_File.SaveAs(fileName, "HTML Document", false, null); //save into chosen folder, and allow user to edit filename /safe } else { Class_File.SaveAs(fileName, "HTML Document", true, null); //save into chosen folder, and allow user to edit filename /malicious } }
private void fileScanner_Click(object sender, EventArgs e) { if (selectedFile != null) { HomePanel.Visible = false; fileResultsPanel.Visible = true; selectedFileName.Text = selectedFile.Text; selectedFileType.Text = selectedFile.SubItems[1].Text; Class_File fileDetails = (Class_File)selectedFile.Tag; if (fileDetails.IsMalicious == true) { MaliciousPic.Visible = true; SafePic.Visible = false; isMaliciousLBL.Text = "File appears to be malicious according database results"; } else { MaliciousPic.Visible = false; SafePic.Visible = true; isMaliciousLBL.Text = "File appears to be safe according database results"; } } }