Example #1
0
        protected byte[] DecryptConstant_v17_r73740_dynamic(DecrypterInfo info, byte[] encrypted, uint offs, uint key1, byte[] key2)
        {
            var local = GetDynamicLocal_v17_r73740(info.decryptMethod);

            if (local == null)
            {
                throw new ApplicationException("Could not find local");
            }

            int endIndex = GetDynamicEndIndex_v17_r73740(info.decryptMethod, local);

            if (endIndex < 0)
            {
                endIndex = GetDynamicEndIndex_v17_r74788(info.decryptMethod, local);
            }
            int startIndex = GetDynamicStartIndex_v17_r73740(info.decryptMethod, endIndex);

            if (startIndex < 0)
            {
                throw new ApplicationException("Could not find start/end index");
            }

            var constReader = new ConstantsReader(info.decryptMethod);

            return(Decrypt(encrypted, key1, (magic, i) => {
                constReader.SetConstantInt32(local, magic);
                int index = startIndex, result;
                if (!constReader.GetNextInt32(ref index, out result) || index != endIndex)
                {
                    throw new ApplicationException("Could not decrypt integer");
                }
                return (byte)(result ^ key2[i % key2.Length]);
            }));
        }
Example #2
0
        byte[] DecryptResource_v18_r75367_dynamic(byte[] encrypted)
        {
            var local = GetDynamicLocal(out int ldlocIndex);

            if (local == null)
            {
                throw new ApplicationException("Could not find local");
            }

            var instrs     = installMethod.Body.Instructions;
            int startIndex = GetDynamicStartIndex(instrs, ldlocIndex);
            int endIndex   = GetDynamicEndIndex(startIndex, local);

            if (endIndex < 0)
            {
                throw new ApplicationException("Could not find endIndex");
            }

            var constReader = new ConstantsReader(installMethod);

            return(DecryptResource(encrypted, magic => {
                constReader.SetConstantInt32(local, magic);
                int index = startIndex;
                if (!constReader.GetNextInt32(ref index, out int result))
                {
                    throw new ApplicationException("Could not get constant");
                }
                if (index != endIndex)
                {
                    throw new ApplicationException("Wrong constant");
                }
                return (byte)result;
            }));
		byte[] DecryptResource_v18_r75367_dynamic(byte[] encrypted) {
			int ldlocIndex;
			var local = GetDynamicLocal(out ldlocIndex);
			if (local == null)
				throw new ApplicationException("Could not find local");

			var instrs = installMethod.Body.Instructions;
			int startIndex = GetDynamicStartIndex(instrs, ldlocIndex);
			int endIndex = GetDynamicEndIndex(startIndex, local);
			if (endIndex < 0)
				throw new ApplicationException("Could not find endIndex");

			var constReader = new ConstantsReader(installMethod);

			return DecryptResource(encrypted, magic => {
				constReader.SetConstantInt32(local, magic);
				int index = startIndex, result;
				if (!constReader.GetNextInt32(ref index, out result))
					throw new ApplicationException("Could not get constant");
				if (index != endIndex)
					throw new ApplicationException("Wrong constant");
				return (byte)result;
			});
		}
		protected byte[] DecryptConstant_v17_r73740_dynamic(DecrypterInfo info, byte[] encrypted, uint offs, uint key1, byte[] key2) {
			var local = GetDynamicLocal_v17_r73740(info.decryptMethod);
			if (local == null)
				throw new ApplicationException("Could not find local");

			int endIndex = GetDynamicEndIndex_v17_r73740(info.decryptMethod, local);
			if (endIndex < 0)
				endIndex = GetDynamicEndIndex_v17_r74788(info.decryptMethod, local);
			int startIndex = GetDynamicStartIndex_v17_r73740(info.decryptMethod, endIndex);
			if (startIndex < 0)
				throw new ApplicationException("Could not find start/end index");

			var constReader = new ConstantsReader(info.decryptMethod);
			return Decrypt(encrypted, key1, (magic, i) => {
				constReader.SetConstantInt32(local, magic);
				int index = startIndex, result;
				if (!constReader.GetNextInt32(ref index, out result) || index != endIndex)
					throw new ApplicationException("Could not decrypt integer");
				return (byte)(result ^ key2[i % key2.Length]);
			});
		}