public byte[] Decrypt() { if (assemblyEncryptedResource == null) { return(null); } assemblyEncryptedResource.Data.Position = 0; var reader = new BinaryReader(assemblyEncryptedResource.Data.CreateStream()); var encryptedData = DeobUtils.Gunzip(reader.BaseStream, reader.ReadInt32()); reader = new BinaryReader(new MemoryStream(encryptedData)); var serializedData = reader.ReadBytes(reader.ReadInt32()); for (int i = 0; i < serializedData.Length; i++) { serializedData[i] ^= 0xAD; } var encryptedAssembly = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position)); var passwordFinder = new PasswordFinder(serializedData); PasswordInfo mainAsmPassword; passwordFinder.Find(out mainAsmPassword, out embedPassword); return(Decrypt(mainAsmPassword, encryptedAssembly)); }
static byte[] Gunzip(byte[] data) { var reader = new BinaryReader(new MemoryStream(data)); return(DeobUtils.Gunzip(reader.BaseStream, reader.ReadInt32())); }