Skip to content

Instantly share code, notes, and snippets.

@Guest126
Forked from CRC32EX/mini4wdgp.cs
Last active May 14, 2020 00:42
Show Gist options
  • Save Guest126/31a2c5fdfc4124d7ae210d4328c826bd to your computer and use it in GitHub Desktop.
Save Guest126/31a2c5fdfc4124d7ae210d4328c826bd to your computer and use it in GitHub Desktop.
using System.IO;
using System.Security.Cryptography;
namespace Dimps.Thrust.Utility
{
class Cryptography
{
private static readonly int s_keysize = 128; // 0x80
private static readonly byte[] s_key = { 0xD5, 0x15, 0x31, 0x3B, 0xEC, 0xCA, 0xB0, 0xAD, 0x01, 0x9F, 0x24, 0xD9, 0xC4, 0xC6, 0x4F, 0x97 };
private static readonly byte[] s_iv = { 0x9F, 0xE6, 0x59, 0x43, 0x77, 0x9D, 0xD0, 0xA0, 0xDE, 0x06, 0xF2, 0xE3, 0x16, 0x00, 0x5D, 0xCA };
private static readonly byte s_mask = 0x45;
private static void applyMask(byte[] array, byte mask)
{
for (int i = 0; i < array.Length; i++, mask++)
{
array[i] = (byte)(array[i] ^ mask);
}
}
public static byte[] Decrypto(byte[] cipher) {
var aes = Aes.Create();
aes.KeySize = s_keysize;
aes.Padding = PaddingMode.PKCS7;
aes.Mode = CipherMode.CBC;
applyMask(s_key, s_mask);
applyMask(s_iv, s_mask);
var decryptor = aes.CreateDecryptor(s_key, s_iv);
return decryptor.TransformFinalBlock(cipher, 0, cipher.Length);
}
}
class TestClass
{
static void Main()
{
string[] files = System.Environment.GetCommandLineArgs();
for (int i = 1; i < files.Length; i++)
{
var bytes = File.ReadAllBytes(files[i]);
bytes = Dimps.Thrust.Utility.Cryptography.Decrypto(bytes);
File.WriteAllBytes(files[i] + ".json", bytes);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment