update minitool3
This commit is contained in:
parent
deaeab63b6
commit
53c9a03e36
@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "minitool1", "minitool1\mini
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "minitool2", "minitool2\minitool2.csproj", "{0FE5458A-A3A9-4D0B-A540-BF4A7CD3F7EA}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "minitool2", "minitool2\minitool2.csproj", "{0FE5458A-A3A9-4D0B-A540-BF4A7CD3F7EA}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "minitool3", "minitool3\minitool3.csproj", "{F6B38C11-304C-4FF8-BB74-D4CA0E515189}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -21,6 +23,10 @@ Global
|
|||||||
{0FE5458A-A3A9-4D0B-A540-BF4A7CD3F7EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0FE5458A-A3A9-4D0B-A540-BF4A7CD3F7EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{0FE5458A-A3A9-4D0B-A540-BF4A7CD3F7EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0FE5458A-A3A9-4D0B-A540-BF4A7CD3F7EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{0FE5458A-A3A9-4D0B-A540-BF4A7CD3F7EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0FE5458A-A3A9-4D0B-A540-BF4A7CD3F7EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F6B38C11-304C-4FF8-BB74-D4CA0E515189}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F6B38C11-304C-4FF8-BB74-D4CA0E515189}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F6B38C11-304C-4FF8-BB74-D4CA0E515189}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F6B38C11-304C-4FF8-BB74-D4CA0E515189}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
103
minitool3/Program.cs
Normal file
103
minitool3/Program.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace minitool3
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
private const string DefaultSecretKey = "dB3aqcLtAmBd";
|
||||||
|
private const string DefaultKeyBase = "RWd3NusabzRc";
|
||||||
|
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
if (args.Length == 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Please drag and drop one or more files onto this program.");
|
||||||
|
Console.ReadKey();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Byte[] SHA256Byte = GenerateSHA256Byte(DefaultKeyBase, Encoding.UTF8.GetBytes(DefaultSecretKey));
|
||||||
|
|
||||||
|
foreach (var filePath in args)
|
||||||
|
{
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Processing file: {filePath}");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] fileData = File.ReadAllBytes(filePath);
|
||||||
|
|
||||||
|
if (fileData.Length < 20) // 4 bytes (size) + 16 bytes (IV)
|
||||||
|
{
|
||||||
|
Console.WriteLine("The file does not contain enough data for size and IV.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the encrypted data & iv size (4 bytes)
|
||||||
|
int encryptedSize = BitConverter.ToInt32(fileData, 0);
|
||||||
|
|
||||||
|
if (encryptedSize <= 0 || encryptedSize > fileData.Length - 4)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Invalid encrypted data size.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
encryptedSize -= 16;
|
||||||
|
|
||||||
|
// Read the IV (16 bytes)
|
||||||
|
byte[] iv = new byte[16];
|
||||||
|
Array.Copy(fileData, 4, iv, 0, 16);
|
||||||
|
|
||||||
|
// Read the ciphertext based on the size
|
||||||
|
byte[] cipherText = new byte[encryptedSize];
|
||||||
|
Array.Copy(fileData, 20, cipherText, 0, encryptedSize);
|
||||||
|
|
||||||
|
byte[] decryptedData = Decrypt(cipherText, SHA256Byte, iv);
|
||||||
|
|
||||||
|
string outputDir = Path.Combine(Path.GetDirectoryName(filePath)!, "dec");
|
||||||
|
Directory.CreateDirectory(outputDir); // Ensure the directory exists
|
||||||
|
string outputFilePath = Path.Combine(outputDir, Path.GetFileNameWithoutExtension(filePath) + ".assets");
|
||||||
|
File.WriteAllBytes(outputFilePath, decryptedData);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"An error occurred: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"File not found: {filePath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Processing complete. Press any key to exit.");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] GenerateSHA256Byte(string data, byte[] key)
|
||||||
|
{
|
||||||
|
using var hmac = new HMACSHA256(key);
|
||||||
|
return hmac.ComputeHash(Encoding.UTF8.GetBytes(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] Decrypt(byte[] cipherText, byte[] sha256Key, byte[] iv)
|
||||||
|
{
|
||||||
|
using var aes = Aes.Create();
|
||||||
|
aes.Key = sha256Key;
|
||||||
|
aes.IV = iv;
|
||||||
|
aes.Mode = CipherMode.CBC;
|
||||||
|
aes.Padding = PaddingMode.PKCS7;
|
||||||
|
|
||||||
|
using var decryptor = aes.CreateDecryptor();
|
||||||
|
using var memoryStream = new MemoryStream(cipherText);
|
||||||
|
using var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
|
||||||
|
|
||||||
|
byte[] decryptedData = new byte[cipherText.Length];
|
||||||
|
int bytesRead = cryptoStream.Read(decryptedData, 0, decryptedData.Length);
|
||||||
|
|
||||||
|
return [.. decryptedData];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
minitool3/Properties/launchSettings.json
Normal file
8
minitool3/Properties/launchSettings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"minitool3": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"commandLineArgs": "\"G:\\source\\minitool1\\minitool3\\bin\\Debug\\net8.0\\bg_avg_003.jp.encrypted\""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
minitool3/encrypted文件结构.txt
Normal file
13
minitool3/encrypted文件结构.txt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
*.encrypted文件结构
|
||||||
|
(D)
|
||||||
|
4B: enc data + iv size
|
||||||
|
16B: iv
|
||||||
|
{data size}B: enc data(AES256 encryption)
|
||||||
|
|
||||||
|
|
||||||
|
SecretKey = "dB3aqcLtAmBd"
|
||||||
|
KeyBase = "RWd3NusabzRc"
|
||||||
|
|
||||||
|
hmac = new HMACSHA256(Encoding.UTF8.GetBytes(SecretKey))
|
||||||
|
AESKey = hmac.ComputeHash(Encoding.UTF8.GetBytes(KeyBase))
|
||||||
|
iv = 看顶上
|
10
minitool3/minitool3.csproj
Normal file
10
minitool3/minitool3.csproj
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user