-
-
Save Guest126/31a2c5fdfc4124d7ae210d4328c826bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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