static GCHandle Decrypt(uint[] encrypted, uint seed) { const int blockSize = 0x10; const int blockMask = blockSize - 1; const byte byteMask = 0xff; // load key and iv var iv = new uint[blockSize]; var key = new uint[blockSize]; ulong s = seed; for (int i = 0; i < blockSize; i++) { // mutate seed s = (s * s) % 0x143fc089; // set in key and buffer key[i] = (uint)s; iv[i] = (uint)((s * s) % 0x444d56fb); } Mutation.Crypt(iv, key); Array.Clear(key, 0, blockSize); //decrypt the buffer var compressedBuffer = new byte[encrypted.Length << 2]; uint offset = 0; for (int i = 0; i < encrypted.Length; i++) { // decrypt 4 bytes and update iv uint data = encrypted[i] ^ iv[i & blockMask]; iv[i & blockMask] = (iv[i & blockMask] ^ data) + 0x3ddb2819; //add bytes to the compressed buffer compressedBuffer[offset + 0] = (byte)(data >> (8 * 0)); compressedBuffer[offset + 1] = (byte)(data >> (8 * 1)); compressedBuffer[offset + 2] = (byte)(data >> (8 * 2)); compressedBuffer[offset + 3] = (byte)(data >> (8 * 3)); offset += 4; } // decompress and clear unused buffers Array.Clear(iv, 0, blockSize); byte[] decompressed = Lzma.Decompress(compressedBuffer); Array.Clear(compressedBuffer, 0, compressedBuffer.Length); // create a gc handle and do final decrypt GCHandle g = GCHandle.Alloc(decompressed, GCHandleType.Pinned); for (int i = 0; i < decompressed.Length; i++) { decompressed[i] ^= (byte)s; if ((i & byteMask) == 0) //every 256 bytes { s = (s * s) % 0x8a5cb7; } } return(g); }
static void Initialize() // very similar to constants encryption initialization { const int blockSize = 0x10; // initialize encrypted buffer uint length = (uint)Mutation.KeyI0; // encrypted buffer length uint[] encryptedBuffer = Mutation.Placeholder(new uint[Mutation.KeyI0]); // initialize key uint[] key = new uint[blockSize]; uint n = (uint)Mutation.KeyI1; // seed for (int i = 0; i < blockSize; i++) { n ^= n >> 13; n ^= n << 25; n ^= n >> 27; key[i] = n; } // decrypt the buffer int index = 0; uint[] tempBuffer = new uint[blockSize]; byte[] compressedBuffer = new byte[length * 4]; for (int offset = 0; offset < length; offset += blockSize) { // copy block to temp buffer for (int i = 0; i < blockSize; i++) { tempBuffer[i] = encryptedBuffer[offset + i]; } // decrypt buffer with key Mutation.Crypt(tempBuffer, key); // copy uint to compressed buffer, and update key for (int i = 0; i < blockSize; i++) { uint e = tempBuffer[i]; compressedBuffer[index++] = (byte)(e >> (8 * 0)); compressedBuffer[index++] = (byte)(e >> (8 * 1)); compressedBuffer[index++] = (byte)(e >> (8 * 2)); compressedBuffer[index++] = (byte)(e >> (8 * 3)); key[i] ^= e; } } //decompress the assembly assembly = Assembly.Load(Lzma.Decompress(compressedBuffer)); AppDomain.CurrentDomain.AssemblyResolve += Handler; }
static void Initialize() { const int blockSize = 0x10; // initialize encrypted buffer uint length = (uint)Mutation.KeyI0; // encrypted buffer length uint[] encryptedBuffer = Mutation.Placeholder(new uint[Mutation.KeyI0]); // initialize key uint[] key = new uint[blockSize]; uint n = (uint)Mutation.KeyI1; // seed for (int i = 0; i < blockSize; i++) { n ^= n >> 12; n ^= n << 25; n ^= n >> 27; key[i] = n; } // decrypt the buffer int index = 0; uint[] tempBuffer = new uint[blockSize]; byte[] compressedBuffer = new byte[length * 4]; for (int offset = 0; offset < length; offset += blockSize) { // copy block to temp buffer for (int i = 0; i < blockSize; i++) { tempBuffer[i] = encryptedBuffer[offset + i]; } // decrypt buffer with key Mutation.Crypt(tempBuffer, key); // copy uint to compressed buffer, and update key for (int i = 0; i < blockSize; i++) { uint e = tempBuffer[i]; compressedBuffer[index++] = (byte)(e >> (8 * 0)); compressedBuffer[index++] = (byte)(e >> (8 * 1)); compressedBuffer[index++] = (byte)(e >> (8 * 2)); compressedBuffer[index++] = (byte)(e >> (8 * 3)); key[i] ^= e; } } // decompress the buffer buffer = Lzma.Decompress(compressedBuffer); }
private static GCHandle Decrypt(uint[] data, uint seed) { var w = new uint[0x10]; var k = new uint[0x10]; ulong s = seed; for (var i = 0; i < 0x10; i++) { s = s * s % 0x143fc089; k[i] = (uint)s; w[i] = (uint)(s * s % 0x444d56fb); } Mutation.Crypt(w, k); Array.Clear(k, 0, 0x10); var b = new byte[data.Length << 2]; uint h = 0; for (var i = 0; i < data.Length; i++) { var d = data[i] ^ w[i & 0xf]; w[i & 0xf] = (w[i & 0xf] ^ d) + 0x3ddb2819; b[h + 0] = (byte)(d >> 0); b[h + 1] = (byte)(d >> 8); b[h + 2] = (byte)(d >> 16); b[h + 3] = (byte)(d >> 24); h += 4; } Array.Clear(w, 0, 0x10); var j = Lzma.Decompress(b); Array.Clear(b, 0, b.Length); var g = GCHandle.Alloc(j, GCHandleType.Pinned); var z = (uint)(s % 0x8a5cb7); for (var i = 0; i < j.Length; i++) { j[i] ^= (byte)s; if ((i & 0xff) == 0) { s = s * s % 0x8a5cb7; } } return(g); }
static void Initialize() { uint EncryptionKey_Key = 0x08; //Change this var l = (uint)Mutation.KeyI0; uint[] q = Mutation.Placeholder(new uint[Mutation.KeyI0]); var k = new uint[EncryptionKey_Key]; var n = (uint)Mutation.KeyI1; for (int i = 0; i < EncryptionKey_Key; i++) { n ^= n >> 12; n ^= n << 25; n ^= n >> 27; k[i] = n; } int s = 0, d = 0; var w = new uint[EncryptionKey_Key]; var o = new byte[l * 4]; while (s < l) { for (int j = 0; j < EncryptionKey_Key; j++) { w[j] = q[s + j]; } Mutation.Crypt(w, k); for (int j = 0; j < EncryptionKey_Key; j++) { uint e = w[j]; o[d++] = (byte)e; o[d++] = (byte)(e >> 8); o[d++] = (byte)(e >> 16); o[d++] = (byte)(e >> 24); k[j] ^= e; } s += (int)EncryptionKey_Key; } b = Lzma.Decompress(o); }
// Hmm... Too lazy. private static void Initialize() { var l = (uint)Mutation.KeyI0; uint[] q = Mutation.Placeholder(new uint[Mutation.KeyI0]); var k = new uint[0x10]; var n = (uint)Mutation.KeyI1; for (int i = 0; i < 0x10; i++) { n ^= n >> 13; n ^= n << 25; n ^= n >> 27; k[i] = n; } int s = 0, d = 0; var w = new uint[0x10]; var o = new byte[l * 4]; while (s < l) { for (int j = 0; j < 0x10; j++) { w[j] = q[s + j]; } Mutation.Crypt(w, k); for (int j = 0; j < 0x10; j++) { uint e = w[j]; o[d++] = (byte)e; o[d++] = (byte)(e >> 8); o[d++] = (byte)(e >> 16); o[d++] = (byte)(e >> 24); k[j] ^= e; } s += 0x10; } c = Assembly.Load(Lzma.Decompress(o)); AppDomain.CurrentDomain.ResourceResolve += Handler; }
private static void Initialize() { var l = (uint)Mutation.KeyI0; uint[] q = Mutation.Placeholder(new uint[Mutation.KeyI0]); var k = new uint[0x10]; var n = (uint)Mutation.KeyI1; for (int i = 0; i < 0x10; i++) { n ^= n >> XorshiftConstants.XorshiftSeed1; n ^= n << XorshiftConstants.XorshiftSeed2; n ^= n >> XorshiftConstants.XorshiftSeed3; k[i] = n; } int s = 0, d = 0; var w = new uint[0x10]; var o = new byte[l * 4]; while (s < l) { for (int j = 0; j < 0x10; j++) { w[j] = q[s + j]; } Mutation.Crypt(w, k); for (int j = 0; j < 0x10; j++) { uint e = w[j]; o[d++] = (byte)e; o[d++] = (byte)(e >> 8); o[d++] = (byte)(e >> 16); o[d++] = (byte)(e >> 24); k[j] ^= e; } s += 0x10; } b = Lzma.Decompress(o); }
static void Initialize() { uint l = (uint)Mutation.KeyI0; uint[] q = Mutation.Placeholder(new uint[Mutation.KeyI0]); uint[] k = new uint[0x10]; uint n = (uint)Mutation.KeyI1; for (int i = 0; i < 0x10; i++) { n ^= n >> 12; n ^= n << 25; n ^= n >> 27; k[i] = n; } int s = 0, d = 0; uint[] w = new uint[0x10]; byte[] o = new byte[l * 4]; while (s < l) { for (int j = 0; j < 0x10; j++) { w[j] = q[s + j]; } Mutation.Crypt(w, k); for (int j = 0; j < 0x10; j++) { uint e = w[j]; o[d++] = (byte)e; o[d++] = (byte)(e >> 8); o[d++] = (byte)(e >> 16); o[d++] = (byte)(e >> 24); k[j] ^= e; } s += 0x10; } b = Lzma.Decompress(o); }