From 6ccc6adf816cc78b76be62fc5cf9a7eb5533102f Mon Sep 17 00:00:00 2001 From: Chenx221 Date: Wed, 1 Jan 2025 18:30:09 +0800 Subject: [PATCH] update --- minitool3/Program.cs | 19 +++++++++---------- minitool3/Properties/launchSettings.json | 2 +- minitool3/encrypted文件结构.txt | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/minitool3/Program.cs b/minitool3/Program.cs index d3bb367..b97cbba 100644 --- a/minitool3/Program.cs +++ b/minitool3/Program.cs @@ -28,30 +28,29 @@ namespace minitool3 { byte[] fileData = File.ReadAllBytes(filePath); - if (fileData.Length < 20) // 4 bytes (size) + 16 bytes (IV) + if (fileData.Length < 16) { - Console.WriteLine("The file does not contain enough data for size and IV."); + Console.WriteLine("The file does not contain enough data."); continue; } - // Read the encrypted data & iv size (4 bytes) + // Read the encrypted data & iv size (4 bytes)* int encryptedSize = BitConverter.ToInt32(fileData, 0); - - if (encryptedSize <= 0 || encryptedSize > fileData.Length - 4) + int sp = 4; + if (fileData.Length - 4 != encryptedSize) //*某些情况下头部不带长度 { - Console.WriteLine("Invalid encrypted data size."); - continue; + sp = 0; + encryptedSize = fileData.Length; } - encryptedSize -= 16; // Read the IV (16 bytes) byte[] iv = new byte[16]; - Array.Copy(fileData, 4, iv, 0, 16); + Array.Copy(fileData, sp, iv, 0, 16); // Read the ciphertext based on the size byte[] cipherText = new byte[encryptedSize]; - Array.Copy(fileData, 20, cipherText, 0, encryptedSize); + Array.Copy(fileData, 16 + sp, cipherText, 0, encryptedSize); byte[] decryptedData = Decrypt(cipherText, SHA256Byte, iv); diff --git a/minitool3/Properties/launchSettings.json b/minitool3/Properties/launchSettings.json index f5f5461..22ff9ea 100644 --- a/minitool3/Properties/launchSettings.json +++ b/minitool3/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "minitool3": { "commandName": "Project", - "commandLineArgs": "\"G:\\source\\minitool1\\minitool3\\bin\\Debug\\net8.0\\bg_avg_003.jp.encrypted\"" + "commandLineArgs": "\"G:\\source\\minitool1\\minitool3\\bin\\Release\\net8.0\\publish\\win-x64\\jp.co.dmm.dmmgames.imys_r\\files\\assetbundles\\characters\\tati\\020g2.encrypted\"" } } } \ No newline at end of file diff --git a/minitool3/encrypted文件结构.txt b/minitool3/encrypted文件结构.txt index 97d8006..014dbcc 100644 --- a/minitool3/encrypted文件结构.txt +++ b/minitool3/encrypted文件结构.txt @@ -1,6 +1,6 @@ *.encrypted文件结构 (D) -4B: enc data + iv size +4B: enc data + iv size (这4B可能没有) 16B: iv {data size}B: enc data(AES256 encryption)