Ejemplo n.º 1
0
        private void method_3(byte[] byte_1)
        {
            if ((byte_1[0] == 60) && (byte_1[1] == 0x70))
            {
                this.SendData(CrossdomainPolicy.GetBytes(), true);
                SessionManager.StopSession(this.uint_0);
            }
            else if (byte_1[0] == 0xb1)
            {
                string[] strArray = Constants.DefaultEncoding.GetString(byte_1).Split(new char[] { '\x00b0' });
                try
                {
                    byte[] bytes;
                    foreach (string str in strArray)
                    {
                        bytes = Constants.DefaultEncoding.GetBytes(str + 1);
                        if (bytes.Length > 3)
                        {
                            bytes[bytes.Length - 1] = 0xb0;
                            if (bytes[3] == 0xb2)
                            {
                                if (bytes[1] == 0xa3)
                                {
                                    this.SendData(PingComposer.Compose(), false);
                                    if (bytes.Length <= 5)
                                    {
                                        continue;
                                    }
                                    goto Label_0238;
                                }
                                int num = 4;
                                while (num < bytes.Length)
                                {
                                    ClientMessage message = null;
                                    try
                                    {
                                        ushort messageFlag = bytes[1];
                                        byte[] body        = new byte[bytes.Length - 4];
                                        for (int i = 0; i < body.Length; i++)
                                        {
                                            body[i] = bytes[num++];
                                        }
                                        message = new ClientMessage(messageFlag, 0, body);
                                    }
                                    catch (Exception)
                                    {
                                        Output.WriteLine("Packet formatting exception on packet: " + Constants.DefaultEncoding.GetString(bytes), OutputLevel.DebugNotification);
                                        break;
                                    }
                                    if (message != null)
                                    {
                                        try
                                        {
                                            DataRouter.HandleData(this, message);
                                            continue;
                                        }
                                        catch (Exception exception)
                                        {
                                            Output.WriteLine("Critical error in HandleData stack: " + exception.Message + "\n\n" + exception.StackTrace, OutputLevel.CriticalError);
                                            break;
                                        }
                                    }
                                }
                                continue;
                            }
                            int num4 = 6;
                            while (num4 < bytes.Length)
                            {
                                ClientMessage message2 = null;
                                try
                                {
                                    ushort num5        = bytes[1];
                                    ushort messageItem = bytes[3];
                                    byte[] buffer3     = new byte[bytes.Length - 6];
                                    for (int j = 0; j < buffer3.Length; j++)
                                    {
                                        buffer3[j] = bytes[num4++];
                                    }
                                    message2 = new ClientMessage(num5, messageItem, buffer3);
                                }
                                catch (Exception)
                                {
                                    Output.WriteLine("Packet formatting exception on packet: " + Constants.DefaultEncoding.GetString(bytes), OutputLevel.DebugNotification);
                                    break;
                                }
                                if (message2 != null)
                                {
                                    try
                                    {
                                        DataRouter.HandleData(this, message2);
                                        continue;
                                    }
                                    catch (Exception exception2)
                                    {
                                        Output.WriteLine("Critical error in HandleData stack: " + exception2.Message + "\n\n" + exception2.StackTrace, OutputLevel.CriticalError);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    return;

Label_0238:
                    if (bytes[5] == 120)
                    {
                        this.SendData(FacebookInitComposer.Compose(), false);
                    }
                }
                catch (Exception exception3)
                {
                    Console.WriteLine(exception3.ToString());
                }
            }
            else
            {
                SessionManager.StopSession(this.uint_0);
            }
        }
Ejemplo n.º 2
0
        private void ProcessData(byte[] Data)
        {
            if (Data.Length == 0)
            {
                return;
            }

            if (Data[0] == 177)
            {
                string[] sp = Encoding.Default.GetString(Data).Split('±');
                int      i  = 1;
                while (i <= sp.Length - 1)
                {
                    int    Pos = 0;
                    byte[] lol = Encoding.Default.GetBytes("±" + sp[i]);
                    while (Pos < lol.Length)
                    {
                        ClientMessage Message = null;

                        try
                        {
                            byte ID            = lol[1];
                            byte Type          = (lol[3] == 178) ? (byte)0 : lol[3];
                            uint MessageId     = uint.Parse(lol[1] + "" + Type);
                            int  MessageLength = (Type > 0) ? lol.Length - 4 : lol.Length - 2;

                            Pos = (Type > 0) ? 4 : 2;

                            byte[] Content = new byte[MessageLength];

                            for (int ii = 0; ii < Content.Length; ii++)
                            {
                                Content[ii] = lol[Pos++];
                            }

                            Message = new ClientMessage(MessageId, Content);
                        }
                        catch (Exception)
                        {
                            SessionManager.StopSession(mId); // packet formatting exception
                            return;
                        }

                        if (Message != null)
                        {
                            if (Program.DEBUG)
                            {
                                Output.WriteLine("[RCV][" + mId + "]: [" + Message.Id + "] " + Encoding.Default.GetString(lol), OutputLevel.DebugInformation);
                            }

                            try
                            {
                                DataRouter.HandleData(this, Message);
                            }
                            catch (Exception e)
                            {
                                Output.WriteLine("Critical error in HandleData stack: " + e.Message + "\n\n" + e.StackTrace,
                                                 OutputLevel.CriticalError);
                                SessionManager.StopSession(mId);
                                return;
                            }
                        }
                        i++;
                    }
                }
            }
            else if (Data[0] == 60)
            {
                Output.WriteLine("Sent crossdomain policy to client " + mId + ".", OutputLevel.DebugInformation);
                string xmlPolicy =
                    "<?xml version=\"1.0\"?>\r\n" +
                    "<!DOCTYPE cross-domain-policy SYSTEM \"/xml/dtds/cross-domain-policy.dtd\">\r\n" +
                    "<cross-domain-policy>\r\n" +
                    "<allow-access-from domain=\"*\" to-ports=\"2002\" />\r\n" +
                    "</cross-domain-policy>\x0";
                SendData(Encoding.Default.GetBytes(xmlPolicy));
                SessionManager.StopSession(mId);
            }
            else
            {
                Output.WriteLine("[RCV][" + mId + "]: " + Encoding.Default.GetString(Data), OutputLevel.DebugInformation);
                SessionManager.StopSession(mId);
            }
        }
Ejemplo n.º 3
0
        private void ProcessData(byte[] Data)
        {
            if (Data.Length == 0)
            {
                return;
            }

            if (Data[0] == 64)
            {
                int Pos = 0;

                while (Pos < Data.Length)
                {
                    ClientMessage Message = null;

                    try
                    {
                        int  MessageLength = Base64Encoding.DecodeInt32(new byte[] { Data[Pos++], Data[Pos++], Data[Pos++] });
                        uint MessageId     = Base64Encoding.DecodeUInt32(new byte[] { Data[Pos++], Data[Pos++] });

                        byte[] Content = new byte[MessageLength - 2];

                        for (int i = 0; i < Content.Length; i++)
                        {
                            Content[i] = Data[Pos++];
                        }

                        Message = new ClientMessage(MessageId, Content);
                    }
                    catch (Exception)
                    {
                        SessionManager.StopSession(mId); // packet formatting exception
                        return;
                    }

                    if (Message != null)
                    {
                        Output.WriteLine("[RCV][" + mId + "]: " + Message.ToString(), OutputLevel.DebugInformation);

                        try
                        {
                            DataRouter.HandleData(this, Message);
                        }
                        catch (Exception e)
                        {
                            Output.WriteLine("Critical error in HandleData stack: " + e.Message + "\n\n" + e.StackTrace,
                                             OutputLevel.CriticalError);
                            SessionManager.StopSession(mId);
                            return;
                        }
                    }
                }
            }
            else if (Data[0] == 60)
            {
                Output.WriteLine("Sent crossdomain policy to client " + mId + ".", OutputLevel.DebugInformation);
                SendData(CrossdomainPolicy.GetBytes());
                SessionManager.StopSession(mId);
            }
            else
            {
                SessionManager.StopSession(mId);
            }
        }