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())); }