Beispiel #1
0
        private static string BpStringToJson(string base64BpString)
        {
            var zlibBpString = Convert.FromBase64String(base64BpString);
            var json         = ZlibStream.UncompressString(zlibBpString);

            return(json);
        }
        public void WavOpusSimilarity()
        {
            string opusFingerprint;
            string pcmFingerprint;

            // cut out 30 second from the middle of the file
            var opusDataSection = new short[330750];
            var pcmDataSection  = new short[330750];

            Buffer.BlockCopy(opusData, 330750, opusDataSection, 0, 330750);
            Buffer.BlockCopy(pcmData, 340775, pcmDataSection, 0, 330750);       // starts 1 sec later than opus section

            // generate fingerprints
            var echoPrint = new CodeGen();

            opusFingerprint = echoPrint.Generate(opusDataSection);
            pcmFingerprint  = echoPrint.Generate(pcmDataSection);

            byte[] unbase64edOpusFingerprint = Convert.FromBase64String(opusFingerprint.Replace('-', '+').Replace('_', '/'));
            string unzippedOpusFingerprint   = ZlibStream.UncompressString(unbase64edOpusFingerprint);

            byte[] unbase64edPcmFingerprint = Convert.FromBase64String(pcmFingerprint.Replace('-', '+').Replace('_', '/'));
            string unzippedPcmFingerprint   = ZlibStream.UncompressString(unbase64edPcmFingerprint);

            // compute Damereau-Levenshein Distance in absence of actual fingerprint matching algorithm
            int   similarity = ComputeLevenshteinDistance(unzippedOpusFingerprint, unzippedPcmFingerprint);
            float averageDifferencePerCharacter = (float)similarity / (unzippedOpusFingerprint.Length + unzippedPcmFingerprint.Length / 2);

            Assert.Less(averageDifferencePerCharacter, 0.4);
            Assert.Greater(averageDifferencePerCharacter, 0.001);
        }
        /// <summary>
        /// Reads the <see cref="AvatarProfileResponseMessage"/> from the specified <see cref="MessageReader"/>.
        /// </summary>
        /// <param name="reader">
        /// <see cref="MessageReader"/> that will be used to read the <see cref="AvatarProfileResponseMessage"/>.
        /// </param>
        public override void ReadMessage(MessageReader reader)
        {
            AvatarData = new AvatarMessageComponent();
            AvatarData.ReadMessageComponent(reader);

            var villageBytes = reader.ReadBytes();

            if (villageBytes.Length != 0)
            {
                var mem = new MemoryStream(villageBytes);
                using (var br = new BinaryReader(mem))
                {
                    var decompressedLength = br.ReadInt32();
                    var compressedVillage  = br.ReadBytes(villageBytes.Length - 4);
                    var villageJson        = ZlibStream.UncompressString(compressedVillage);
                    VillageJson = villageJson;
                }
            }

            TroopsDonated  = reader.ReadInt32();
            TroopsReceived = reader.ReadInt32();
            WarCoolDown    = TimeSpan.FromSeconds(reader.ReadInt32());

            Unknown2 = reader.ReadInt32();
            Unknown3 = reader.ReadBoolean();
        }
Beispiel #4
0
        /// <summary>
        /// Reads the <see cref="LoginFailedMessage"/> from the specified <see cref="MessageReader"/>.
        /// </summary>
        /// <param name="reader">
        /// <see cref="MessageReader"/> that will be used to read the <see cref="LoginFailedMessage"/>.
        /// </param>
        /// <exception cref="ArgumentNullException"><paramref name="reader"/> is null.</exception>
        public override void ReadMessage(MessageReader reader)
        {
            ThrowIfReaderNull(reader);

            Reason = (LoginFailureReason)reader.ReadInt32(); // Returned 2 when data is not valid.

            FingerprintJson = reader.ReadString();           // null

            Hostname            = reader.ReadString();       // stage.clashofclans.com
            ContentUrl          = reader.ReadString();       // http://b46f744d64acd2191eda-3720c0374d47e9a0dd52be4d281c260f.r11.cf2.rackcdn.com/
            MarketUrl           = reader.ReadString();       // market://details?id=com.supercell.clashofclans
            Message             = reader.ReadString();
            MaintenanceDuration = TimeSpan.FromSeconds(reader.ReadInt32());

            Unknown4 = reader.ReadByte(); // 0

            //TODO: Implement Compressed String in MessageWriter and MessageReader.
            var fingerprintData = reader.ReadBytes();

            if (fingerprintData != null)
            {
                using (var br = new BinaryReader(new MemoryStream(fingerprintData)))
                {
                    var decompressedLength    = br.ReadInt32();
                    var compressedFingerprint = br.ReadBytes(fingerprintData.Length - 4);
                    var fingerprintJson       = ZlibStream.UncompressString(compressedFingerprint);
                    FingerprintJsonCompressed = fingerprintJson;
                }
            }

            Unknown6 = reader.ReadInt32(); // -1
            Unknown7 = reader.ReadInt32(); // 2
            Unknown8 = reader.ReadInt32(); // 0
            Unknown9 = reader.ReadInt32(); // -1
        }
Beispiel #5
0
        public static string UncompressString(byte[] compressed)
        {
            try
            {
                //  throw new ApplicationException("test");
                if (compressed == null || compressed.Length == 0)
                {
                    return(string.Empty);
                }

                string uncompressed = ZlibStream.UncompressString(compressed);
                // if it contains old format value (xml)
                if (uncompressed.Length == 0 || uncompressed[0] == '<')
                {
                    return(uncompressed);
                }
                // if it contains new format value (base64 string)
                byte[] encodedDataAsBytes = Convert.FromBase64String(uncompressed);
                return(System.Text.Encoding.Unicode.GetString(encodedDataAsBytes));
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                return(string.Empty);
            }
        }
        /// <summary>
        /// Reads the <see cref="VillageMessageComponent"/> from the specified <see cref="MessageReader"/>.
        /// </summary>
        /// <param name="reader">
        /// <see cref="MessageReader"/> that will be used to read the <see cref="VillageMessageComponent"/>.
        /// </param>
        /// <exception cref="ArgumentNullException"><paramref name="reader"/> is null.</exception>
        /// <exception cref="InvalidMessageException">Home data array is null.</exception>
        public override void ReadMessageComponent(MessageReader reader)
        {
            ThrowIfReaderNull(reader);

            HomeId         = reader.ReadInt64();
            ShieldDuration = TimeSpan.FromSeconds(reader.ReadInt32());
            GuardDuration  = TimeSpan.FromSeconds(reader.ReadInt32()); // 1800 = 8.x.x

            Unknown1 = reader.ReadInt32();                             // 69119 = 8.x.x seems to change, might be a TimeSpan.

            if (reader.ReadBoolean())
            {
                var homeData = reader.ReadBytes();
                if (homeData == null)
                {
                    throw new InvalidMessageException("No data was provided about Village.");
                }

                if (homeData.Length != 0)
                {
                    // Use a BinaryReader for little-endian reading.
                    var mem = new MemoryStream(homeData);
                    using (var br = new BinaryReader(mem))
                    {
                        var decompressedLength = br.ReadInt32();
                        var compressedHome     = br.ReadBytes(homeData.Length - 4); // -4 to remove the decompressedLength bytes read.
                        var homeJson           = ZlibStream.UncompressString(compressedHome);
                        VillageJson = homeJson;
                    }
                }
            }

            if (reader.ReadBoolean())
            {
                var eventData = reader.ReadBytes();
                if (eventData == null)
                {
                    throw new InvalidMessageException("No data was provided about Village.");
                }

                if (eventData.Length != 0)
                {
                    // Use a BinaryReader for little-endian reading.
                    var mem = new MemoryStream(eventData);
                    using (var br = new BinaryReader(mem))
                    {
                        var decompressedLength = br.ReadInt32();
                        var compressedEvent    = br.ReadBytes(eventData.Length - 4); // -4 to remove the decompressedLength bytes read.
                        var eventJson          = ZlibStream.UncompressString(compressedEvent);
                        EventJson = eventJson;
                    }
                }
            }
        }
Beispiel #7
0
        public static Modules.PostAnalysisResults InflateAndDeserializeResults(byte[] compressed)
        {
            if (compressed == null)
            {
                return(new Modules.PostAnalysisResults());
            }

            string json = ZlibStream.UncompressString(compressed);

            return(JsonConvert.DeserializeObject <Modules.PostAnalysisResults>(json));
        }
Beispiel #8
0
        public static string DecodeJson(string json)
        {
            if (string.IsNullOrWhiteSpace(json))
            {
                return(null);
            }
            //remove first 32 chars (constant hash), convert base-64 string to standard string, uncompress string with zlib deflation.
            string decodedJson = ZlibStream.UncompressString(Convert.FromBase64String(json.Substring(32)));

            //return prettified json
            return(PrettifyJson(decodedJson));
        }
Beispiel #9
0
        /// <summary>
        /// Decodes a compressed string
        /// </summary>
        /// <param name="byteBuffer"></param>
        /// <param name="indicator"></param>
        /// <returns></returns>
        public static string ReadCompressedString(this IByteBuffer byteBuffer, bool indicator = true)
        {
            if (indicator)
            {
                byteBuffer.ReadByte();
            }

            var compressedLength = byteBuffer.ReadInt() - 4;

            byteBuffer.ReadIntLE();

            var compressedBytes = byteBuffer.ReadBytes(compressedLength);

            return(ZlibStream.UncompressString(compressedBytes.Array));
        }
Beispiel #10
0
        internal string ReadZlibStream()
        {
            var bytes = ReadBytes();

            if (bytes?.Length > 0)
            {
                using (Reader br = new Reader(bytes))
                {
                    int    decompressedLength = br.ReadInt32();
                    string homeJson           = ZlibStream.UncompressString(br.ReadFully());
                    return(homeJson);
                }
            }
            return(null);
        }
Beispiel #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        public void ReadFromPacketReader(PacketReader reader)
        {
            var homeData = reader.ReadByteArray();

            if (homeData == null)
            {
                return;
            }
            using (var binaryReader = new BinaryReader(new MemoryStream(homeData)))
            {
                var decompressedLength = binaryReader.ReadInt32();
                var compressedJson     = binaryReader.ReadBytes(homeData.Length - 4);
                var json = ZlibStream.UncompressString(compressedJson);
                //if (decompressedLength != json.Length)
                //    throw new InvalidDataException(string.Format("Json length is not valid. {0} != {1}.", decompressedLength, json.Length));
                FromJson(json);
            }
        }
Beispiel #12
0
        private static string UnzipStringVersion5(byte[] compressed)
        {
            //  throw new ApplicationException("test");
            if (compressed == null || compressed.Length == 0)
            {
                return(string.Empty);
            }

            string uncompressed = ZlibStream.UncompressString(compressed);

            // if it contains old format value (xml)
            if (uncompressed.Length == 0 || uncompressed[0] == '<')
            {
                return(uncompressed);
            }
            // if it contains new format value (base64 string)
            byte[] encodedDataAsBytes = Convert.FromBase64String(uncompressed);
            return(Encoding.Unicode.GetString(encodedDataAsBytes));
        }
Beispiel #13
0
        private async Task GetManifestJson(int version)
        {
            if (version == -1)
            {
                PatcherContext.UpdateMainProgress(Properties.Resources.GettingLatestVersion, "", 0, true, true);
                _version = version = await NexonApi.Instance.GetLatestVersion();
            }

            PatcherContext.UpdateMainProgress(Properties.Resources.DownloadingManifest, "", 0, true, true);
            // Get Manifest String
            var manifestHashString = await NexonApi.Instance.GetManifestHashString();

            // Download Manifest
            var buffer = DownloadManifestBuffer(manifestHashString);

            PatcherContext.UpdateMainProgress(Properties.Resources.DecompressingManifest, "", 0, true, true);

            // Decompress Manifest and Convert to Object
            var manifestContent = ZlibStream.UncompressString(buffer);
            var data            = JsonConvert.DeserializeObject <dynamic>(manifestContent);

            PatchData = data;
        }
        public override void Encode()
        {
            var data = new List <byte>();

            data.AddInt32(0);
            data.AddInt32(JsonBase.Length);
            data.AddRange(Encoding.ASCII.GetBytes(JsonBase));
            data.AddRange(Player.GetPlayerAvatar().Encode());
            data.AddInt32(0);
            data.AddInt32(LevelId);

            byte[] home2 =
            {
                /*0x00, 0x00, 0x03, 0x55, 0x25, 0x0F, 0x00, 0x00,*/ 0x78, 0x9C, 0x9D, 0x57, 0x4B, 0x6F, 0xE2,
                0x30,                                                     0x10, 0xFE, 0x2F, 0x39, 0x67, 0xA5, 0xD8, 0x4E, 0xC2, 0xE3, 0xB8, 0x5D, 0xED, 0x69, 0x4F, 0xDB,
                0xD5,                                                     0x5E, 0x2A, 0x64, 0x19, 0xE2, 0x42, 0xB4, 0xC6, 0x8E, 0x12, 0x07, 0x8A, 0xAA, 0xFE, 0xF7, 0x1D,
                0xC7,                                                     0x03, 0x24, 0x88, 0xAA, 0x36, 0x8D, 0x0A, 0xF8, 0xF1, 0x8D, 0xE7, 0xF1, 0xCD, 0x64, 0xFC, 0x9E,
                0x08,                                                     0x5D, 0xB5, 0xA6, 0xAE, 0xF8, 0x46, 0xD5, 0x52, 0xDB, 0x64, 0x69, 0xDB, 0x5E, 0xA6, 0x89, 0xD8,
                0xD8,                                                     0xFA, 0x20, 0xB9, 0x12, 0x27, 0xD3, 0xC3, 0x64, 0x96, 0x26, 0xFE, 0x27, 0xEF, 0xAC, 0xB0, 0x32,
                0x59,                                                     0xBE, 0x64, 0xE9, 0xE5, 0x59, 0xA5, 0xC9, 0xBA, 0xAF, 0x55, 0x55, 0xEB, 0x6D, 0x07, 0x2B, 0xEF,
                0x49,                                                     0x25, 0xAC, 0x48, 0x96, 0x24, 0x73, 0x7F, 0x04, 0x90, 0x07, 0x95, 0x2C, 0x69, 0x9A, 0xBC, 0xC1,
                0x27,                                                     0x0C, 0x4F, 0xF0, 0x05, 0xF2, 0x76, 0xCD, 0x20, 0xB6, 0x95, 0xDB, 0x64, 0xF9, 0x2A, 0x54, 0x27,
                0x3F,                                                     0xD2, 0x29, 0x32, 0x9F, 0x22, 0xB3, 0x01, 0x49, 0xCA, 0x3B, 0x48, 0xF7, 0xBB, 0xE3, 0xB6, 0xDE,
                0x83,                                                     0x62, 0xD9, 0xAD, 0x98, 0x0C, 0xC5, 0x64, 0x5E, 0x4C, 0xE9, 0xC5, 0x2C, 0xD2, 0xA4, 0xD7, 0xB5,
                0x75,                                                     0xFA, 0xBE, 0xE4, 0xB8, 0x8F, 0x66, 0x2B, 0x30, 0xA5, 0xB3, 0xA6, 0x15, 0x5B, 0xC9, 0xED, 0xA9,
                0x91,                                                     0x03, 0xEA, 0x2B, 0x45, 0x49, 0x31, 0x39, 0x81, 0xCC, 0x83, 0x4D, 0x24, 0xF9, 0x54, 0xB7, 0x62,
                0x40,                                                     0x32, 0x1A, 0xE0, 0x9C, 0xF9, 0x14, 0xC9, 0xBC, 0x55, 0x2C, 0x5A, 0x5B, 0x44, 0xD2, 0x3C, 0xE0,
                0x4C,                                                     0x8A, 0x48, 0x32, 0xB1, 0xB3, 0x88, 0x0D, 0x08, 0x43, 0x31, 0xF0, 0xBD, 0x31, 0xBA, 0xB3, 0xDC,
                0x3A,                                                     0xCD, 0x67, 0xD9, 0x65, 0xC8, 0xA5, 0xAE, 0x60, 0x2A, 0x67, 0x05, 0xCB, 0x19, 0x2D, 0xE8, 0xD8,
                0x39,                                                     0x41, 0x8A, 0x9E, 0x4D, 0x2C, 0x3C, 0x92, 0x7A, 0xE4, 0x3D, 0xE6, 0xDC, 0x22, 0xCB, 0x89, 0x89,
                0x67,                                                     0xB2, 0xDC, 0xE7, 0x9C, 0xE3, 0x0F, 0x6F, 0x5A, 0x03, 0xBA, 0xBE, 0xFB, 0x01, 0x52, 0xE6, 0xE3,
                0x0B,                                                     0x0A, 0x2E, 0xBC, 0xD4, 0xFC, 0x0E, 0x05, 0xD9, 0x43, 0x0C, 0xBC, 0x4D, 0x15, 0x64, 0xC3, 0x6C,
                0x1A,                                                     0x06, 0x90, 0x6C, 0xD6, 0x90, 0xBE, 0x1B, 0x25, 0xC7, 0x69, 0x3A, 0x1F, 0x24, 0xCC, 0x06, 0x64,
                0x71,                                                     0xA1, 0x91, 0x32, 0xC6, 0xF2, 0x7D, 0xAF, 0x6C, 0xDD, 0xA8, 0x13, 0x3F, 0xC8, 0x16, 0xA6, 0xAF,
                0xA7,                                                     0x8E, 0x31, 0x04, 0x03, 0xB3, 0x08, 0x03, 0x15, 0x63, 0x1F, 0xE4, 0x61, 0x98, 0x72, 0x7C, 0x10,
                0x9B,                                                     0x85, 0x81, 0xB2, 0x71, 0xD9, 0x08, 0x3C, 0xC8, 0x2B, 0xE7, 0x4E, 0x38, 0x79, 0x82, 0x87, 0xBB,
                0xA1,                                                     0x8C, 0x39, 0x87, 0x4D, 0xE8, 0x95, 0x45, 0x79, 0xCE, 0x1B, 0xC4, 0xCA, 0xA8, 0x93, 0xBC, 0xBB,
                0x59,                                                     0x94, 0x1B, 0x1E, 0x89, 0xEB, 0xFC, 0x01, 0x8B, 0x8A, 0x0B, 0x5B, 0x43, 0x30, 0x9E, 0xE2, 0xB9,
                0xB7,                                                     0x27, 0x90, 0xA8, 0x74, 0x6C, 0x0F, 0x89, 0xC1, 0x90, 0xEC, 0x52, 0x92, 0x43, 0x40, 0xBE, 0x6C,
                0x44,                                                     0x71, 0x1B, 0x8B, 0xA9, 0x4F, 0x59, 0x16, 0xA8, 0x9C, 0x07, 0x79, 0x9A, 0xB2, 0x22, 0x86, 0xA6,
                0xDE,                                                     0x71, 0x51, 0x31, 0x65, 0x58, 0x3F, 0x03, 0xD3, 0x01, 0x41, 0x79, 0x54, 0x29, 0x41, 0x2F, 0xE4,
                0x51,                                                     0x89, 0xE7, 0x41, 0xCC, 0xC7, 0x35, 0xCC, 0x0B, 0x04, 0x2B, 0x24, 0xF2, 0x27, 0x8C, 0xA7, 0x08,
                0x62,                                                     0x24, 0x86, 0xDC, 0x64, 0xD2, 0x6F, 0xB0, 0x30, 0x93, 0x10, 0x84, 0x7E, 0x08, 0x34, 0x89, 0x8D,
                0x1D,                                                     0x1E, 0x98, 0x12, 0x08, 0x42, 0xDA, 0x85, 0xD1, 0xC1, 0x69, 0x75, 0x4D, 0x89, 0xC0, 0x7C, 0x45,
                0x10,                                                     0x3A, 0x3C, 0x30, 0xC7, 0x7D, 0xBD, 0x67, 0xE5, 0xE5, 0xBD, 0x1D, 0x72, 0x10, 0x19, 0xBF, 0xFB,
                0x02,                                                     0x2B, 0xDD, 0x19, 0x94, 0x3F, 0xF2, 0x66, 0x89, 0x4B, 0xBF, 0x69, 0x8B, 0x17, 0x07, 0x2A, 0x63,
                0xD8,                                                     0x8A, 0x89, 0x7E, 0x76, 0x44, 0x54, 0xE5, 0xA2, 0xF3, 0x98, 0x32, 0x74, 0x8E, 0xED, 0x3C, 0xE6,
                0x45,                                                     0xC1, 0xB0, 0xB0, 0x7A, 0xCC, 0x7D, 0xED, 0xE8, 0xAD, 0x76, 0x8B, 0x71, 0x98, 0xC8, 0x67, 0x26,
                0x41,                                                     0x83, 0x53, 0xC9, 0x8D, 0x71, 0xCD, 0xCD, 0x6A, 0x68, 0x7D, 0x1A, 0x71, 0xD4, 0x7F, 0x45, 0xDB,
                0xB9,                                                     0x06, 0xAD, 0x83, 0x15, 0x5D, 0x75, 0x3F, 0x5B, 0xB3, 0xFF, 0x25, 0x3A, 0xFB, 0xDB, 0xAF, 0x02,
                0xF7,                                                     0xCB, 0x45, 0x71, 0xD9, 0xFC, 0x2C, 0x25, 0x74, 0x73, 0xDF, 0x08, 0x2B, 0x67, 0x19, 0x65, 0xAC,
                0x20,                                                     0xD7, 0x96, 0xE9, 0x49, 0x49, 0xD1, 0x3E, 0x99, 0x5E, 0x5B, 0x77, 0x18, 0x98, 0xEC, 0xDA, 0x2A,
                0x6E,                                                     0x0D, 0xDF, 0xCA, 0xFD, 0xDA, 0xBC, 0x71, 0xB8, 0x44, 0x35, 0xCE, 0xDD, 0x34, 0x9F, 0x53, 0x5C,
                0xAC,                                                     0xF5, 0x79, 0xB1, 0x91, 0x6D, 0x6D, 0x7C, 0x4F, 0x5B, 0x12, 0xF0, 0x08, 0x74, 0xBA, 0x46, 0x55,
                0xE6,                                                     0xA8, 0x51, 0x57, 0x2D, 0x8F, 0xCF, 0x3B, 0xD3, 0x7C, 0x1F, 0xDD, 0xA2, 0x28, 0xDC, 0xAC, 0x58,
                0x4A,                                                     0x87, 0x7F, 0x9A, 0x92, 0x94, 0x5E, 0xEF, 0x5B, 0x30, 0x2A, 0x46, 0xA3, 0x9B, 0xE7, 0x2A, 0xEE,
                0x4F,                                                     0x2B, 0x9A, 0x6E, 0x7A, 0x55, 0xBB, 0xDD, 0xF2, 0x03, 0xFD, 0x45, 0xD2, 0x1C, 0x25, 0x7F, 0x2A,
                0x37,                                                     0xEC, 0x59, 0xB9, 0x8B, 0x22, 0x34, 0xF1, 0xE0, 0xAD, 0x6D, 0x2F, 0x79, 0x2B, 0xF4, 0x3F, 0xBC,
                0x3D,                                                     0xC2, 0xA4, 0x50, 0xAA, 0x16, 0x7A, 0x03, 0xD7, 0x4A, 0x79, 0x90, 0xCA, 0xBF, 0x22, 0x47, 0x9B,
                0xBB,                                                     0x5D, 0xFF, 0xFA, 0xAA, 0xE4, 0x75, 0x3F, 0x28, 0xD9, 0xF1, 0x4E, 0x4A, 0xED, 0xAA, 0x0E, 0x44,
                0x49,                                                     0x56, 0xD0, 0x64, 0xEF, 0x4D, 0xE5, 0xB6, 0x1A, 0x17, 0x3C, 0xEC, 0xC4, 0x8F, 0xA2, 0xE5, 0xB6,
                0x87,                                                     0xAE, 0xB9, 0x86, 0x31, 0x02, 0x32, 0x3F, 0xBD, 0x16, 0x9D, 0xBC, 0xEC, 0xDB, 0x49, 0xD5, 0x70,
                0xD3,                                                     0x48, 0xED, 0xA2, 0x8C, 0x73, 0x6B, 0x88, 0x04, 0x5E, 0x73, 0xF9, 0x20, 0x7F, 0x10, 0xCD, 0x65,
                0x7B,                                                     0x05, 0x7E, 0xFC, 0x07, 0xCA, 0xF2, 0x7C, 0x89
            };
            Debugger.WriteLine(ZlibStream.UncompressString(home2), null, 5);
            ;

            SetData(data.ToArray());
        }
        // These two data types are supported in DotNetZip, but only if .NET Framework is targeted.
        //private SelfExtractorFlavor _selfExtractorFlavor;
        //private SelfExtractorSaveOptions _selfExtractorSaveOptions;

        public void CallAll()
        {
            // These two apis are supported in DotNetZip, but only if .NET Framework is targeted.
            //_zipFile.SaveSelfExtractor(_string, _selfExtractorFlavor);
            //_zipFile.SaveSelfExtractor(_string, _selfExtractorSaveOptions);

            //Project: Ionic.Zip
            _bZip2InputStream.Close();
            _bZip2InputStream.Flush();
            _int  = _bZip2InputStream.Read(_bytes, _int, _int);
            _int  = _bZip2InputStream.ReadByte();
            _long = _bZip2InputStream.Seek(_long, _seekOrigin);
            _bZip2InputStream.SetLength(_long);
            _bZip2InputStream.Write(_bytes, _int, _int);
            _bZip2OutputStream.Close();
            _bZip2OutputStream.Flush();
            _int  = _bZip2OutputStream.Read(_bytes, _int, _int);
            _long = _bZip2OutputStream.Seek(_long, _seekOrigin);
            _bZip2OutputStream.SetLength(_long);
            _bZip2OutputStream.Write(_bytes, _int, _int);
            _parallelBZip2OutputStream.Close();
            _parallelBZip2OutputStream.Flush();
            _int  = _parallelBZip2OutputStream.Read(_bytes, _int, _int);
            _long = _parallelBZip2OutputStream.Seek(_long, _seekOrigin);
            _parallelBZip2OutputStream.SetLength(_long);
            _parallelBZip2OutputStream.Write(_bytes, _int, _int);
            _crc32.Combine(_int, _int);
            _int = _crc32.ComputeCrc32(_int, _byte);
            _int = _crc32.GetCrc32(_stream);
            _int = _crc32.GetCrc32AndCopy(_stream, _stream);
            _crc32.Reset();
            _crc32.SlurpBlock(_bytes, _int, _int);
            _crc32.UpdateCRC(_byte);
            _crc32.UpdateCRC(_byte, _int);
            _crcCalculatorStream.Close();
            _crcCalculatorStream.Flush();
            _int  = _crcCalculatorStream.Read(_bytes, _int, _int);
            _long = _crcCalculatorStream.Seek(_long, _seekOrigin);
            _crcCalculatorStream.SetLength(_long);
            _crcCalculatorStream.Write(_bytes, _int, _int);
            _zipEntriesCollection = _fileSelector.SelectEntries(_zipFile);
            _zipEntriesCollection = _fileSelector.SelectEntries(_zipFile, _string);
            _stringsCollection    = _fileSelector.SelectFiles(_string);
            _stringsReadOnly      = _fileSelector.SelectFiles(_string, _bool);
            _string = _fileSelector.ToString();
            _bool   = _comHelper.CheckZip(_string);
            _bool   = _comHelper.CheckZipPassword(_string, _string);
            _comHelper.FixZipDirectory(_string);
            _string = _comHelper.GetZipLibraryVersion();
            _bool   = _comHelper.IsZipFile(_string);
            _bool   = _comHelper.IsZipFileWithExtract(_string);
            _countingStream.Adjust(_long);
            _countingStream.Flush();
            _int  = _countingStream.Read(_bytes, _int, _int);
            _long = _countingStream.Seek(_long, _seekOrigin);
            _countingStream.SetLength(_long);
            _countingStream.Write(_bytes, _int, _int);
            _zipEntry.Extract();
            _zipEntry.Extract(_extractExistingFileAction);
            _zipEntry.Extract(_string);
            _zipEntry.Extract(_string, _extractExistingFileAction);
            _zipEntry.Extract(_stream);
            _zipEntry.ExtractWithPassword(_extractExistingFileAction, _string);
            _zipEntry.ExtractWithPassword(_string);
            _zipEntry.ExtractWithPassword(_string, _extractExistingFileAction, _string);
            _zipEntry.ExtractWithPassword(_string, _string);
            _zipEntry.ExtractWithPassword(_stream, _string);
            _crcCalculatorStream = _zipEntry.OpenReader();
            _crcCalculatorStream = _zipEntry.OpenReader(_string);
            _zipEntry.SetEntryTimes(_datetime, _datetime, _datetime);
            _string   = _zipEntry.ToString();
            _zipEntry = _zipFile.AddDirectory(_string);
            _zipEntry = _zipFile.AddDirectory(_string, _string);
            _zipEntry = _zipFile.AddDirectoryByName(_string);
            _zipEntry = _zipFile.AddEntry(_string, _bytes);
            _zipEntry = _zipFile.AddEntry(_string, _openDelegate, _closeDelegate);
            _zipEntry = _zipFile.AddEntry(_string, _writeDelegate);
            _zipEntry = _zipFile.AddEntry(_string, _string);
            _zipEntry = _zipFile.AddEntry(_string, _string, _encoding);
            _zipEntry = _zipFile.AddEntry(_string, _stream);
            _zipEntry = _zipFile.AddFile(_string);
            _zipEntry = _zipFile.AddFile(_string, _string);
            _zipFile.AddFiles(_strings);
            _zipFile.AddFiles(_strings, _bool, _string);
            _zipFile.AddFiles(_strings, _string);
            _zipEntry = _zipFile.AddItem(_string);
            _zipEntry = _zipFile.AddItem(_string, _string);
            _zipFile.AddSelectedFiles(_string);
            _zipFile.AddSelectedFiles(_string, _bool);
            _zipFile.AddSelectedFiles(_string, _string);
            _zipFile.AddSelectedFiles(_string, _string, _bool);
            _zipFile.AddSelectedFiles(_string, _string, _string);
            _zipFile.AddSelectedFiles(_string, _string, _string, _bool);
            _bool = _zipFile.ContainsEntry(_string);
            _zipFile.Dispose();
            _zipFile.ExtractAll(_string);
            _zipFile.ExtractAll(_string, _extractExistingFileAction);
            _zipFile.ExtractSelectedEntries(_string);
            _zipFile.ExtractSelectedEntries(_string, _extractExistingFileAction);
            _zipFile.ExtractSelectedEntries(_string, _string);
            _zipFile.ExtractSelectedEntries(_string, _string, _string);
            _zipFile.ExtractSelectedEntries(_string, _string, _string, _extractExistingFileAction);
            _enumerator = _zipFile.GetNewEnum();
            _zipFile.Initialize(_string);
            _zipFile.RemoveEntries(_zipEntriesCollection);
            _zipFile.RemoveEntries(_stringsCollection);
            _zipFile.RemoveEntry(_zipEntry);
            _zipFile.RemoveEntry(_string);
            _int = _zipFile.RemoveSelectedEntries(_string);
            _int = _zipFile.RemoveSelectedEntries(_string, _string);
            _zipFile.Save();
            _zipFile.Save(_string);
            _zipFile.Save(_stream);
            _zipEntriesCollection = _zipFile.SelectEntries(_string);
            _zipEntriesCollection = _zipFile.SelectEntries(_string, _string);
            _string   = _zipFile.ToString();
            _zipEntry = _zipFile.UpdateDirectory(_string);
            _zipEntry = _zipFile.UpdateDirectory(_string, _string);
            _zipEntry = _zipFile.UpdateEntry(_string, _bytes);
            _zipEntry = _zipFile.UpdateEntry(_string, _openDelegate, _closeDelegate);
            _zipEntry = _zipFile.UpdateEntry(_string, _writeDelegate);
            _zipEntry = _zipFile.UpdateEntry(_string, _string);
            _zipEntry = _zipFile.UpdateEntry(_string, _string, _encoding);
            _zipEntry = _zipFile.UpdateEntry(_string, _stream);
            _zipEntry = _zipFile.UpdateFile(_string);
            _zipFile.UpdateFile(_string, _string);
            _zipFile.UpdateFiles(_strings);
            _zipFile.UpdateFiles(_strings, _string);
            _zipFile.UpdateItem(_string);
            _zipFile.UpdateItem(_string, _string);
            _zipFile.UpdateSelectedFiles(_string, _string, _string, _bool);
            _zipInputStream.Flush();
            _zipEntry = _zipInputStream.GetNextEntry();
            _int      = _zipInputStream.Read(_bytes, _int, _int);
            _long     = _zipInputStream.Seek(_long, _seekOrigin);
            _zipInputStream.SetLength(_long);
            _string = _zipInputStream.ToString();
            _zipInputStream.Write(_bytes, _int, _int);
            _bool = _zipOutputStream.ContainsEntry(_string);
            _zipOutputStream.Flush();
            _zipEntry = _zipOutputStream.PutNextEntry(_string);
            _int      = _zipOutputStream.Read(_bytes, _int, _int);
            _long     = _zipOutputStream.Seek(_long, _seekOrigin);
            _zipOutputStream.SetLength(_long);
            _string = _zipOutputStream.ToString();
            _zipOutputStream.Write(_bytes, _int, _int);
            _deflateStream.Flush();
            _int  = _deflateStream.Read(_bytes, _int, _int);
            _long = _deflateStream.Seek(_long, _seekOrigin);
            _deflateStream.SetLength(_long);
            _deflateStream.Write(_bytes, _int, _int);
            _gZipStream.Flush();
            _int  = _gZipStream.Read(_bytes, _int, _int);
            _long = _gZipStream.Seek(_long, _seekOrigin);
            _gZipStream.SetLength(_long);
            _gZipStream.Write(_bytes, _int, _int);
            _parallelDeflateOutputStream.Close();
            _parallelDeflateOutputStream.Flush();
            _int = _parallelDeflateOutputStream.Read(_bytes, _int, _int);
            _parallelDeflateOutputStream.Reset(_stream);
            _long = _parallelDeflateOutputStream.Seek(_long, _seekOrigin);
            _parallelDeflateOutputStream.SetLength(_long);
            _parallelDeflateOutputStream.Write(_bytes, _int, _int);

            // Static
            _bool = ZipFile.CheckZip(_string);
            _bool = ZipFile.CheckZip(_string, _bool, _textWriter);
            _bool = ZipFile.CheckZipPassword(_string, _string);
            ZipFile.FixZipDirectory(_string);
            _bool    = ZipFile.IsZipFile(_string);
            _bool    = ZipFile.IsZipFile(_string, _bool);
            _bool    = ZipFile.IsZipFile(_stream, _bool);
            _zipFile = ZipFile.Read(_string);
            _zipFile = ZipFile.Read(_string, _readOptions);
            _zipFile = ZipFile.Read(_stream);
            _zipFile = ZipFile.Read(_stream, _readOptions);
            _uint    = Adler.Adler32(_uint, _bytes, _int, _int);
            _bytes   = DeflateStream.CompressBuffer(_bytes);
            _bytes   = DeflateStream.CompressString(_string);
            _bytes   = DeflateStream.UncompressBuffer(_bytes);
            _string  = DeflateStream.UncompressString(_bytes);
            _bytes   = GZipStream.CompressBuffer(_bytes);
            _bytes   = GZipStream.CompressString(_string);
            _bytes   = GZipStream.UncompressBuffer(_bytes);
            _string  = GZipStream.UncompressString(_bytes);
            _bytes   = ZlibStream.CompressBuffer(_bytes);
            _bytes   = ZlibStream.CompressString(_string);
            _bytes   = ZlibStream.UncompressBuffer(_bytes);
            _string  = ZlibStream.UncompressString(_bytes);
        }
Beispiel #16
0
 /// <summary>
 /// Unzips the file bytes
 /// </summary>
 public string UnzipString(byte[] compbytes)
 {
     return(ZlibStream.UncompressString(compbytes));
 }
 public static string UnCompressZlib(this byte[] source)
 {
     return(ZlibStream.UncompressString(source));
 }
Beispiel #18
0
        /// <summary>
        /// Decrypts a packet
        /// </summary>
        public static byte[] DecryptPacket(Packet p)
        {
            int packetID = p.ID;

            byte[] encryptedPayload = p.Payload;
            byte[] decryptedPayload;

            if (packetID == 10100 || packetID == 20100)
            {
                // Both Session (10100) and SessionOk (20100) packets are not encrypted
                // Thus.. just return the encrypted payload
                Logger.LogDecryptedPacket(packetID, encryptedPayload);
                return(encryptedPayload);
            }
            else if (packetID == 10101)
            {
                // The decrypted Login (10101) requires a nonce being calculated by the PK & the modded PK
                _10101_PublicKey = encryptedPayload.Take(32).ToArray();
                Blake2b.Init();
                Blake2b.Update(_10101_PublicKey);
                Blake2b.Update(Keys.ModdedPublicKey);
                var tmpNonce = Blake2b.Finish();

                // Decrypt the payload the custom NaCl
                decryptedPayload  = CustomNaCl.OpenPublicBox(encryptedPayload.Skip(32).ToArray(), tmpNonce, Keys.GeneratedPrivateKey, _10101_PublicKey);
                _10101_SessionKey = decryptedPayload.Take(24).ToArray();
                _10101_Nonce      = decryptedPayload.Skip(24).Take(24).ToArray();
                decryptedPayload  = decryptedPayload.Skip(48).ToArray();
                using (var reader = new PacketReader(new MemoryStream(decryptedPayload)))
                {
                    Logger.Log("Packet 10101 Content ->", LogType.PACKET);
                    Console.WriteLine("User ID                      -> " + reader.ReadInt64());
                    Console.WriteLine("User Token                   -> " + reader.ReadString());
                    Console.WriteLine("Major Version                -> " + reader.ReadInt32());
                    Console.WriteLine("Content Version              -> " + reader.ReadInt32());
                    Console.WriteLine("Minor Version                -> " + reader.ReadInt32());
                    Console.WriteLine("MasterHash                   -> " + reader.ReadString());
                    Console.WriteLine("Unknown1                     -> " + reader.ReadString());
                    Console.WriteLine("OpenUDID                     -> " + reader.ReadString());
                    Console.WriteLine("MacAddress                   -> " + reader.ReadString());
                    Console.WriteLine("DeviceModel                  -> " + reader.ReadString());
                    Console.WriteLine("LocaleKey                    -> " + reader.ReadInt32());
                    Console.WriteLine("Language                     -> " + reader.ReadString());
                    Console.WriteLine("AdvertisingGUID              -> " + reader.ReadString());
                    Console.WriteLine("OSVersion                    -> " + reader.ReadString());
                    Console.WriteLine("Unknown2                     -> " + reader.ReadByte());
                    Console.WriteLine("Unknown3                     -> " + reader.ReadString());
                    Console.WriteLine("AndroidDeviceID              -> " + reader.ReadString());
                    Console.WriteLine("FacebookDistributionID       -> " + reader.ReadString());
                    Console.WriteLine("IsAdvertisingTrackingEnabled -> " + reader.ReadBoolean());
                    Console.WriteLine("VendorGUID                   -> " + reader.ReadString());
                    Console.WriteLine("Seed                         -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown4                     -> " + reader.ReadByte());
                    Console.WriteLine("Unknown5                     -> " + reader.ReadString());
                    Console.WriteLine("Unknown6                     -> " + reader.ReadString());
                    Console.WriteLine("ClientVersion                -> " + reader.ReadString());
                }
            }
            else if (packetID == 14102)
            {
                _10101_Nonce.Increment();
                decryptedPayload = CustomNaCl.OpenSecretBox(new byte[16].Concat(encryptedPayload).ToArray(), _10101_Nonce, _20103_20104_SharedKey);
                using (var reader = new PacketReader(new MemoryStream(decryptedPayload)))
                {
                    Logger.Log("Packet 14102 Content ->", LogType.PACKET);
                    Console.WriteLine("Subtick                      -> " + reader.ReadUInt32WithEndian());
                    Console.WriteLine("Checksum                     -> " + reader.ReadUInt32WithEndian());
                    var commandammound = reader.ReadUInt32WithEndian();
                    Console.WriteLine("Command Ammount              -> " + commandammound);
                    if (commandammound > 0 && commandammound < 20)
                    {
                        Console.WriteLine("NestedCommands              -> " + Encoding.UTF8.GetString(reader.ReadBytes()));
                    }
                }
            }
            else if (packetID == 20103 || packetID == 20104)
            {
                // The decrypted LoginFailed / LoginOk (20103/20104) requires a nonce being calculated by the nonce from 10101, the custom PK & the original PK
                Blake2b.Init();
                Blake2b.Update(_10101_Nonce);
                Blake2b.Update(CustomKeyPair.PublicKey);
                Blake2b.Update(Keys.OriginalPublicKey);
                var tmpNonce = Blake2b.Finish();

                // Decrypt the payload with the custom NaCl
                decryptedPayload       = CustomNaCl.OpenPublicBox(encryptedPayload, tmpNonce, CustomKeyPair.SecretKey, Keys.OriginalPublicKey);
                _20103_20104_Nonce     = decryptedPayload.Take(24).ToArray();
                _20103_20104_SharedKey = decryptedPayload.Skip(24).Take(32).ToArray();
                decryptedPayload       = decryptedPayload.Skip(56).ToArray();
                if (packetID == 20104)
                {
                    using (var reader = new PacketReader(new MemoryStream(decryptedPayload)))
                    {
                        Logger.Log("Packet 20104 Content ->", LogType.PACKET);
                        Console.WriteLine("User ID 1                     -> " + reader.ReadInt64());
                        Console.WriteLine("User ID 2                     -> " + reader.ReadInt64());
                        Console.WriteLine("PassToken                     -> " + reader.ReadString());
                        Console.WriteLine("Facebook ID                   -> " + reader.ReadString());
                        Console.WriteLine("GameCenter ID                 -> " + reader.ReadString());
                    }
                }
                else
                {
                    using (var reader = new PacketReader(new MemoryStream(decryptedPayload)))
                    {
                        Logger.Log("Packet 20103 Content ->", LogType.PACKET);
                        Console.WriteLine("Error Code                    -> " + reader.ReadInt32());
                        Console.WriteLine("FingerPrint Data              -> " + reader.ReadString());
                    }
                }
            }
            else if (packetID == 24101)
            {
                _20103_20104_Nonce.Increment();
                decryptedPayload = CustomNaCl.OpenSecretBox(new byte[16].Concat(encryptedPayload).ToArray(), _20103_20104_Nonce, _20103_20104_SharedKey);
                using (var reader = new PacketReader(new MemoryStream(decryptedPayload)))
                {
                    Logger.Log("Packet 24101 Content ->", LogType.PACKET);
                    Console.WriteLine("Last Visit                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 1                     -> " + reader.ReadInt32());
                    Console.WriteLine("TimeStamp                     -> " + DateTimeConverter.FromUnixTimestamp(reader.ReadInt32()));
                    Console.WriteLine("Unknown 2                     -> " + reader.ReadInt32());
                    Console.WriteLine("User ID                       -> " + reader.ReadInt64());
                    Console.WriteLine("Shield Duration               -> " + TimeSpan.FromSeconds(reader.ReadInt32()));
                    Console.WriteLine("Unknown 3                     -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 4                     -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 5                     -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 6                     -> " + reader.ReadInt32());
                    Console.WriteLine("Compressed                    -> " + reader.ReadBoolean());
                    var homeData = reader.ReadBytes();
                    using (var br = new BinaryReader(new MemoryStream(homeData))) // little endian
                    {
                        var decompressedLength = br.ReadInt32();
                        var compressedHome     = br.ReadBytes(homeData.Length - 4); // -4 to remove the decompressedLength bytes read
                        Console.WriteLine("Compressed Home             -> " + Encoding.UTF8.GetString(compressedHome));
                        Console.WriteLine("Compressed Home Lenght      -> " + compressedHome.Length);
                        var homeJson = ZlibStream.UncompressString(compressedHome);
                        Console.WriteLine("Decompresssed Lenght        -> " + decompressedLength);
                        Console.WriteLine("Decompressed Home           -> " + homeJson);
                    }
                    Console.WriteLine("Unknown 7                     -> " + reader.ReadInt32());
                    Console.WriteLine("User ID                       -> " + reader.ReadInt64());
                    Console.WriteLine("User ID 2                     -> " + reader.ReadInt64());
                    var haveclan = reader.ReadBoolean();
                    Console.WriteLine("Have Clan                     -> " + haveclan);
                    if (haveclan)
                    {
                        Console.WriteLine("Clan ID                       -> " + reader.ReadInt64());
                        Console.WriteLine("Clan Name                     -> " + reader.ReadString());
                        Console.WriteLine("Clan Badge                    -> " + reader.ReadInt32());
                        Console.WriteLine("Clan Role                     -> " + reader.ReadInt32());
                        Console.WriteLine("Clan Level                    -> " + reader.ReadInt32());
                        Console.WriteLine("Unknown 8                     -> " + reader.ReadBoolean());
                    }
                    Console.WriteLine("Unknown 9                     -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 10                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 11                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 12                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 13                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 14                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 15                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 16                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 17                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 18                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 19                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 20                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 21                    -> " + reader.ReadInt32());
                    Console.WriteLine("League ID                     -> " + reader.ReadInt32());
                    Console.WriteLine("Alliance Castle Level         -> " + reader.ReadInt32());
                    Console.WriteLine("Alliance Castle Total Capacity-> " + reader.ReadInt32());
                    Console.WriteLine("Alliance Castle Used Capacity -> " + reader.ReadInt32());
                    Console.WriteLine("Town Hall Level               -> " + reader.ReadInt32());
                    Console.WriteLine("Name                          -> " + reader.ReadString());
                    Console.WriteLine("Facebook ID                   -> " + reader.ReadInt32());
                    Console.WriteLine("Level                         -> " + reader.ReadInt32());
                    Console.WriteLine("Experience                    -> " + reader.ReadInt32());
                    Console.WriteLine("Gems                          -> " + reader.ReadInt32());
                    Console.WriteLine("FreeGems                      -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 22                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 23                    -> " + reader.ReadInt32());
                    Console.WriteLine("Trophies                      -> " + reader.ReadInt32());
                    Console.WriteLine("Attack Won                    -> " + reader.ReadInt32());
                    Console.WriteLine("Attack Lost                   -> " + reader.ReadInt32());
                    Console.WriteLine("Defences Won                  -> " + reader.ReadInt32());
                    Console.WriteLine("Defences Lost                 -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 24                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 25                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 26                    -> " + reader.ReadInt32());
                    Console.WriteLine("Unknown 27                    -> " + reader.ReadByte());
                    Console.WriteLine("Unknown 28                    -> " + reader.ReadInt64());
                    Console.WriteLine("Name Set                      -> " + reader.ReadBoolean());
                }
            }
            else
            {
                if (p.Destination == DataDestination.DATA_FROM_CLIENT)
                {
                    _10101_Nonce.Increment();
                    decryptedPayload = CustomNaCl.OpenSecretBox(new byte[16].Concat(encryptedPayload).ToArray(), _10101_Nonce, _20103_20104_SharedKey);
                }
                else
                {
                    _20103_20104_Nonce.Increment();
                    decryptedPayload = CustomNaCl.OpenSecretBox(new byte[16].Concat(encryptedPayload).ToArray(), _20103_20104_Nonce, _20103_20104_SharedKey);
                }
            }
            Logger.LogDecryptedPacket(packetID, decryptedPayload);
            return(decryptedPayload);
        }
Beispiel #19
0
        private static void Uncompress(string _Hexa)
        {
            string Buffer = ZlibStream.UncompressString(_Hexa.HexaToBytes());

            Console.WriteLine("Uncompressed : " + Buffer);
        }
Beispiel #20
0
        public override void Encode()
        {
            var pack = new List <byte>();
            var data = new List <byte>();

            //data.AddRange(BitConverter.GetBytes(Player.GetPlayerAvatar().GetSecondsFromLastUpdate()).Reverse());
            data.AddRange(new byte[]
            {
                0x00, 0x00, 0x00, 0xF0,
                0xFF, 0xFF, 0xFF, 0xFF,
                0x54, 0xCE, 0x5C, 0x4A
            });

            var ch = new ClientHome(m_vOwnerLevel.GetPlayerAvatar().GetId());

            ch.SetShieldDurationSeconds(m_vOwnerLevel.GetPlayerAvatar().RemainingShieldTime);
            ch.SetHomeJSON(m_vOwnerLevel.SaveToJSON());

            data.AddRange(ch.Encode());
            data.AddRange(m_vOwnerLevel.GetPlayerAvatar().Encode());

            data.AddRange(m_vVisitorLevel.GetPlayerAvatar().Encode());

            data.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x03, 0x00 });

            SetData(data.ToArray());

            byte[] home2 =
            {
                /*0x00, 0x00, 0x03, 0x55, 0x25, 0x0F, 0x00, 0x00,*/ 0x78, 0x9C, 0x9D, 0x57, 0x4B, 0x6F, 0xE2,
                0x30,                                                     0x10, 0xFE, 0x2F, 0x39, 0x67, 0xA5, 0xD8, 0x4E, 0xC2, 0xE3, 0xB8, 0x5D, 0xED, 0x69, 0x4F, 0xDB,
                0xD5,                                                     0x5E, 0x2A, 0x64, 0x19, 0xE2, 0x42, 0xB4, 0xC6, 0x8E, 0x12, 0x07, 0x8A, 0xAA, 0xFE, 0xF7, 0x1D,
                0xC7,                                                     0x03, 0x24, 0x88, 0xAA, 0x36, 0x8D, 0x0A, 0xF8, 0xF1, 0x8D, 0xE7, 0xF1, 0xCD, 0x64, 0xFC, 0x9E,
                0x08,                                                     0x5D, 0xB5, 0xA6, 0xAE, 0xF8, 0x46, 0xD5, 0x52, 0xDB, 0x64, 0x69, 0xDB, 0x5E, 0xA6, 0x89, 0xD8,
                0xD8,                                                     0xFA, 0x20, 0xB9, 0x12, 0x27, 0xD3, 0xC3, 0x64, 0x96, 0x26, 0xFE, 0x27, 0xEF, 0xAC, 0xB0, 0x32,
                0x59,                                                     0xBE, 0x64, 0xE9, 0xE5, 0x59, 0xA5, 0xC9, 0xBA, 0xAF, 0x55, 0x55, 0xEB, 0x6D, 0x07, 0x2B, 0xEF,
                0x49,                                                     0x25, 0xAC, 0x48, 0x96, 0x24, 0x73, 0x7F, 0x04, 0x90, 0x07, 0x95, 0x2C, 0x69, 0x9A, 0xBC, 0xC1,
                0x27,                                                     0x0C, 0x4F, 0xF0, 0x05, 0xF2, 0x76, 0xCD, 0x20, 0xB6, 0x95, 0xDB, 0x64, 0xF9, 0x2A, 0x54, 0x27,
                0x3F,                                                     0xD2, 0x29, 0x32, 0x9F, 0x22, 0xB3, 0x01, 0x49, 0xCA, 0x3B, 0x48, 0xF7, 0xBB, 0xE3, 0xB6, 0xDE,
                0x83,                                                     0x62, 0xD9, 0xAD, 0x98, 0x0C, 0xC5, 0x64, 0x5E, 0x4C, 0xE9, 0xC5, 0x2C, 0xD2, 0xA4, 0xD7, 0xB5,
                0x75,                                                     0xFA, 0xBE, 0xE4, 0xB8, 0x8F, 0x66, 0x2B, 0x30, 0xA5, 0xB3, 0xA6, 0x15, 0x5B, 0xC9, 0xED, 0xA9,
                0x91,                                                     0x03, 0xEA, 0x2B, 0x45, 0x49, 0x31, 0x39, 0x81, 0xCC, 0x83, 0x4D, 0x24, 0xF9, 0x54, 0xB7, 0x62,
                0x40,                                                     0x32, 0x1A, 0xE0, 0x9C, 0xF9, 0x14, 0xC9, 0xBC, 0x55, 0x2C, 0x5A, 0x5B, 0x44, 0xD2, 0x3C, 0xE0,
                0x4C,                                                     0x8A, 0x48, 0x32, 0xB1, 0xB3, 0x88, 0x0D, 0x08, 0x43, 0x31, 0xF0, 0xBD, 0x31, 0xBA, 0xB3, 0xDC,
                0x3A,                                                     0xCD, 0x67, 0xD9, 0x65, 0xC8, 0xA5, 0xAE, 0x60, 0x2A, 0x67, 0x05, 0xCB, 0x19, 0x2D, 0xE8, 0xD8,
                0x39,                                                     0x41, 0x8A, 0x9E, 0x4D, 0x2C, 0x3C, 0x92, 0x7A, 0xE4, 0x3D, 0xE6, 0xDC, 0x22, 0xCB, 0x89, 0x89,
                0x67,                                                     0xB2, 0xDC, 0xE7, 0x9C, 0xE3, 0x0F, 0x6F, 0x5A, 0x03, 0xBA, 0xBE, 0xFB, 0x01, 0x52, 0xE6, 0xE3,
                0x0B,                                                     0x0A, 0x2E, 0xBC, 0xD4, 0xFC, 0x0E, 0x05, 0xD9, 0x43, 0x0C, 0xBC, 0x4D, 0x15, 0x64, 0xC3, 0x6C,
                0x1A,                                                     0x06, 0x90, 0x6C, 0xD6, 0x90, 0xBE, 0x1B, 0x25, 0xC7, 0x69, 0x3A, 0x1F, 0x24, 0xCC, 0x06, 0x64,
                0x71,                                                     0xA1, 0x91, 0x32, 0xC6, 0xF2, 0x7D, 0xAF, 0x6C, 0xDD, 0xA8, 0x13, 0x3F, 0xC8, 0x16, 0xA6, 0xAF,
                0xA7,                                                     0x8E, 0x31, 0x04, 0x03, 0xB3, 0x08, 0x03, 0x15, 0x63, 0x1F, 0xE4, 0x61, 0x98, 0x72, 0x7C, 0x10,
                0x9B,                                                     0x85, 0x81, 0xB2, 0x71, 0xD9, 0x08, 0x3C, 0xC8, 0x2B, 0xE7, 0x4E, 0x38, 0x79, 0x82, 0x87, 0xBB,
                0xA1,                                                     0x8C, 0x39, 0x87, 0x4D, 0xE8, 0x95, 0x45, 0x79, 0xCE, 0x1B, 0xC4, 0xCA, 0xA8, 0x93, 0xBC, 0xBB,
                0x59,                                                     0x94, 0x1B, 0x1E, 0x89, 0xEB, 0xFC, 0x01, 0x8B, 0x8A, 0x0B, 0x5B, 0x43, 0x30, 0x9E, 0xE2, 0xB9,
                0xB7,                                                     0x27, 0x90, 0xA8, 0x74, 0x6C, 0x0F, 0x89, 0xC1, 0x90, 0xEC, 0x52, 0x92, 0x43, 0x40, 0xBE, 0x6C,
                0x44,                                                     0x71, 0x1B, 0x8B, 0xA9, 0x4F, 0x59, 0x16, 0xA8, 0x9C, 0x07, 0x79, 0x9A, 0xB2, 0x22, 0x86, 0xA6,
                0xDE,                                                     0x71, 0x51, 0x31, 0x65, 0x58, 0x3F, 0x03, 0xD3, 0x01, 0x41, 0x79, 0x54, 0x29, 0x41, 0x2F, 0xE4,
                0x51,                                                     0x89, 0xE7, 0x41, 0xCC, 0xC7, 0x35, 0xCC, 0x0B, 0x04, 0x2B, 0x24, 0xF2, 0x27, 0x8C, 0xA7, 0x08,
                0x62,                                                     0x24, 0x86, 0xDC, 0x64, 0xD2, 0x6F, 0xB0, 0x30, 0x93, 0x10, 0x84, 0x7E, 0x08, 0x34, 0x89, 0x8D,
                0x1D,                                                     0x1E, 0x98, 0x12, 0x08, 0x42, 0xDA, 0x85, 0xD1, 0xC1, 0x69, 0x75, 0x4D, 0x89, 0xC0, 0x7C, 0x45,
                0x10,                                                     0x3A, 0x3C, 0x30, 0xC7, 0x7D, 0xBD, 0x67, 0xE5, 0xE5, 0xBD, 0x1D, 0x72, 0x10, 0x19, 0xBF, 0xFB,
                0x02,                                                     0x2B, 0xDD, 0x19, 0x94, 0x3F, 0xF2, 0x66, 0x89, 0x4B, 0xBF, 0x69, 0x8B, 0x17, 0x07, 0x2A, 0x63,
                0xD8,                                                     0x8A, 0x89, 0x7E, 0x76, 0x44, 0x54, 0xE5, 0xA2, 0xF3, 0x98, 0x32, 0x74, 0x8E, 0xED, 0x3C, 0xE6,
                0x45,                                                     0xC1, 0xB0, 0xB0, 0x7A, 0xCC, 0x7D, 0xED, 0xE8, 0xAD, 0x76, 0x8B, 0x71, 0x98, 0xC8, 0x67, 0x26,
                0x41,                                                     0x83, 0x53, 0xC9, 0x8D, 0x71, 0xCD, 0xCD, 0x6A, 0x68, 0x7D, 0x1A, 0x71, 0xD4, 0x7F, 0x45, 0xDB,
                0xB9,                                                     0x06, 0xAD, 0x83, 0x15, 0x5D, 0x75, 0x3F, 0x5B, 0xB3, 0xFF, 0x25, 0x3A, 0xFB, 0xDB, 0xAF, 0x02,
                0xF7,                                                     0xCB, 0x45, 0x71, 0xD9, 0xFC, 0x2C, 0x25, 0x74, 0x73, 0xDF, 0x08, 0x2B, 0x67, 0x19, 0x65, 0xAC,
                0x20,                                                     0xD7, 0x96, 0xE9, 0x49, 0x49, 0xD1, 0x3E, 0x99, 0x5E, 0x5B, 0x77, 0x18, 0x98, 0xEC, 0xDA, 0x2A,
                0x6E,                                                     0x0D, 0xDF, 0xCA, 0xFD, 0xDA, 0xBC, 0x71, 0xB8, 0x44, 0x35, 0xCE, 0xDD, 0x34, 0x9F, 0x53, 0x5C,
                0xAC,                                                     0xF5, 0x79, 0xB1, 0x91, 0x6D, 0x6D, 0x7C, 0x4F, 0x5B, 0x12, 0xF0, 0x08, 0x74, 0xBA, 0x46, 0x55,
                0xE6,                                                     0xA8, 0x51, 0x57, 0x2D, 0x8F, 0xCF, 0x3B, 0xD3, 0x7C, 0x1F, 0xDD, 0xA2, 0x28, 0xDC, 0xAC, 0x58,
                0x4A,                                                     0x87, 0x7F, 0x9A, 0x92, 0x94, 0x5E, 0xEF, 0x5B, 0x30, 0x2A, 0x46, 0xA3, 0x9B, 0xE7, 0x2A, 0xEE,
                0x4F,                                                     0x2B, 0x9A, 0x6E, 0x7A, 0x55, 0xBB, 0xDD, 0xF2, 0x03, 0xFD, 0x45, 0xD2, 0x1C, 0x25, 0x7F, 0x2A,
                0x37,                                                     0xEC, 0x59, 0xB9, 0x8B, 0x22, 0x34, 0xF1, 0xE0, 0xAD, 0x6D, 0x2F, 0x79, 0x2B, 0xF4, 0x3F, 0xBC,
                0x3D,                                                     0xC2, 0xA4, 0x50, 0xAA, 0x16, 0x7A, 0x03, 0xD7, 0x4A, 0x79, 0x90, 0xCA, 0xBF, 0x22, 0x47, 0x9B,
                0xBB,                                                     0x5D, 0xFF, 0xFA, 0xAA, 0xE4, 0x75, 0x3F, 0x28, 0xD9, 0xF1, 0x4E, 0x4A, 0xED, 0xAA, 0x0E, 0x44,
                0x49,                                                     0x56, 0xD0, 0x64, 0xEF, 0x4D, 0xE5, 0xB6, 0x1A, 0x17, 0x3C, 0xEC, 0xC4, 0x8F, 0xA2, 0xE5, 0xB6,
                0x87,                                                     0xAE, 0xB9, 0x86, 0x31, 0x02, 0x32, 0x3F, 0xBD, 0x16, 0x9D, 0xBC, 0xEC, 0xDB, 0x49, 0xD5, 0x70,
                0xD3,                                                     0x48, 0xED, 0xA2, 0x8C, 0x73, 0x6B, 0x88, 0x04, 0x5E, 0x73, 0xF9, 0x20, 0x7F, 0x10, 0xCD, 0x65,
                0x7B,                                                     0x05, 0x7E, 0xFC, 0x07, 0xCA, 0xF2, 0x7C, 0x89
            };
            Debugger.WriteLine(ZlibStream.UncompressString(home2), null, 5);
            ;
        }