Ejemplo n.º 1
0
        public void OnClientPingConfig()
        {
            try
            {
                PayloadWriter pWriter = new PayloadWriter();

                byte[] plContent = { 0x00, 0x00, 0x0F, 0xA0, 0x00, 0x00, 0x0F, 0xA0, 0x00, 0x00, 0x0F, 0xA0,
                                     0x00, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00 };
                pWriter.WriteData(plContent);

                OutPacket oPacket = new OutPacket(pWriter.GetPayload(CenterOpcodes.ENU_CLIENT_PING_CONFIG_ACK), _CryptoHandler,
                                                  _AuthHandler, Prefix, ++Count);

                Send(oPacket);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Close();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates a request packet.
        /// </summary>
        /// <returns></returns>
        public DiffieHellman GenerateRequest()
        {
            // Generate the parameters.
            prime = BigInteger.genPseudoPrime(bits, 30, random);
            mine  = BigInteger.genPseudoPrime(bits, 30, random);
            g     = BigInteger.genPseudoPrime(bits, 30, random);

            // Gemerate the string.
            PayloadWriter pw = new PayloadWriter();

            pw.WriteBigInteger(prime);
            pw.WriteBigInteger(g);

            // Generate the send BigInt.
            using (BigInteger send = g.modPow(mine, prime))
            {
                pw.WriteBigInteger(send);
            }
            representation = pw.ToByteArray();
            return(this);
        }
Ejemplo n.º 3
0
        public byte[] Encrypt(byte[] Data, int Offset, int Length)
        {
            lock (AES)
            {
                byte[] NewIV = new byte[16];
                Frandom.NextBytes(NewIV);
                this.IV = NewIV;

                //mask the IV to make it harder to grab the IV while packet sniffing / MITM
                IvConfuser.Obfuscate(ref NewIV, 0);

                using (ICryptoTransform Encryptor = AES.CreateEncryptor())
                {
                    using (PayloadWriter pw = new PayloadWriter(new System.IO.MemoryStream()))
                    {
                        pw.WriteBytes(NewIV);
                        pw.WriteBytes(Encryptor.TransformFinalBlock(Data, Offset, Length));
                        return(pw.ToByteArray());
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void NotifySHAFile(ClientSession cs)
        {
            try
            {
                PayloadWriter pWriter = new PayloadWriter();
                pWriter.WriteData(0);
                pWriter.WriteData(SHAFileList.Length);

                for (int i = 0; i <= SHAFileList.Length - 1; i++)
                {
                    pWriter.WriteData(SHAFileList[i].Length * 2);
                    pWriter.WriteData(SHAFileList[i]);
                }

                OutPacket oPacket = new OutPacket(pWriter.GetPayload(CenterOpcodes.ENU_SHAFILENAME_LIST_ACK), cs._CryptoHandler,
                                                  cs._AuthHandler, cs.Prefix, ++cs.Count);

                cs.Send(oPacket);
            }
            catch
            {
            }
        }
Ejemplo n.º 5
0
        public void OnGuideBookList(ClientSession cs)
        {
            try
            {
                PayloadWriter pWritter = new PayloadWriter();

                byte[] plContent = { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 };
                pWritter.WriteData(plContent);

                OutPacket oPacket = new OutPacket(pWritter.GetCompressedPayload(CenterOpcodes.ENU_GUIDE_BOOK_LIST_ACK),
                                                  cs._CryptoHandler, cs._AuthHandler, cs.Prefix, ++cs.Count);

                cs.Send(oPacket);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                while (true)
                {
                    ;
                }
            }
        }
Ejemplo n.º 6
0
        public void SendCashbackRatio(ClientSession cs)
        {
            try
            {
                PayloadWriter pWritter = new PayloadWriter();

                byte[] plContent = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                pWritter.WriteData(plContent);

                OutPacket oPacket = new OutPacket(pWritter.GetCompressedPayload(CenterOpcodes.ENU_CASHBACK_RATIO_INFO_NOT),
                                                  cs._CryptoHandler, cs._AuthHandler, cs.Prefix, ++cs.Count);

                cs.Send(oPacket);
            }
            catch (Exception ex)
            {
                Log.Error("SendCashbackRatio: {0}", ex.Message);
                while (true)
                {
                    ;
                }
            }
        }
Ejemplo n.º 7
0
        public void SendSocketTableInfo(ClientSession cs)
        {
            try
            {
                PayloadWriter pWritter = new PayloadWriter();

                byte[] plContent = Util.StringToByteArray("00 00 00 65 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 01 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 02 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 03 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 04 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 05 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 08 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 09 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 0A 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 0B 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 0C 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 0D 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 0E 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 0F 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 10 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 11 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 12 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 13 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 14 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 15 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 16 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 17 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 18 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 0C 00 00 00 19 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 0C 00 00 00 1A 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 0C 00 00 00 1B 00 00 00 0A 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 1C 00 00 00 0A 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 1D 00 00 00 0A 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 1E 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 1F 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 20 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 21 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 22 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 23 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 24 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 25 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 26 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 27 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 28 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 29 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 2A 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 2B 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 2C 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 2D 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00 2E 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00 2F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00 30 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00 14 00 00 00 31 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00 14 00 00 00 32 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00 14 00 00 00 33 00 00 00 12 00 00 00 13 00 00 00 14 00 00 00 15 00 00 00 34 00 00 00 12 00 00 00 13 00 00 00 14 00 00 00 15 00 00 00 35 00 00 00 12 00 00 00 13 00 00 00 14 00 00 00 15 00 00 00 36 00 00 00 13 00 00 00 14 00 00 00 15 00 00 00 16 00 00 00 37 00 00 00 13 00 00 00 14 00 00 00 15 00 00 00 16 00 00 00 38 00 00 00 13 00 00 00 14 00 00 00 15 00 00 00 16 00 00 00 39 00 00 00 14 00 00 00 15 00 00 00 16 00 00 00 17 00 00 00 3A 00 00 00 14 00 00 00 15 00 00 00 16 00 00 00 17 00 00 00 3B 00 00 00 14 00 00 00 15 00 00 00 16 00 00 00 17 00 00 00 3C 00 00 00 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 3D 00 00 00 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 3E 00 00 00 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 3F 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 40 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 41 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 42 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 43 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 44 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 45 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 46 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 47 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 48 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 49 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 4A 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 4B 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 4C 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 4D 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 4E 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1E 00 00 00 4F 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1E 00 00 00 50 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1E 00 00 00 51 00 00 00 1C 00 00 00 1D 00 00 00 1E 00 00 00 1F 00 00 00 52 00 00 00 1C 00 00 00 1D 00 00 00 1E 00 00 00 1F 00 00 00 53 00 00 00 1C 00 00 00 1D 00 00 00 1E 00 00 00 1F 00 00 00 54 00 00 00 1D 00 00 00 1E 00 00 00 1F 00 00 00 20 00 00 00 55 00 00 00 1D 00 00 00 1E 00 00 00 1F 00 00 00 20 00 00 00 56 00 00 00 1D 00 00 00 1E 00 00 00 1F 00 00 00 20 00 00 00 57 00 00 00 1E 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 58 00 00 00 1E 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 59 00 00 00 1E 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 5A 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 22 00 00 00 5B 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 22 00 00 00 5C 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 22 00 00 00 5D 00 00 00 20 00 00 00 21 00 00 00 22 00 00 00 23 00 00 00 5E 00 00 00 20 00 00 00 21 00 00 00 22 00 00 00 23 00 00 00 5F 00 00 00 20 00 00 00 21 00 00 00 22 00 00 00 23 00 00 00 60 00 00 00 21 00 00 00 22 00 00 00 23 00 00 00 24 00 00 00 61 00 00 00 21 00 00 00 22 00 00 00 23 00 00 00 24 00 00 00 62 00 00 00 21 00 00 00 22 00 00 00 23 00 00 00 24 00 00 00 63 00 00 00 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 64 00 00 00 22 00 00 00 23 00 00 00 24 00 00 00 25 00 00 00 65 00 00 00 00 00 00 00 BE 00 00 00 FA 00 00 01 4A 00 00 01 D6 00 00 00 01 00 00 00 BE 00 00 00 FA 00 00 01 4A 00 00 01 D6 00 00 00 02 00 00 00 BE 00 00 00 FA 00 00 01 4A 00 00 01 D6 00 00 00 03 00 00 00 FA 00 00 01 4A 00 00 01 D6 00 00 03 52 00 00 00 04 00 00 00 FA 00 00 01 4A 00 00 01 D6 00 00 03 52 00 00 00 05 00 00 00 FA 00 00 01 4A 00 00 01 D6 00 00 03 52 00 00 00 06 00 00 01 4A 00 00 01 D6 00 00 03 52 00 00 08 98 00 00 00 07 00 00 01 4A 00 00 01 D6 00 00 03 52 00 00 08 98 00 00 00 08 00 00 01 4A 00 00 01 D6 00 00 03 52 00 00 08 98 00 00 00 09 00 00 01 D6 00 00 03 52 00 00 08 98 00 00 0E 74 00 00 00 0A 00 00 01 D6 00 00 03 52 00 00 08 98 00 00 0E 74 00 00 00 0B 00 00 01 D6 00 00 03 52 00 00 08 98 00 00 0E 74 00 00 00 0C 00 00 03 52 00 00 08 98 00 00 0E 74 00 00 17 0C 00 00 00 0D 00 00 03 52 00 00 08 98 00 00 0E 74 00 00 17 0C 00 00 00 0E 00 00 03 52 00 00 08 98 00 00 0E 74 00 00 17 0C 00 00 00 0F 00 00 08 98 00 00 0E 74 00 00 17 0C 00 00 22 C4 00 00 00 10 00 00 08 98 00 00 0E 74 00 00 17 0C 00 00 22 C4 00 00 00 11 00 00 08 98 00 00 0E 74 00 00 17 0C 00 00 22 C4 00 00 00 12 00 00 0E 74 00 00 17 0C 00 00 22 C4 00 00 31 9C 00 00 00 13 00 00 0E 74 00 00 17 0C 00 00 22 C4 00 00 31 9C 00 00 00 14 00 00 0E 74 00 00 17 0C 00 00 22 C4 00 00 31 9C 00 00 00 15 00 00 17 0C 00 00 22 C4 00 00 31 9C 00 00 55 F0 00 00 00 16 00 00 17 0C 00 00 22 C4 00 00 31 9C 00 00 55 F0 00 00 00 17 00 00 17 0C 00 00 22 C4 00 00 31 9C 00 00 55 F0 00 00 00 18 00 00 22 C4 00 00 31 9C 00 00 55 F0 00 00 6C 98 00 00 00 19 00 00 22 C4 00 00 31 9C 00 00 55 F0 00 00 6C 98 00 00 00 1A 00 00 22 C4 00 00 31 9C 00 00 55 F0 00 00 6C 98 00 00 00 1B 00 00 31 9C 00 00 55 F0 00 00 6C 98 00 00 84 08 00 00 00 1C 00 00 31 9C 00 00 55 F0 00 00 6C 98 00 00 84 08 00 00 00 1D 00 00 31 9C 00 00 55 F0 00 00 6C 98 00 00 84 08 00 00 00 1E 00 00 55 F0 00 00 6C 98 00 00 84 08 00 00 9C 40 00 00 00 1F 00 00 55 F0 00 00 6C 98 00 00 84 08 00 00 9C 40 00 00 00 20 00 00 55 F0 00 00 6C 98 00 00 84 08 00 00 9C 40 00 00 00 21 00 00 6C 98 00 00 84 08 00 00 9C 40 00 00 B9 28 00 00 00 22 00 00 6C 98 00 00 84 08 00 00 9C 40 00 00 B9 28 00 00 00 23 00 00 6C 98 00 00 84 08 00 00 9C 40 00 00 B9 28 00 00 00 24 00 00 84 08 00 00 9C 40 00 00 B9 28 00 00 D8 CC 00 00 00 25 00 00 84 08 00 00 9C 40 00 00 B9 28 00 00 D8 CC 00 00 00 26 00 00 84 08 00 00 9C 40 00 00 B9 28 00 00 D8 CC 00 00 00 27 00 00 9C 40 00 00 B9 28 00 00 D8 CC 00 00 F8 70 00 00 00 28 00 00 9C 40 00 00 B9 28 00 00 D8 CC 00 00 F8 70 00 00 00 29 00 00 9C 40 00 00 B9 28 00 00 D8 CC 00 00 F8 70 00 00 00 2A 00 00 B9 28 00 00 D8 CC 00 00 F8 70 00 01 1D 28 00 00 00 2B 00 00 B9 28 00 00 D8 CC 00 00 F8 70 00 01 1D 28 00 00 00 2C 00 00 B9 28 00 00 D8 CC 00 00 F8 70 00 01 1D 28 00 00 00 2D 00 00 D8 CC 00 00 F8 70 00 01 1D 28 00 01 47 58 00 00 00 2E 00 00 D8 CC 00 00 F8 70 00 01 1D 28 00 01 47 58 00 00 00 2F 00 00 D8 CC 00 00 F8 70 00 01 1D 28 00 01 47 58 00 00 00 30 00 00 F8 70 00 01 1D 28 00 01 47 58 00 01 7D 40 00 00 00 31 00 00 F8 70 00 01 1D 28 00 01 47 58 00 01 7D 40 00 00 00 32 00 00 F8 70 00 01 1D 28 00 01 47 58 00 01 7D 40 00 00 00 33 00 01 1D 28 00 01 47 58 00 01 7D 40 00 01 B7 74 00 00 00 34 00 01 1D 28 00 01 47 58 00 01 7D 40 00 01 B7 74 00 00 00 35 00 01 1D 28 00 01 47 58 00 01 7D 40 00 01 B7 74 00 00 00 36 00 01 47 58 00 01 7D 40 00 01 B7 74 00 02 00 E4 00 00 00 37 00 01 47 58 00 01 7D 40 00 01 B7 74 00 02 00 E4 00 00 00 38 00 01 47 58 00 01 7D 40 00 01 B7 74 00 02 00 E4 00 00 00 39 00 01 7D 40 00 01 B7 74 00 02 00 E4 00 02 50 F8 00 00 00 3A 00 01 7D 40 00 01 B7 74 00 02 00 E4 00 02 50 F8 00 00 00 3B 00 01 7D 40 00 01 B7 74 00 02 00 E4 00 02 50 F8 00 00 00 3C 00 01 B7 74 00 02 00 E4 00 02 50 F8 00 02 AC C4 00 00 00 3D 00 01 B7 74 00 02 00 E4 00 02 50 F8 00 02 AC C4 00 00 00 3E 00 01 B7 74 00 02 00 E4 00 02 50 F8 00 02 AC C4 00 00 00 3F 00 02 00 E4 00 02 50 F8 00 02 AC C4 00 03 15 10 00 00 00 40 00 02 00 E4 00 02 50 F8 00 02 AC C4 00 03 15 10 00 00 00 41 00 02 00 E4 00 02 50 F8 00 02 AC C4 00 03 15 10 00 00 00 42 00 02 50 F8 00 02 AC C4 00 03 15 10 00 03 BB 78 00 00 00 43 00 02 50 F8 00 02 AC C4 00 03 15 10 00 03 BB 78 00 00 00 44 00 02 50 F8 00 02 AC C4 00 03 15 10 00 03 BB 78 00 00 00 45 00 02 AC C4 00 03 15 10 00 03 BB 78 00 04 27 48 00 00 00 46 00 02 AC C4 00 03 15 10 00 03 BB 78 00 04 27 48 00 00 00 47 00 02 AC C4 00 03 15 10 00 03 BB 78 00 04 27 48 00 00 00 48 00 03 15 10 00 03 BB 78 00 04 27 48 00 04 AC E0 00 00 00 49 00 03 15 10 00 03 BB 78 00 04 27 48 00 04 AC E0 00 00 00 4A 00 03 15 10 00 03 BB 78 00 04 27 48 00 04 AC E0 00 00 00 4B 00 03 BB 78 00 04 27 48 00 04 AC E0 00 05 32 78 00 00 00 4C 00 03 BB 78 00 04 27 48 00 04 AC E0 00 05 32 78 00 00 00 4D 00 03 BB 78 00 04 27 48 00 04 AC E0 00 05 32 78 00 00 00 4E 00 04 27 48 00 04 AC E0 00 05 32 78 00 05 B8 10 00 00 00 4F 00 04 27 48 00 04 AC E0 00 05 32 78 00 05 B8 10 00 00 00 50 00 04 27 48 00 04 AC E0 00 05 32 78 00 05 B8 10 00 00 00 51 00 04 AC E0 00 05 32 78 00 05 B8 10 00 06 3D A8 00 00 00 52 00 04 AC E0 00 05 32 78 00 05 B8 10 00 06 3D A8 00 00 00 53 00 04 AC E0 00 05 32 78 00 05 B8 10 00 06 3D A8 00 00 00 54 00 05 32 78 00 05 B8 10 00 06 3D A8 00 06 C3 40 00 00 00 55 00 05 32 78 00 05 B8 10 00 06 3D A8 00 06 C3 40 00 00 00 56 00 05 32 78 00 05 B8 10 00 06 3D A8 00 06 C3 40 00 00 00 57 00 05 B8 10 00 06 3D A8 00 06 C3 40 00 07 48 74 00 00 00 58 00 05 B8 10 00 06 3D A8 00 06 C3 40 00 07 48 74 00 00 00 59 00 05 B8 10 00 06 3D A8 00 06 C3 40 00 07 48 74 00 00 00 5A 00 06 3D A8 00 06 C3 40 00 07 48 74 00 07 CE 0C 00 00 00 5B 00 06 3D A8 00 06 C3 40 00 07 48 74 00 07 CE 0C 00 00 00 5C 00 06 3D A8 00 06 C3 40 00 07 48 74 00 07 CE 0C 00 00 00 5D 00 06 C3 40 00 07 48 74 00 07 CE 0C 00 08 53 A4 00 00 00 5E 00 06 C3 40 00 07 48 74 00 07 CE 0C 00 08 53 A4 00 00 00 5F 00 06 C3 40 00 07 48 74 00 07 CE 0C 00 08 53 A4 00 00 00 60 00 07 48 74 00 07 CE 0C 00 08 53 A4 00 08 D9 3C 00 00 00 61 00 07 48 74 00 07 CE 0C 00 08 53 A4 00 08 D9 3C 00 00 00 62 00 07 48 74 00 07 CE 0C 00 08 53 A4 00 08 D9 3C 00 00 00 63 00 07 CE 0C 00 08 53 A4 00 08 D9 3C 00 09 5E D4 00 00 00 64 00 07 CE 0C 00 08 53 A4 00 08 D9 3C 00 09 5E D4 00 04 61 54");
                pWritter.WriteData(plContent);

                OutPacket oPacket = new OutPacket(pWritter.GetCompressedPayload(CenterOpcodes.ENU_SOCKET_TABLE_INFO_NOT),
                                                  cs._CryptoHandler, cs._AuthHandler, cs.Prefix, ++cs.Count);

                cs.Send(oPacket);
            }
            catch (Exception ex)
            {
                Log.Error("SendSocketTableInfo: {0}", ex.Message);
                while (true)
                {
                    ;
                }
            }
        }
Ejemplo n.º 8
0
        public void SendClientContentOpen(ClientSession cs)
        {
            try
            {
                PayloadWriter pWritter = new PayloadWriter();

                byte[] plContent = Util.StringToByteArray("00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 09 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 09 00 00 00 01 00 00 00 01 00 00 00 0A 00 00 00 01 00 00 00 01 00 00 00 0E 00 00 00 01 00 00 00 01 00 00 00 12 00 00 00 01 00 00 00 01 00 00 00 14 00 00 00 01 00 00 00 01 00 00 00 02 00 00 00 01 00 00 00 03 00 00 00 03 00 00 00 01 00 00 00 00 00 00 00 15 00 00 00 01 00 00 00 0D 00 00 00 08 00 00 00 00 00 00 00 02 00 00 00 01 00 00 00 02 00 00 00 01 00 00 00 01 00 00 00 05 00 00 00 03 00 00 00 01 00 00 00 06 00 00 00 04 00 00 00 01 00 00 00 00 00 00 00 05 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 02 00 00 00 42 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00 14 00 00 00 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1E 00 00 00 24 00 00 00 27 00 00 00 28 00 00 00 29 00 00 00 2A 00 00 00 2B 00 00 00 2C 00 00 00 2D 00 00 00 2E 00 00 00 2F 00 00 00 30 00 00 00 31 00 00 00 32 00 00 00 37 00 00 00 38 00 00 00 39 00 00 00 3A 00 00 00 3B 00 00 00 3C 00 00 00 3D 00 00 00 3E 00 00 00 3F 00 00 00 40 00 00 00 46 00 00 00 49 00 00 00 4A 00 00 00 4C 00 00 00 4E 00 00 00 4F 00 00 00 50 00 00 00 51 00 00 00 53 00 00 00 54 00 00 00 55 00 00 00 56 00 00 00 57 00 00 00 58 00 00 00 59 00 00 00 5A 00 00 00 5B 00 00 00 5C 00 00 00 5D 00 00 00 5E 00 00 00 5F 00 00 00 0B 00 00 00 01 00 00 00 26 00 00 00 0D 00 00 00 01 00 00 00 42 00 00 00 06 00 00 00 04 00 00 00 00 01 00 00 00 63 00 00 00 00 01 00 00 00 10 00 00 00 63 00 00 00 64 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 2B 00 00 00 2F 00 00 00 01 01 00 00 00 0E 00 00 00 0A 00 00 00 63 00 00 00 64 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 09 00 00 00 04 00 00 00 06 00 00 00 05 00 00 00 08 00 00 00 07 00 00 00 0B 00 00 00 05 01 00 00 00 10 00 00 00 63 00 00 00 64 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 2B 00 00 00 2F 00 00 00 03 01 00 00 00 09 00 00 00 63 00 00 00 64 00 00 00 00 00 00 00 01 00 00 00 09 00 00 00 0B 00 00 00 02 00 00 00 0A 00 00 00 04 00 00 00 0B 00 00 00 00 10 00 00 00 63 00 00 00 64 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 2B 00 00 00 2F 00 00 00 06 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 55 00 00 00 13 00 00 00 00 00 00 00 04 00 01 02 03 00 00 00 01 00 00 00 04 00 01 02 03 00 00 00 02 00 00 00 04 00 01 02 03 00 00 00 03 00 00 00 04 00 01 02 03 00 00 00 04 00 00 00 04 00 01 02 03 00 00 00 05 00 00 00 04 00 01 02 03 00 00 00 06 00 00 00 04 00 01 02 03 00 00 00 07 00 00 00 04 00 01 02 03 00 00 00 08 00 00 00 04 00 01 02 03 00 00 00 09 00 00 00 04 00 01 02 03 00 00 00 0A 00 00 00 04 00 01 02 03 00 00 00 0B 00 00 00 04 00 01 02 03 00 00 00 0C 00 00 00 04 00 01 02 03 00 00 00 0D 00 00 00 04 00 01 02 03 00 00 00 0E 00 00 00 04 00 01 02 03 00 00 00 0F 00 00 00 02 00 01 00 00 00 10 00 00 00 02 00 01 00 00 00 11 00 00 00 02 00 01 00 00 00 12 00 00 00 01 00 00 00 00 13 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00 00 00 00 00 02 00 00 00 01 00 00 00 02 00 00 00 02 00 00 00 02 00 00 00 03 00 00 00 01 00 00 00 04 00 00 00 01 00 00 00 05 00 00 00 01 00 00 00 06 00 00 00 01 00 00 00 07 00 00 00 01 00 00 00 08 00 00 00 01 00 00 00 09 00 00 00 01 00 00 00 0A 00 00 00 01 00 00 00 0B 00 00 00 01 00 00 00 0C 00 00 00 01 00 00 00 0D 00 00 00 01 00 00 00 0E 00 00 00 00 00 00 00 0F 00 00 00 01 00 00 00 10 00 00 00 01 00 00 00 11 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 12 00 00 00 00 00 01 83 3F 00 00 00 01 00 01 83 40 00 00 00 02 00 01 83 41 00 00 00 03 00 01 83 42 00 00 00 04 00 01 83 43 00 00 00 05 00 01 83 44 00 00 00 06 00 01 83 45 00 00 00 07 00 01 83 46 00 00 00 08 00 01 83 47 00 00 00 09 00 01 83 48 00 00 00 0A 00 01 83 49 00 00 00 0B 00 01 83 4A 00 00 00 0C 00 01 83 4B 00 00 00 0D 00 01 83 4C 00 00 00 0E 00 01 83 4D 00 00 00 0F 00 01 83 4E 00 00 00 10 00 01 83 4F 00 00 00 11 00 01 E3 32 00 00 00 43 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0A 00 00 00 0B 00 00 00 0C 00 00 00 0D 00 00 00 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00 12 00 00 00 13 00 00 00 14 00 00 00 15 00 00 00 16 00 00 00 17 00 00 00 18 00 00 00 19 00 00 00 1A 00 00 00 1B 00 00 00 1C 00 00 00 1D 00 00 00 1E 00 00 00 1F 00 00 00 20 00 00 00 21 00 00 00 22 00 00 00 23 00 00 00 24 00 00 00 26 00 00 00 27 00 00 00 28 00 00 00 29 00 00 00 2A 00 00 00 2B 00 00 00 2C 00 00 00 2D 00 00 00 2E 00 00 00 2F 00 00 00 30 00 00 00 31 00 00 00 32 00 00 00 33 00 00 00 34 00 00 00 39 00 00 00 3A 00 00 00 3B 00 00 00 3C 00 00 00 3D 00 00 00 3E 00 00 00 3F 00 00 00 40 00 00 00 41 00 00 00 42 00 00 00 43 00 00 00 44 00 00 00 45 00 00 00 46 00 00 00 47 00 00 00 02 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 13 00 00 00 18 00 00 00 03 00 00 22 56 00 00 00 8E 00 00 00 3C 74 00 65 00 78 00 5F 00 67 00 63 00 5F 00 6D 00 62 00 6F 00 78 00 5F 00 67 00 61 00 77 00 69 00 62 00 61 00 77 00 69 00 62 00 6F 00 5F 00 64 00 6C 00 67 00 2E 00 64 00 64 00 73 00 00 00 00 01 00 06 4E F6 00 00 25 40 00 00 00 B3 00 00 00 36 74 00 65 00 78 00 5F 00 67 00 63 00 5F 00 6D 00 62 00 6F 00 78 00 5F 00 66 00 72 00 69 00 65 00 6E 00 64 00 5F 00 67 00 69 00 66 00 74 00 2E 00 64 00 64 00 73 00 00 00 00 01 00 0C C5 D8 00 00 27 D2 00 00 00 BF 00 00 00 38 74 00 65 00 78 00 5F 00 67 00 63 00 5F 00 6D 00 62 00 6F 00 78 00 5F 00 73 00 6F 00 6E 00 67 00 6B 00 72 00 61 00 6E 00 5F 00 64 00 6C 00 67 00 2E 00 64 00 64 00 73 00 00 00 00 01 00 0D 5E 44");
                pWritter.WriteData(plContent);

                OutPacket oPacket = new OutPacket(pWritter.GetCompressedPayload(CenterOpcodes.ENU_NEW_CLIENT_CONTENTS_OPEN_NOT),
                                                  cs._CryptoHandler, cs._AuthHandler, cs.Prefix, ++cs.Count);

                cs.Send(oPacket);
            }
            catch (Exception ex)
            {
                Log.Error("SendClientContent: {0}", ex.Message);
                while (true)
                {
                    ;
                }
            }
        }
Ejemplo n.º 9
0
        public void SendChannelNews(ClientSession cs)
        {
            try
            {
                PayloadWriter pWritter = new PayloadWriter();

                byte[] plContent = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
                pWritter.WriteData(plContent);

                OutPacket oPacket = new OutPacket(pWritter.GetPayload(CenterOpcodes.ENU_CHANNEL_NEWS_NOT),
                                                  cs._CryptoHandler, cs._AuthHandler, cs.Prefix, ++cs.Count);

                cs.Send(oPacket);
            }
            catch (Exception ex)
            {
                Log.Error("ChannelNews: {0}", ex.Message);
                while (true)
                {
                    ;
                }
            }
        }
Ejemplo n.º 10
0
        private void HandleGetUserInfo(GetUserInfo payload, PayloadWriter writer)
        {
            uint accountId = payload.UserId;

            if (accountId != Account.Id)
            {
                StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>();
                resultPayload1.Errorcode = 1;
                resultPayload1.Errormsg  = "Incorrect account";
                resultPayload1.TicketId  = payload.TicketId;
                SendReply(writer, resultPayload1);
                return;
            }

            SendUserInfo resultPayload2 = Payloads.CreatePayload <SendUserInfo>();

            resultPayload2.UserId      = accountId;
            resultPayload2.Name        = Account.UserName;
            resultPayload2.Password    = null;
            resultPayload2.Mail        = Account.Email;
            resultPayload2.Banned      = false;
            resultPayload2.Active      = true;
            resultPayload2.Status      = 2;
            resultPayload2.Data        = Account.UserData;
            resultPayload2.Created     = "2012-04-02 00:00:00+0:00";
            resultPayload2.LastLogin   = "******";
            resultPayload2.TotalLogins = 1;
            resultPayload2.TicketId    = payload.TicketId;
            SendReply(writer, resultPayload2);

            StatusMsg resultPayload3 = Payloads.CreatePayload <StatusMsg>();

            resultPayload3.Errorcode = 0;
            resultPayload3.Errormsg  = null;
            resultPayload3.TicketId  = payload.TicketId;
            SendReply(writer, resultPayload3);
        }
Ejemplo n.º 11
0
        private void HandleSelectNickname(SelectNickname payload, PayloadWriter writer)
        {
            uint playerId = payload.CharId;

            if (playerId != Account.Id)
            {
                StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>();
                resultPayload1.Errorcode = 1;
                resultPayload1.Errormsg  = "Incorrect account";
                resultPayload1.TicketId  = payload.TicketId;
                SendReply(writer, resultPayload1);
                return;
            }

            SelectNicknameReply resultPayload2 = Payloads.CreatePayload <SelectNicknameReply>();

            resultPayload2.CharId     = Account.Id;
            resultPayload2.Name       = Account.PlayerName;
            resultPayload2.OwnerId    = Account.Id;
            resultPayload2.OwnerName  = Account.UserName;
            resultPayload2.GuildId    = 0;
            resultPayload2.GuildName  = null;
            resultPayload2.GuildRole  = 0;
            resultPayload2.Status     = 1;
            resultPayload2.ServerId   = 0;
            resultPayload2.ServerName = null;
            resultPayload2.Data       = _nicknameData;
            resultPayload2.TicketId   = payload.TicketId;
            SendReply(writer, resultPayload2);

            StatusMsg resultPayload3 = Payloads.CreatePayload <StatusMsg>();

            resultPayload3.Errorcode = 0;
            resultPayload3.Errormsg  = null;
            resultPayload3.TicketId  = payload.TicketId;
            SendReply(writer, resultPayload3);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Return a random outpoint and a random payload.
        /// </summary>
        private (Outpoint, Memory <byte>) MakeRandomRawTxo(int lowLimit, int upLimit)
        {
            var content = new byte[Outpoint.TotalSizeInBytes].AsMemory();
            var temp    = new byte[Outpoint.KeySizeInBytes - 4];

            _rand.NextBytes(temp);
            temp.CopyTo(content);

            var index = _rand.Next(0, 20);

            BitConverter.GetBytes(index).CopyTo(content.Slice(Outpoint.KeySizeInBytes - 4, 4));

            var payloadLength = _rand.Next(lowLimit, upLimit);

            BitConverter.GetBytes(payloadLength).CopyTo(content.Slice(Outpoint.KeySizeInBytes, 4));

            var payload = new byte[payloadLength];

            _rand.NextBytes(payload);

            var numberOfEvents = _rand.Next(1, 5);

            // write data length inside payload

            BitConverter.TryWriteBytes(payload.AsSpan(sizeof(ulong), sizeof(int)),
                                       payloadLength - sizeof(ulong) - sizeof(int) - BlockEvent.SizeInBytes * numberOfEvents);

            var writer = new PayloadWriter(payload.AsSpan(payloadLength - BlockEvent.SizeInBytes * numberOfEvents));

            for (var i = 0; i < numberOfEvents; ++i)
            {
                var ev = new BlockEvent((uint)_rand.Next(0, 1_000_000));
                writer.Write(ev);
            }

            return(Outpoint.Create(content.Span), payload);
        }
Ejemplo n.º 13
0
        private static byte[] CreateConnectionAttributes()
        {
            var attributesWriter = new PayloadWriter();

            attributesWriter.WriteLengthEncodedString("_client_name");
            attributesWriter.WriteLengthEncodedString("MySqlConnector");
            attributesWriter.WriteLengthEncodedString("_client_version");
            attributesWriter.WriteLengthEncodedString(typeof(ServerSession).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion);
            try
            {
                Utility.GetOSDetails(out var os, out var osDescription, out var architecture);
                if (os != null)
                {
                    attributesWriter.WriteLengthEncodedString("_os");
                    attributesWriter.WriteLengthEncodedString(os);
                }
                attributesWriter.WriteLengthEncodedString("_os_details");
                attributesWriter.WriteLengthEncodedString(osDescription);
                attributesWriter.WriteLengthEncodedString("_platform");
                attributesWriter.WriteLengthEncodedString(architecture);
            }
            catch (PlatformNotSupportedException)
            {
            }
            using (var process = Process.GetCurrentProcess())
            {
                attributesWriter.WriteLengthEncodedString("_pid");
                attributesWriter.WriteLengthEncodedString(process.Id.ToString(CultureInfo.InvariantCulture));
            }
            var connectionAttributes = attributesWriter.ToBytes();

            var writer = new PayloadWriter();

            writer.WriteLengthEncodedInteger((ulong)connectionAttributes.Length);
            writer.Write(connectionAttributes);
            return(writer.ToBytes());
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Generate a response packet.
        /// </summary>
        /// <param name="request">The string representation of the request.</param>
        /// <returns></returns>
        public DiffieHellman GenerateResponse(PayloadReader pr)
        {
            // Generate the would-be fields.
            using (BigInteger prime = pr.ReadBigInteger())
                using (BigInteger g = pr.ReadBigInteger())
                    using (BigInteger mine = BigInteger.genPseudoPrime(bits, 30, random))
                    {
                        // Generate the key.
                        using (BigInteger given = pr.ReadBigInteger())
                            using (BigInteger key = given.modPow(mine, prime))
                            {
                                this.key = key.getBytes();
                            }
                        // Generate the response.
                        using (BigInteger send = g.modPow(mine, prime))
                        {
                            PayloadWriter pw = new PayloadWriter();
                            pw.WriteBigInteger(send);
                            this.representation = pw.ToByteArray();
                        }
                    }

            return(this);
        }
Ejemplo n.º 15
0
        private void HandleConfirmNickname(ConfirmNickname payload, PayloadWriter writer)
        {
            uint accountId = payload.UserId;

            if (accountId != Account.Id)
            {
                StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>();
                resultPayload1.Errorcode = 1;
                resultPayload1.Errormsg  = "Incorrect account";
                resultPayload1.TicketId  = payload.TicketId;
                SendReply(writer, resultPayload1);
                return;
            }

            string mail = payload.Mail;

            if (mail != null)
            {
                Program.Accounts.SetEmail(Database.Connection, accountId, mail);
                Account.Email = mail;
            }

            byte[] nicknameData = payload.Data;
            if (nicknameData != null)
            {
                Program.Accounts.SetUserData(Database.Connection, accountId, nicknameData);
                Account.UserData = nicknameData;
            }

            StatusMsg resultPayload2 = Payloads.CreatePayload <StatusMsg>();

            resultPayload2.Errorcode = 0;
            resultPayload2.Errormsg  = null;
            resultPayload2.TicketId  = payload.TicketId;
            SendReply(writer, resultPayload2);
        }
Ejemplo n.º 16
0
        private static PayloadWriter CreateCapabilitiesPayload(ProtocolCapabilities serverCapabilities, ConnectionSettings cs, bool useCompression, ProtocolCapabilities additionalCapabilities = 0)
        {
            var writer = new PayloadWriter();

            writer.WriteInt32((int)(
                                  ProtocolCapabilities.Protocol41 |
                                  ProtocolCapabilities.LongPassword |
                                  ProtocolCapabilities.SecureConnection |
                                  (serverCapabilities & ProtocolCapabilities.PluginAuth) |
                                  (serverCapabilities & ProtocolCapabilities.PluginAuthLengthEncodedClientData) |
                                  ProtocolCapabilities.MultiStatements |
                                  ProtocolCapabilities.MultiResults |
                                  ProtocolCapabilities.PreparedStatementMultiResults |
                                  ProtocolCapabilities.LocalFiles |
                                  (string.IsNullOrWhiteSpace(cs.Database) ? 0 : ProtocolCapabilities.ConnectWithDatabase) |
                                  (cs.UseAffectedRows ? 0 : ProtocolCapabilities.FoundRows) |
                                  (useCompression ? ProtocolCapabilities.Compress : ProtocolCapabilities.None) |
                                  additionalCapabilities));
            writer.WriteInt32(0x4000_0000);
            writer.WriteByte((byte)CharacterSet.Utf8Mb4Binary);
            writer.Write(new byte[23]);

            return(writer);
        }
Ejemplo n.º 17
0
 void IPayloadSerializable.Write(PayloadWriter writer)
 {
     Write(writer);
 }
Ejemplo n.º 18
0
        private void BuildFile()
        {
            this.Enabled = false;
            string uploadKey = tbUploadKey.txtbox.Text;
            string time      = nudInterval.Value.ToString();
            string mutex     = Random();

            if (string.IsNullOrEmpty(uploadKey) || string.IsNullOrEmpty(time))
            {
                this.Enabled = true;
                return;
            }
            tbBuildLog.Text += "> Upload Key: " + uploadKey + Environment.NewLine;
            tbBuildLog.Text += "> Log Interval: " + time + Environment.NewLine;
            tbBuildLog.Text += "> Mutex: " + mutex + Environment.NewLine;


            bool   installFile = cbInstallFile.Checked;
            string processName = tbProcessName.txtbox.Text;
            string folder      = tbFolder.txtbox.Text;
            string directory   = cbDirectory.Text;

            bool   hkcu    = cbHKCU.Checked;
            bool   hklm    = cbHKLM.Checked;
            string hkcuKey = tbHKCU.txtbox.Text;
            string hklmKey = tbHKLM.txtbox.Text;

            bool meltFile        = cbMeltFile.Checked;
            bool antis           = cbAntis.Checked;
            bool sendScreenshots = cbSendScreenshots.Checked;
            bool hideFile        = cbHideFile.Checked;
            bool pinlogger       = cbPinlogger.Checked;

            bool stealers = cbStealers.Checked;

            string title       = tbTitle.txtbox.Text;
            string description = tbDescription.txtbox.Text;
            string product     = tbProduct.txtbox.Text;
            string copyright   = tbCopyright.txtbox.Text;
            string version     = tbVersion.txtbox.Text;
            string guid        = tbGUID.txtbox.Text;

            string iconPath   = tbIconPath.txtbox.Text;
            bool   changeIcon = !string.IsNullOrEmpty(tbIconPath.txtbox.Text);

            byte[] iconFile = null;
            if (changeIcon)
            {
                iconFile = File.ReadAllBytes(iconPath);
            }

            using (PayloadWriter pw = new PayloadWriter())
            {
                pw.WriteByte(0x03);
                pw.WriteString(uploadKey);
                pw.WriteString(time);
                pw.WriteString(mutex);
                pw.WriteBool(installFile);
                if (installFile)
                {
                    pw.WriteString(processName);
                    pw.WriteString(folder);
                    pw.WriteString(directory);
                }
                pw.WriteBool(hkcu);
                if (hkcu)
                {
                    pw.WriteString(hkcuKey);
                }
                pw.WriteBool(hklm);
                if (hklm)
                {
                    pw.WriteString(hklmKey);
                }


                pw.WriteBool(meltFile);
                pw.WriteBool(antis);
                pw.WriteBool(sendScreenshots);
                pw.WriteBool(hideFile);
                pw.WriteBool(pinlogger);

                pw.WriteBool(stealers);


                pw.WriteString(title);
                pw.WriteString(description);
                pw.WriteString(product);
                pw.WriteString(copyright);
                pw.WriteString(version);
                pw.WriteString(guid);

                pw.WriteBool(changeIcon);

                if (changeIcon)
                {
                    pw.WriteInteger(iconFile.Length);
                    pw.WriteBytes(iconFile);
                }

                byte[] packet = pw.ToByteArray();
                tbBuildLog.Text += "> Sending packet size: " + packet.Length + Environment.NewLine;
                GlobalVariables.SendData(packet);
            }
        }
Ejemplo n.º 19
0
        public void OnLogin(ClientSession cs, InPacket ip)
        {
            PayloadReader pReader = new PayloadReader(ip.Payload);

            Database db = new Database();

            pReader.Skip(7);
            byte IDLength = pReader.ReadByte();

            UID = pReader.ReadString(IDLength);

            pReader.Skip(3);

            byte PWLength = pReader.ReadByte();

            UPW = pReader.ReadString(PWLength);

            if (db.OpenDB())
            {
                try
                {
                    MySqlDataReader sReader = db.Query("SELECT * FROM users WHERE LOGIN = @0 AND PASS = @1", UID, UPW);
                    Log.SqlQuerys(db.dbcmd.CommandText);

                    if (!sReader.HasRows)
                    {
                        Log.Inform("Falha no login. Usuário: {0}", UID);

                        try
                        {
                            PayloadWriter pWriter = new PayloadWriter();

                            byte[] plContent = { 0x00, 0x00, 0x00, 0x14 };
                            pWriter.WriteData(plContent);

                            pWriter.WriteData(IDLength * 2);
                            pWriter.WriteUnicodeString(UID);

                            byte[] plContent1 = { 0x00, 0x00, 0x00, 0x00, 0x00 };
                            pWriter.WriteData(plContent1);

                            OutPacket oPacket = new OutPacket(pWriter.GetCompressedPayload(CenterOpcodes.ENU_VERIFY_ACCOUNT_ACK),
                                                              cs._CryptoHandler, cs._AuthHandler, cs.Prefix, ++cs.Count);

                            cs.Send(oPacket);
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex.Message);
                            while (true)
                            {
                                ;
                            }
                        }
                    }
                    else
                    {
                        // Successful login.
                        Log.Inform("Novo login. Usuário: {0}", UID);

                        // Send server list first.
                        Log.Inform("Enviando a lista de servidores.");
                        SendServerList(cs);
                        SendChannelNews(cs);
                        SendShop(cs);
                        SendClientContentOpen(cs);
                        SendSocketTableInfo(cs);
                        SendCashbackRatio(cs);

                        //Log.Inform("로그인 성공 메시지를 전송합니다.", ID);

                        PayloadWriter pWritter = new PayloadWriter();

                        byte[] plContent = { 0x00, 0x00, 0x00, 0x00 };
                        pWritter.WriteData(plContent);
                        pWritter.WriteData(IDLength * 2);
                        pWritter.WriteUnicodeString(UID);
                        pWritter.WriteData(PWLength);
                        pWritter.WriteData(UPW);

                        byte[] plContent2 = Util.StringToByteArray("00 00 00 00 14 00 8E A7 C5 01 00 00 00 00 00 00 02 4B 52 00 05 A3 BD 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00");
                        pWritter.WriteData(plContent2);

                        pWritter.WriteData(cs.MyLoading.GuildMarkURL.Length * 2);
                        pWritter.WriteUnicodeString(cs.MyLoading.GuildMarkURL);

                        byte[] plContent3 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                        pWritter.WriteData(plContent3);

                        int SHAi = cs.MyLoading.SHAFileList.Length;
                        pWritter.WriteData(SHAi);

                        for (int i = 0; i <= cs.MyLoading.SHAFileList.Length - 1; i++)
                        {
                            pWritter.WriteData(cs.MyLoading.SHAFileList[i].Length * 2);
                            pWritter.WriteUnicodeString(cs.MyLoading.SHAFileList[i]);
                            pWritter.WriteData(true);
                        }

                        byte[] plContent4 = Util.StringToByteArray("00 00 00 01 00 00 00 03 00 00 00 00 00 00 00 00 64 01 00 00 00 00 00 00 00 64 02 00 00 00 00 00 00 00 64 01 BF 80 00 00 FC 04 97 FF 00 00 00 00 00 00 00 00 00 00 00 00");
                        pWritter.WriteData(plContent4);

                        OutPacket oPacket = new OutPacket(pWritter.GetCompressedPayload(CenterOpcodes.ENU_VERIFY_ACCOUNT_ACK),
                                                          cs._CryptoHandler, cs._AuthHandler, cs.Prefix, ++cs.Count);

                        cs.Send(oPacket);
                    }

                    sReader.Close();
                    db.dbconn.Close();
                }
                catch (MySql.Data.MySqlClient.MySqlException ex)
                {
                    Log.Sql(ex.Message);
                    while (true)
                    {
                        ;
                    }
                }
            }
        }
Ejemplo n.º 20
0
        protected sealed override bool HandlePayloadType(Payloads.Types payloadType, PayloadPrefix payload, PayloadWriter writer)
        {
            if (base.HandlePayloadType(payloadType, payload, writer))
            {
                return(true);
            }

            switch (payloadType)
            {
            case Payloads.Types.RegisterNickname:
                HandleRegisterNickname((RegisterNickname)payload, writer);
                return(true);

            case Payloads.Types.ConfirmNickname:
                HandleConfirmNickname((ConfirmNickname)payload, writer);
                return(true);

            case Payloads.Types.GetCDKeys:
                HandleGetCdKeys((GetCDKeys)payload, writer);
                return(true);

            case Payloads.Types.GetWelcomeMsg:
                HandleGetWelcomeMsg((GetWelcomeMsg)payload, writer);
                return(true);

            case Payloads.Types.GetUserInfo:
                HandleGetUserInfo((GetUserInfo)payload, writer);
                return(true);

            case Payloads.Types.GetPlayerInfo:
                HandleGetCharacterInfo((GetPlayerInfo)payload, writer);
                return(true);

            case Payloads.Types.GetChatServer:
                HandleGetChatServer((GetChatServer)payload, writer);
                return(true);

            case Payloads.Types.SelectNickname:
                HandleSelectNickname((SelectNickname)payload, writer);
                return(true);

            case Payloads.Types.RegisterServer:
                HandleRegisterServer((RegisterServer)payload, writer);
                return(true);

            case Payloads.Types.GetServers:
                HandleGetServers((GetServers)payload, writer);
                return(true);

            case Payloads.Types.StopServerUpdates:
                HandleStopServerUpdates((StopServerUpdates)payload, writer);
                return(true);

            case Payloads.Types.UnknownType056:
                HandlePayload056((Payload56)payload, writer);
                return(true);

            case Payloads.Types.UnknownType157:
                HandlePayload157((Payload157)payload, writer);
                return(true);

            case Payloads.Types.ConnectToServer:
                HandleConnectToServer((ConnectToServer)payload, writer);
                return(true);

            case Payloads.Types.UpdateServerInfo:
                HandleUpdateServerInfo((UpdateServerInfo)payload, writer);
                return(true);

            default:
                return(false);
            }
        }
Ejemplo n.º 21
0
        public void SendServerList(ClientSession cs)
        {
            try
            {
                Database db = new Database();
                db.OpenDB();

                MySqlDataReader sReader = db.Query("SELECT id, name, ip, port, description FROM servers");
                Log.SqlQuerys(db.dbcmd.CommandText);
                DataTable dt = new DataTable();

                dt.Load(sReader);
                sReader.Close();
                db.dbconn.Close();

                int nServers = dt.Rows.Count;

                PayloadWriter pWriter = new PayloadWriter();

                byte[] plContent  = { 0x00, 0x00, 0x01, 0x43, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
                byte[] plContent1 = { 0x00, 0x00, 0x00, 0x00 };

                pWriter.WriteData(nServers); // Number of servers

                int    serverNumber;
                string serverName;
                string serverIP;
                short  serverPort;
                string serverDesc;

                foreach (DataRow row in dt.Rows)
                {
                    serverNumber = (int)row[0];
                    serverName   = (string)row[1];
                    serverIP     = (string)row[2];
                    serverPort   = (short)row[3];
                    serverDesc   = (string)row[4];

                    // Server info
                    pWriter.WriteData(serverNumber); // Server number
                    pWriter.WriteData(serverNumber); // Server number?
                    pWriter.WriteData(serverName.Length * 2);
                    pWriter.WriteUnicodeString(serverName);
                    pWriter.WriteData(serverIP.Length);
                    pWriter.WriteData(serverIP);
                    pWriter.WriteData(serverPort);
                    pWriter.WriteData(0);               // Atualmente curtiu?
                    pWriter.WriteData(500);             // Likes máximos?
                    pWriter.WriteData(plContent);
                    pWriter.WriteData(serverIP.Length); // Send IP again
                    pWriter.WriteData(serverIP);
                    pWriter.WriteData(serverDesc.Length * 2);
                    pWriter.WriteUnicodeString(serverDesc);
                    pWriter.WriteData(plContent1);
                }

                OutPacket oPacket = new OutPacket(pWriter.GetPayload(CenterOpcodes.ENU_SERVER_LIST_NOT),
                                                  cs._CryptoHandler, cs._AuthHandler, cs.Prefix, ++cs.Count);

                cs.Send(oPacket);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Ejemplo n.º 22
0
        public ClientSession(Socket socket) : base(socket)
        {
            Log.Inform("Cliente conectado.");

            IP = BitConverter.ToUInt32(IPAddress.Parse(GetIP()).GetAddressBytes(), 0);

            InitiateReceive(2, true);

            // Generate new security keys
            CryptoKey      = Generate.Key();
            _CryptoHandler = new CryptoHandler(CryptoKey);

            AuthKey      = Generate.Key();
            _AuthHandler = new AuthHandler(AuthKey);

            short TempPrefix = Generate.Prefix();

            try
            {
                PayloadWriter pWriter = new PayloadWriter();

                pWriter.WriteData(TempPrefix);
                pWriter.WriteData((int)8);
                pWriter.WriteData(_AuthHandler.HmacKey);
                pWriter.WriteData((int)8);
                pWriter.WriteData(_CryptoHandler.Key);

                byte[] plContent = { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 0x00, 0x00 };
                pWriter.WriteData(plContent);

                OutPacket oPacket = new OutPacket(pWriter.GetPayload(CenterOpcodes.SET_SECURITY_KEY_NOT), tempCryptoHandler,
                                                  tempAuthHandler, Prefix, ++Count);

                Send(oPacket);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Close();
            }

            Prefix = TempPrefix;

            try
            {
                PayloadWriter pWritter = new PayloadWriter();

                byte[] plContent = { 0x00, 0x00, 0x27, 0x10 };
                pWritter.WriteData(plContent);

                OutPacket oPacket = new OutPacket(pWritter.GetPayload(CenterOpcodes.ENU_WAIT_TIME_NOT), _CryptoHandler,
                                                  _AuthHandler, Prefix, ++Count);

                Send(oPacket);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                Close();
            }
        }
Ejemplo n.º 23
0
        private void HandleRegisterUser(RegisterUser payload, PayloadWriter writer)
        {
            byte[] loginCipher = payload.Cipher;

            byte[] result = Crypto.HandleUser(loginCipher, _sharedSecret);
            Program.LogDebug($" User: {Serializer.DumpBytes(result)}");

            MemoryStream stream = new MemoryStream(result);
            BinaryReader reader = new BinaryReader(stream);

            bool invalid = false;

            byte[] nameBytes  = null;
            int    nameLength = reader.ReadByte();

            if (nameLength < 32)
            {
                nameBytes = reader.ReadBytes(nameLength);
            }
            else
            {
                invalid = true;
            }

            byte[] passwordBytes = null;
            if (!invalid)
            {
                int passwordLength = reader.ReadByte();
                if (nameLength < 32)
                {
                    passwordBytes = reader.ReadBytes(passwordLength);
                }
                else
                {
                    invalid = true;
                }
            }

            byte[] cdKey = null;
            if (!invalid)
            {
                int keysLength = reader.ReadByte();
                int keyPool    = reader.ReadByte();
                int keyLength  = reader.ReadByte();
                if (keysLength != 1 || keyPool != 1 || keyLength != 16)
                {
                    invalid = true;
                }
                else
                {
                    cdKey = reader.ReadBytes(keyLength);
                }
            }

            if (invalid)
            {
                StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>();
                resultPayload1.Errorcode = 3;
                resultPayload1.Errormsg  = "Encryption failure";
                resultPayload1.TicketId  = payload.TicketId;
                SendReply(writer, resultPayload1);
                return;
            }

            string name = Encoding.ASCII.GetString(nameBytes);

            byte[] password = Crypto.HashPassword(passwordBytes);

            uint id = Program.Accounts.Create(Database.Connection, name, password, cdKey);

            if (id == 0)
            {
                StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>();
                resultPayload1.Errorcode = 1;
                resultPayload1.Errormsg  = "Username already in use";
                resultPayload1.TicketId  = payload.TicketId;
                SendReply(writer, resultPayload1);
                return;
            }

            Account = Program.Accounts.Get(Database.Connection, name);
            if (Account == null)
            {
                StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>();
                resultPayload1.Errorcode = 1;
                resultPayload1.Errormsg  = "Account not created";
                resultPayload1.TicketId  = payload.TicketId;
                SendReply(writer, resultPayload1);
                return;
            }

            byte[] secret = Crypto.HandleSessionKey(Crypto.CreateSecretKey(), _sharedSecret);

            LoginReplyCipher resultPayload2 = Payloads.CreatePayload <LoginReplyCipher>();

            resultPayload2.PermId   = Account.Id;
            resultPayload2.Cipher   = secret;
            resultPayload2.TicketId = payload.TicketId;
            SendReply(writer, resultPayload2);

            Program.Log($"Account created for {name}");
        }
Ejemplo n.º 24
0
        private void _Invoke(ref object RetObject, params object[] args)
        {
            if (args.Length < ArgumentTypes.Length) //check if a argument is using "params x[] args"
                throw new Exception("missing arguments");

            List<int> usedDelegates = new List<int>();
            PayloadWriter pw = new PayloadWriter();
            pw.WriteInteger(sharedClass.SharedId);
            pw.WriteInteger(MethodId);
            pw.WriteByte(isDelegate ? (byte)1 : (byte)0);

            if (isDelegate)
            {
                pw.WriteInteger(this.DelegateId);
                pw.WriteInteger(this.sharedClass.SharedId);
            }

            SmartSerializer serializer = new SmartSerializer();
            for (int i = 0; i < args.Length; i++)
            {
                object obj = ArgumentTypes[i].IsByRef ? null : args[i];

                if (DelegateIndex.ContainsKey(i))
                    obj = null;

                byte[] SerializedObj = serializer.Serialize(obj);
                pw.WriteInteger(SerializedObj.Length);
                pw.WriteBytes(SerializedObj);
            }

            for (int i = 0; i < DelegateIndex.Count; i++)
            {
                Delegate del = args[DelegateIndex.Keys[i]] as Delegate;

                if (del != null)
                {
                    if (del.Method == null)
                        throw new Exception("Target delegate is NULL");

                    int id = rnd.Next();
                    while(Delegates.ContainsKey(id))
                        id = rnd.Next();

                    pw.WriteByte(1);
                    SharedDelegate sharedDel = new SharedDelegate(del.Method, sharedClass, del.GetType(), id, del, this.MethodId);
                    sharedDel.sharedMethod.Unchecked = DelegateIndex.Values[i].isUnchecked;
                    sharedDel.sharedMethod.usePacketQueue = DelegateIndex.Values[i].UsePacketQueue;
                    sharedDel.sharedMethod.useUdp = DelegateIndex.Values[i].UseUDP;
                    sharedDel.sharedMethod.NoWaitingTime = DelegateIndex.Values[i].NoWaitingTime;
                    pw.WriteObject(sharedDel);

                    if (!isDelegate)
                    {
                        Delegates.Add(id, sharedDel);
                    }
                    continue;
                }
                pw.WriteByte(0);
            }

            if (Unchecked || useUdp)
            {
                //just execute the method and don't wait for response
                sharedClass.connection.Connection.SendMessage(new MsgExecuteMethod(0, pw.ToByteArray(), false));
            }
            else
            {
                SyncObject syncObject = null;
                Random rnd = new Random();
                int RequestId = rnd.Next();
                lock (sharedClass.connection.MethodRequests)
                {
                    while(sharedClass.connection.MethodRequests.ContainsKey(RequestId))
                        RequestId = rnd.Next();
                    syncObject = new SyncObject(sharedClass.connection.Connection.Connection);
                    sharedClass.connection.MethodRequests.Add(RequestId, syncObject);
                    sharedClass.connection.Connection.SendMessage(new MsgExecuteMethod(RequestId, pw.ToByteArray(), true));
                }
                RetObject = syncObject.Wait<ReturnResult>(null, 0);
            }

            /*if (callback != null)
            {
                sharedClass.connection.BeginSendRequest(pw, callback, true, this.usePacketQueue);
            }
            else
            {
                if (Unchecked || useUdp)
                {
                    //just don't wait till we received something back since it's a VOID anyway
                    sharedClass.connection.BeginSendRequest(pw, (object obj) => { }, false, this.usePacketQueue);
                }
                else
                {
                    RetObject = sharedClass.connection.SendRequest(pw, this.usePacketQueue);
                }
            }*/
            serializer = null;
        }
Ejemplo n.º 25
0
        protected sealed override bool HandlePayloadType(Payloads.Types payloadType, PayloadPrefix payload, PayloadWriter writer)
        {
            if (base.HandlePayloadType(payloadType, payload, writer))
            {
                return(true);
            }

            switch (payloadType)
            {
            case Payloads.Types.LoginChat:
                HandleLoginChat((LoginChat)payload, writer);
                return(true);

            case Payloads.Types.VerifyChatLogin:
                HandleVerifyChatLogin((VerifyChatLogin)payload, writer);
                return(true);

            default:
                return(false);
            }
        }
Ejemplo n.º 26
0
        private void HandleLoginServer(LoginServer payload, PayloadWriter writer)
        {
            byte[] loginCipher = payload.Cipher;

            byte[] result = Crypto.HandleUser(loginCipher, _sharedSecret);
            Program.LogDebug($" User: {Serializer.DumpBytes(result)}");

            MemoryStream stream = new MemoryStream(result);
            BinaryReader reader = new BinaryReader(stream);

            bool invalid = false;

            byte[] nameBytes  = null;
            int    nameLength = reader.ReadByte();

            if (nameLength < 32)
            {
                nameBytes = reader.ReadBytes(nameLength);
            }
            else
            {
                invalid = true;
            }

            byte[] passwordBytes = null;
            if (!invalid)
            {
                int passwordLength = reader.ReadByte();
                if (nameLength < 32)
                {
                    passwordBytes = reader.ReadBytes(passwordLength);
                }
                else
                {
                    invalid = true;
                }
            }

            if (invalid)
            {
                StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>();
                resultPayload1.Errorcode = 3;
                resultPayload1.Errormsg  = "Encryption failure";
                resultPayload1.TicketId  = payload.TicketId;
                SendReply(writer, resultPayload1);
                return;
            }

            string name = Encoding.ASCII.GetString(nameBytes);

            byte[] password = Crypto.HashPassword(passwordBytes);

            Account = Program.Accounts.Get(Database.Connection, name);
            if (Account == null)
            {
                StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>();
                resultPayload1.Errorcode = 1;
                resultPayload1.Errormsg  = "Account not found";
                resultPayload1.TicketId  = payload.TicketId;
                SendReply(writer, resultPayload1);
                return;
            }

            if (!Serializer.CompareArrays(password, Account.Password))
            {
                StatusMsg resultPayload1 = Payloads.CreatePayload <StatusMsg>();
                resultPayload1.Errorcode = 1;
                resultPayload1.Errormsg  = "Wrong password";
                resultPayload1.TicketId  = payload.TicketId;
                SendReply(writer, resultPayload1);
                return;
            }

            byte[] secret = Crypto.HandleSessionKey(Crypto.CreateSecretKey(), _sharedSecret);

            LoginReplyCipher resultPayload = Payloads.CreatePayload <LoginReplyCipher>();

            resultPayload.PermId   = Account.Id;
            resultPayload.Cipher   = secret;
            resultPayload.TicketId = payload.TicketId;
            SendReply(writer, resultPayload);

            Program.Log($"Server logged in for user {name}");
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Decrypt the data
        /// </summary>
        /// <param name="Data">The data to decrypt</param>l
        /// <param name="Offset">The index where the data starts</param>
        /// <param name="Length">The length to decrypt</param>
        public void Decrypt(byte[] Data, int Offset, int Length)
        {
            lock (DecState)
            {
                int OrgLen = Length;
                Length += Offset;

                for (int round = 0; round < Rounds; round++)
                {
                    using (PayloadWriter pw = new PayloadWriter(new System.IO.MemoryStream(Data)))
                    {
                        ulong temp_Value = DecState.IV[EncMode == WopEncMode.Simple ? 0 : DecState.IV_Pos]; //is being used for CBC Mode (Block-Cipher-Chaining Mode)
                        for (int i = Offset, k = 0; i < Length; k++)
                        {
                            pw.vStream.Position = i;
                            int   usedsize     = 0;
                            ulong value        = 0;
                            ulong OrgReadValue = 0;

                            if (i + 8 < Length)
                            {
                                OrgReadValue = BitConverter.ToUInt64(Data, i);
                                usedsize     = 8;

                                value = Decrypt_Core_Big(OrgReadValue ^ temp_Value, OrgLen, k);
                                pw.WriteULong(value);
                            }
                            else
                            {
                                OrgReadValue = Data[i];
                                usedsize     = 1;

                                value = Decrypt_Core_Small((byte)OrgReadValue, OrgLen, k);
                                pw.WriteByte((byte)value);
                            }

                            temp_Value    += OrgReadValue;
                            DecState.Seed += (int)value;
                            i             += usedsize;

                            if (EncMode != WopEncMode.Simple)
                            {
                                DecState.Key_Pos  += 1;
                                DecState.Salt_Pos += 1;
                            }
                        }
                    }
                }

                DecState.IV_Pos = (DecState.IV_Pos + 1) % DecState.IV.Length;

                switch (EncMode)
                {
                case WopEncMode.GenerateNewAlgorithm:
                {
                    InstructionInfo tempEncCode = null;
                    InstructionInfo tempDecCode = null;
                    FastRandom      fastRand    = new FastRandom(DecState.Seed);

                    for (int i = 0; i < DecState.Instructions.Length; i++)
                    {
                        GetNextRandomInstruction(fastRand, ref tempEncCode, ref tempDecCode);
                        DecState.Instructions[i] = tempDecCode;
                    }

                    if (UseDynamicCompiler)
                    {
                        DecState.Compile();
                    }
                    break;
                }

                case WopEncMode.ShuffleInstructions:
                {
                    ShuffleInstructions(DecState.Instructions, DecState.Seed);

                    if (UseDynamicCompiler)
                    {
                        DecState.Compile();
                    }
                    break;
                }
                }
            }
        }
Ejemplo n.º 28
0
        private void _Invoke(ref object RetObject, params object[] args)
        {
            if (args.Length < ArgumentTypes.Length) //check if a argument is using "params x[] args"
            {
                throw new Exception("missing arguments");
            }

            List <int>    usedDelegates = new List <int>();
            PayloadWriter pw            = new PayloadWriter();

            pw.WriteInteger(sharedClass.SharedId);
            pw.WriteInteger(MethodId);
            pw.WriteByte(isDelegate ? (byte)1 : (byte)0);

            if (isDelegate)
            {
                pw.WriteInteger(this.DelegateId);
                pw.WriteInteger(this.sharedClass.SharedId);
            }

            SmartSerializer serializer = new SmartSerializer();

            for (int i = 0; i < args.Length; i++)
            {
                object obj = ArgumentTypes[i].IsByRef ? null : args[i];

                if (DelegateIndex.ContainsKey(i))
                {
                    obj = null;
                }

                byte[] SerializedObj = serializer.Serialize(obj);
                pw.WriteInteger(SerializedObj.Length);
                pw.WriteBytes(SerializedObj);
            }

            for (int i = 0; i < DelegateIndex.Count; i++)
            {
                Delegate del = args[DelegateIndex.Keys[i]] as Delegate;

                if (del != null)
                {
                    if (del.Method == null)
                    {
                        throw new Exception("Target delegate is NULL");
                    }

                    int id = rnd.Next();
                    while (Delegates.ContainsKey(id))
                    {
                        id = rnd.Next();
                    }

                    pw.WriteByte(1);
                    SharedDelegate sharedDel = new SharedDelegate(del.Method, sharedClass, del.GetType(), id, del, this.MethodId);
                    sharedDel.sharedMethod.Unchecked      = DelegateIndex.Values[i].isUnchecked;
                    sharedDel.sharedMethod.usePacketQueue = DelegateIndex.Values[i].UsePacketQueue;
                    sharedDel.sharedMethod.useUdp         = DelegateIndex.Values[i].UseUDP;
                    sharedDel.sharedMethod.NoWaitingTime  = DelegateIndex.Values[i].NoWaitingTime;
                    pw.WriteObject(sharedDel);

                    if (!isDelegate)
                    {
                        Delegates.Add(id, sharedDel);
                    }
                    continue;
                }
                pw.WriteByte(0);
            }

            if (Unchecked || useUdp)
            {
                //just execute the method and don't wait for response
                sharedClass.connection.Connection.SendMessage(new MsgExecuteMethod(0, pw.ToByteArray(), false));
            }
            else
            {
                SyncObject syncObject = null;
                Random     rnd        = new Random();
                int        RequestId  = rnd.Next();
                lock (sharedClass.connection.MethodRequests)
                {
                    while (sharedClass.connection.MethodRequests.ContainsKey(RequestId))
                    {
                        RequestId = rnd.Next();
                    }
                    syncObject = new SyncObject(sharedClass.connection.Connection.Connection);
                    sharedClass.connection.MethodRequests.Add(RequestId, syncObject);
                    sharedClass.connection.Connection.SendMessage(new MsgExecuteMethod(RequestId, pw.ToByteArray(), true));
                }
                RetObject = syncObject.Wait <ReturnResult>(null, 0);
            }

            /*if (callback != null)
             * {
             *  sharedClass.connection.BeginSendRequest(pw, callback, true, this.usePacketQueue);
             * }
             * else
             * {
             *  if (Unchecked || useUdp)
             *  {
             *      //just don't wait till we received something back since it's a VOID anyway
             *      sharedClass.connection.BeginSendRequest(pw, (object obj) => { }, false, this.usePacketQueue);
             *  }
             *  else
             *  {
             *      RetObject = sharedClass.connection.SendRequest(pw, this.usePacketQueue);
             *  }
             * }*/
            serializer = null;
        }
Ejemplo n.º 29
0
        public void NotifyContentInfo(ClientSession cs)
        {
            try
            {
                PayloadWriter pWriter = new PayloadWriter();

                byte[] plContent0 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
                                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
                pWriter.WriteData(plContent0);

                byte[] plContent1 = { 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
                                      0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 };
                pWriter.WriteData(plContent1);

                pWriter.WriteData(InitLoading.Length);

                pWriter.WriteData(InitLoading[0].Length * 2);
                pWriter.WriteUnicodeString(InitLoading[0]);

                pWriter.WriteData(InitLoading[1].Length * 2);
                pWriter.WriteUnicodeString(InitLoading[1]);

                pWriter.WriteData(InitLoading[2].Length * 2);
                pWriter.WriteUnicodeString(InitLoading[2]);

                pWriter.WriteData(InitLoading[3].Length * 2);
                pWriter.WriteUnicodeString(InitLoading[3]);

                byte[] plContent2 = { 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
                                      0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 };
                pWriter.WriteData(plContent2);

                pWriter.WriteData(MatchLoading.Length);

                pWriter.WriteData(MatchLoading[0].Length * 2);
                pWriter.WriteUnicodeString(MatchLoading[0]);

                pWriter.WriteData(MatchLoading[1].Length * 2);
                pWriter.WriteUnicodeString(MatchLoading[1]);

                pWriter.WriteData(MatchLoading[2].Length * 2);
                pWriter.WriteUnicodeString(MatchLoading[2]);
                pWriter.WriteData(0);

                pWriter.WriteData(SquareLoading.Length);
                pWriter.WriteData(0);

                pWriter.WriteData(SquareLoading[0].Length * 2);
                pWriter.WriteUnicodeString(SquareLoading[0]);

                pWriter.WriteData(1);
                pWriter.WriteData(SquareLoading[1].Length * 2);
                pWriter.WriteUnicodeString(SquareLoading[1]);

                pWriter.WriteData(2);
                pWriter.WriteData(SquareLoading[2].Length * 2);
                pWriter.WriteUnicodeString(SquareLoading[2]);

                byte[] plContent3 = { 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                      0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 };
                pWriter.WriteData(plContent3);

                // HackList
                pWriter.WriteData(HackList.Length);
                for (int i = 0; i <= HackList.Length - 1; i++)
                {
                    pWriter.WriteData(HackList[i].Length * 2);
                    pWriter.WriteUnicodeString(HackList[i]);
                }

                OutPacket oPacket = new OutPacket(pWriter.GetCompressedPayload(CenterOpcodes.ENU_CLIENT_CONTENTS_FIRST_INIT_INFO_ACK),
                                                  cs._CryptoHandler, cs._AuthHandler, cs.Prefix, ++cs.Count);

                cs.Send(oPacket);
            }
            catch
            {
            }
        }
Ejemplo n.º 30
0
        protected sealed override void HandleChatPayloadType(ChatPayloads.ChatTypes chatPayloadType, ChatPayloadPrefix chatPayload, PayloadWriter writer)
        {
            Program.LogDebug($" --- Chat Payload received: {chatPayloadType} ---");
            chatPayload.Serialize(Logger);

            switch (chatPayloadType)
            {
            case ChatPayloads.ChatTypes.CreateChannel:
                ChatHandleCreateChannel((CreateChannel)chatPayload, writer);
                break;

            default:
                return;
            }
        }
Ejemplo n.º 31
0
        private void _Invoke(ref object RetObject, params object[] args)
        {
            if (args.Length < ArgumentTypes.Length) //check if a argument is using "params x[] args"
            {
                throw new Exception("missing arguments");
            }

            List <int>    usedDelegates = new List <int>();
            PayloadWriter pw            = new PayloadWriter();

            SmartSerializer serializer = new SmartSerializer();

            for (int i = 0; i < args.Length; i++)
            {
                object obj = ArgumentTypes[i].IsByRef ? null : args[i];

                if (DelegateIndex.ContainsKey(i))
                {
                    obj = null;
                }

                byte[] SerializedObj = serializer.Serialize(obj);
                pw.WriteInteger(SerializedObj.Length);
                pw.WriteBytes(SerializedObj);
            }

            for (int i = 0; i < DelegateIndex.Count; i++)
            {
                Delegate del = args[DelegateIndex.Keys[i]] as Delegate;

                if (del != null)
                {
                    if (del.Method == null)
                    {
                        throw new Exception("Target delegate is NULL");
                    }

                    int id = rnd.Next();
                    while (Delegates.ContainsKey(id))
                    {
                        id = rnd.Next();
                    }

                    pw.WriteBool(true);
                    SharedDelegate sharedDel = new SharedDelegate(del.Method, sharedClass, del.GetType(), id, del, this.MethodId);
                    sharedDel.sharedMethod.Unchecked      = this.Unchecked;      //DelegateIndex.Values[i].isUnchecked;
                    sharedDel.sharedMethod.usePacketQueue = this.usePacketQueue; //DelegateIndex.Values[i].UsePacketQueue;
                    sharedDel.sharedMethod.useUdp         = this.useUdp;         //DelegateIndex.Values[i].UseUDP;
                    pw.WriteObject(sharedDel);

                    if (!isDelegate)
                    {
                        Delegates.Add(id, sharedDel);
                    }
                    continue;
                }
                pw.WriteBool(false);
            }

            try
            {
                if (Unchecked || useUdp)
                {
                    //just execute the method and don't wait for response
                    sharedClass.Client.Send(new MsgExecuteMethod(0, pw.ToByteArray(), false, sharedClass.SharedId, MethodId, this.DelegateId, this.sharedClass.SharedId));
                }
                else
                {
                    SyncObject syncObject = null;
                    Random     rnd        = new Random();
                    int        RequestId  = rnd.Next();
                    lock (sharedClass.Client.Requests)
                    {
                        while (sharedClass.Client.Requests.ContainsKey(RequestId))
                        {
                            RequestId = rnd.Next();
                        }
                        syncObject = new SyncObject(sharedClass.Client);
                        sharedClass.Client.Requests.Add(RequestId, syncObject);
                        sharedClass.Client.Send(new MsgExecuteMethod(RequestId, pw.ToByteArray(), true, sharedClass.SharedId, MethodId, this.DelegateId, this.sharedClass.SharedId));
                    }
                    RetObject = syncObject.Wait <ReturnResult>(null, TimeOutLength);

                    if (syncObject.TimedOut)
                    {
                        //copying the object in memory, maybe a strange way todo it but it works
                        RetObject = new ReturnResult(serializer.Deserialize(serializer.Serialize(this.TimeOutValue)), false);
                    }
                }
            }
            catch
            {
                //client most likely disconnected and was unable to send the message
                RetObject = null;
            }

            /*if (callback != null)
             * {
             *  sharedClass.connection.BeginSendRequest(pw, callback, true, this.usePacketQueue);
             * }
             * else
             * {
             *  if (Unchecked || useUdp)
             *  {
             *      //just don't wait till we received something back since it's a VOID anyway
             *      sharedClass.connection.BeginSendRequest(pw, (object obj) => { }, false, this.usePacketQueue);
             *  }
             *  else
             *  {
             *      RetObject = sharedClass.connection.SendRequest(pw, this.usePacketQueue);
             *  }
             * }*/
            serializer = null;
        }