private static void ReEncryptAllTracks() { string circuitFolder = @"D:\Archive\Games\Pod\Installation\Data\Binary\Circuits\Backup"; string decFolder = @"D:\Pictures\Circuits"; string encFolder = @"D:\Archive\Games\Pod\Installation\Data\Binary\Circuits"; Directory.CreateDirectory(decFolder); Directory.CreateDirectory(encFolder); foreach (string filePath in Directory.GetFiles(circuitFolder, "*.bl4")) { string fileName = Path.GetFileName(filePath); string decFilePath = Path.ChangeExtension(Path.Combine(decFolder, fileName), "dec.bl4"); string encFilePath = Path.Combine(encFolder, fileName); Console.WriteLine($"Updating {fileName}..."); using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None)) using (FileStream decFile = new FileStream(decFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) using (FileStream encFile = new FileStream(encFilePath, FileMode.Create, FileAccess.Write, FileShare.None)) { uint key = Pbdf.RetrieveKey(file); file.Position = 0; int blockSize = Pbdf.RetrieveBlockSize(file, key); file.Position = 0; Pbdf.Decrypt(file, decFile, key, blockSize); decFile.Position = 0; Pbdf.Encrypt(decFile, encFile, key, blockSize); } } }
private static void DecryptTracks(string inFolder, string outFolder) { Directory.CreateDirectory(outFolder); foreach (string inFilePath in Directory.GetFiles(inFolder, "*.bl4")) { string fileName = Path.GetFileName(inFilePath); string outFilePath = Path.Combine(outFolder, fileName.Replace(".bl4", ".dec.bl4")); Console.WriteLine($"Decrypting {fileName}..."); using (FileStream inFile = new FileStream(inFilePath, FileMode.Open, FileAccess.Read, FileShare.None)) using (FileStream outFile = new FileStream(outFilePath, FileMode.Create, FileAccess.Write, FileShare.None)) { Pbdf.Decrypt(inFile, outFile, 0x00000F7E, 0x00004000); } } }
// ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- private static void Main(string[] args) { string inFolder = @"D:\Archive\Games\Pod\Installation\Data\Binary\Circuits\Backup"; string outFolder = @"D:\Archive\Games\Pod\Installation\Data\Binary\Circuits"; foreach (string inFilePath in Directory.GetFiles(inFolder, "*.bl4")) { if (!inFilePath.Contains("Cocoon")) { continue; } // Ignore partly broken files. if (inFilePath.Contains("Arcade++") || inFilePath.Contains("Forest")) { continue; } string fileName = Path.GetFileName(inFilePath); string outFilePath = Path.Combine(outFolder, fileName); Console.WriteLine($"Modifying {fileName}..."); Circuit circuit = new Circuit(inFilePath); //PlayWithTrack(circuit); circuit.Save(outFilePath); //RawPbdf raw = new RawPbdf(inFilePath); //raw.Save(outFilePath); // Save a decrypted copy for analyzation purposes. string decFilePath = $@"D:\Pictures\Circuits\decnew\{Path.GetFileNameWithoutExtension(inFilePath)}.new.dec.bl4"; using (FileStream stream = new FileStream(outFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) using (FileStream outStream = new FileStream(decFilePath, FileMode.Create, FileAccess.Write, FileShare.None)) { Pbdf.Decrypt(stream, outStream, 0x00000F7E, 0x00004000); } } }