Esempio n. 1
0
        private static void HandleIW5ServerAuth(MessageData data, int type)
        {
            var packet = DWRouter.GetMessage(data);

            bool unknownBool;
            uint randomNumber;
            uint gameID;

            byte[] rsaKeyBuf = new byte[1120 / 8];

            packet.BitBuffer.UseDataTypes = false;
            packet.BitBuffer.ReadBoolean(out unknownBool);
            packet.BitBuffer.UseDataTypes = true;

            packet.BitBuffer.ReadUInt32(out randomNumber);
            packet.BitBuffer.ReadUInt32(out gameID);

            // create state
            var state = new IW5ServerAuthstate()
            {
                GameID  = gameID,
                Packet  = packet,
                Random  = randomNumber,
                OddBool = unknownBool
            };

            if (type == 26)
            {
                packet.BitBuffer.Read(1120, rsaKeyBuf);

                // start thread
                var thread = new Thread(CreateIW5ServerKey);
                thread.Start(state);
            }
        }
Esempio n. 2
0
        public static void DW_PacketReceived(MessageData data)
        {
            var type  = data.Get <int>("type");
            var crypt = data.Get <bool>("crypt");

            if (type == 6)
            {
                var packet = DWRouter.GetMessage(data);
                var call   = packet.ByteBuffer.ReadByte();

                try
                {
                    switch (call)
                    {
                    case 1:
                        break;

                    case 14:
                        SendGlobalInstantMessage(data, packet);
                        break;

                    default:
                        Log.Debug("unknown packet " + call + " in bdMessaging");
                        //DWRouter.Unknown(data, packet);
                        break;
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e.ToString());
                }
            }
        }
Esempio n. 3
0
        public static void DW_PacketReceived(MessageData data)
        {
            var type  = data.Get <int>("type");
            var crypt = data.Get <bool>("crypt");

            var packet = DWRouter.GetMessage(data);
            var call   = packet.ByteBuffer.ReadByte();

            switch (call)
            {
            case 2:
                GetUserData(data, packet);
                break;
            }
        }
Esempio n. 4
0
        private static void HandleClientAuth(MessageData data)
        {
            var packet = DWRouter.GetMessage(data);

            bool unknownBool;
            uint randomNumber;
            uint gameID;
            uint ticketLength;

            byte[] ticket;

            packet.BitBuffer.UseDataTypes = false;
            packet.BitBuffer.ReadBoolean(out unknownBool);
            packet.BitBuffer.UseDataTypes = true;

            packet.BitBuffer.ReadUInt32(out randomNumber);
            packet.BitBuffer.ReadUInt32(out gameID);
            packet.BitBuffer.ReadUInt32(out ticketLength);

            ticket = new byte[ticketLength];
            packet.BitBuffer.ReadBytes((int)ticketLength, out ticket);

            var cid = data.Get <string>("cid");

            // and the connection
            //var ci = TCPHandler.Connections.Find(c => c.ConnectionID == cid);

            var SourceSocket = cid.Split(':');
            // create state
            var state = new ClientAuthstate()
            {
                GameID  = gameID,
                Ticket  = ticket,
                Packet  = packet,
                Random  = randomNumber,
                OddBool = unknownBool,
                Source  = SourceSocket[0]
            };

            // start thread
            var thread = new Thread(DoClientAuth);

            thread.Start(state);
        }
Esempio n. 5
0
        private static void HandleServerAuth(MessageData data)
        {
            var packet = DWRouter.GetMessage(data);

            bool unknownBool;
            uint randomNumber;
            uint gameID;

            byte[] keyDataBuf = new byte[8];

            packet.BitBuffer.UseDataTypes = false;
            packet.BitBuffer.ReadBoolean(out unknownBool);
            packet.BitBuffer.UseDataTypes = true;

            packet.BitBuffer.ReadUInt32(out randomNumber);
            packet.BitBuffer.ReadUInt32(out gameID);
            packet.BitBuffer.Read(64, keyDataBuf);

            // create state
            var state = new ServerAuthstate()
            {
                GameID  = gameID,
                KeyData = BitConverter.ToUInt64(keyDataBuf, 0),
                Packet  = packet,
                Random  = randomNumber,
                OddBool = unknownBool
            };

            // start thread
            if (Program.Game == TitleID.T5)
            {
                var thread = new Thread(DoServerAuth);
                thread.Start(state);
            }
            else if (Program.Game == TitleID.IW5)
            {
                var thread = new Thread(DoIW5ServerAuth);
                thread.Start(state);
            }
        }
Esempio n. 6
0
        public static void DW_PacketReceived(MessageData data)
        {
            var type  = data.Get <int>("type");
            var crypt = data.Get <bool>("crypt");

            if (type == 12 && crypt)
            {
                var packet = DWRouter.GetMessage(data);
                var call   = packet.ByteBuffer.ReadByte();

                switch (call)
                {
                case 6:
                    GetServerTime(data, packet);
                    break;

                default:
                    //DWRouter.Unknown(data, packet);
                    Log.Info("unknown packet " + call + " in bdTitleUtilities");
                    break;
                }
            }
        }
Esempio n. 7
0
        public static void DW_PacketReceived(MessageData data)
        {
            var type  = data.Get <int>("type");
            var crypt = data.Get <bool>("crypt");

            var weHandle = ((type == 10) || (type == 18) || (type == 8 || (crypt && type == 28) || type == 50 || type == 4 || type == 58) || (type == 23));

            try
            {
                if (type == 10)
                {
                    var packet   = DWRouter.GetMessage(data);
                    var call     = packet.ByteBuffer.ReadByte();
                    var initTime = DateTime.Now;

                    switch (call)
                    {
                    case 1:
                        UploadFile(data, packet);
                        break;

                    case 3:
                        GetFile(data, packet);
                        break;

                    case 7:
                        GetPublisherFile(data, packet);
                        break;

                    default:
                        Log.Debug("unknown packet " + call + " in bdStorage");
                        DWRouter.Unknown(data, packet);
                        break;
                    }
                }
                else if (type == 18)
                {
                    try
                    {
                        var packet = DWRouter.GetMessage(data);
                        var reply  = packet.MakeReply(5, false);
                        reply.ByteBuffer.Write(new byte[] { 0x2d, 0xb3, 0xa2, 0x4f, 0x1a, 0x36, 0xd0, 0xd2, 0x00, 0x00, 0x04, 0x00, 0x00, 0xee, 0x02, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0xd0, 0x07, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x88, 0x13, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00, 0x02, 0x0c, 0xd1, 0xaa, 0x7a, 0xb1, 0x31, 0xb1, 0xaa, 0x6b, 0x83, 0x51, 0x00, 0x00 });
                        reply.Send(true);
                    }
                    catch { }
                }
                else if (type == 8 || (crypt && type == 28) || type == 50 || type == 4 || type == 58)
                {
                    try
                    {
                        var packet = DWRouter.GetMessage(data);

                        try
                        {
                            var call = packet.ByteBuffer.ReadByte();
                            //Log.Debug("Service call identifier is " + call + ".");
                        }
                        catch { }

                        //DWRouter.Unknown(data, packet);
                    }
                    catch { }
                }
                else if (type == 23)
                {
                    try
                    {
                        var packet = DWRouter.GetMessage(data);
                        var call   = packet.ByteBuffer.ReadByte();

                        switch (call)
                        {
                        case 2:
                            GetCounterTotals(data, packet);
                            break;

                        default:
                            Log.Debug("unknown packet " + call + " in bdCounter");
                            //DWRouter.Unknown(data, packet);
                            break;
                        }
                    }
                    catch { }
                }

                /*else if (type != 12 && crypt)
                 * {
                 *  var packet = DWRouter.GetMessage(data);
                 *  DWRouter.Unknown(data, packet);
                 * }*/
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }

            if (weHandle)
            {
                var upacket = DWRouter.GetMessage(data);
            }
        }
Esempio n. 8
0
        private void redirectPacket(MessageData data)
        {
            data.Arguments["handled"] = false;

            var  type   = data.Get <int>("type");
            var  crypt  = data.Get <bool>("crypt");
            bool routed = false;

            try
            {
                if (!crypt && (type == 28 || type == 12 || type == 26))
                {
                    DWAuther.DW_PacketReceived(data);
                    routed = true;
                    //Log.Debug("got auth packet");
                }
                if (crypt && type == 28)
                {
                    DWGroups.DW_PacketReceived(data);
                    routed = true;
                }
                if (type == 7)
                {
                    DWLobby.DW_PacketReceived(data);
                    routed = true;
                    //Log.Debug("got lobby packet");
                }
                if (type == 6)
                {
                    DWMessaging.DW_PacketReceived(data);
                    routed = true;
                    //Log.Debug("got service packet");
                }
                if (type == 21)
                {
                    DWMatch.DW_PacketReceived(data);
                    routed = true;
                    //Log.Debug("got match packet");
                }
                if ((type == 10) || (type == 18) || (type == 23) || (type == 8 || type == 50 || type == 4 || type == 58))
                {
                    DWStorage.DW_PacketReceived(data);
                    routed = true;
                    //Log.Debug("got storage packet");
                }
                if (type == 12 && crypt)
                {
                    DWTitles.DW_PacketReceived(data);
                    routed = true;
                    //Log.Debug("got Title packet");
                }
                if (type == 8)
                {
                    DWProfiles.DW_PacketReceived(data);
                    routed = true;
                }
                if (type == 27)
                {
                    DWDML.DW_PacketReceived(data);
                }
                if (type == 67)
                {
                    DWEventLog.DW_PacketReceived(data);
                }
            }
            catch (Exception e)
            {
                Log.Error("Exception: " + e.ToString());
            }

            /*if(routed == false)
             * {
             *  Log.Debug("UNHANDLED PACKET: " + type);
             * }*/

            try
            {
                if (crypt && !data.Get <bool>("handled"))
                {
                    DWRouter.Unknown(data, DWRouter.GetMessage(data));
                }
            }
            catch
            {
                Log.Error("UNKNOWN FAILED, THIS CONNECTION CAN BE CONSIDERED DEAD.");

                // disconnect to prevent pollution of system
                TCPHandler.ForceDisconnect(data);
            }
        }
Esempio n. 9
0
        public static void DW_PacketReceived(MessageData data)
        {
            var type  = data.Get <int>("type");
            var crypt = data.Get <bool>("crypt");

            if (type == 21)
            {
                var packet = DWRouter.GetMessage(data);
                var call   = packet.ByteBuffer.ReadByte();

                try
                {
                    switch (call)
                    {
                    case 1:
                        CreateSession(data, packet);
                        break;

                    case 2:
                        UpdateSession(data, packet);
                        break;

                    case 3:
                        DeleteSession(data, packet);
                        break;

                    case 4:
                        FindSessionFromID(data, packet);
                        break;

                    case 5:
                        FindSessions(data, packet);
                        break;

                    case 8:
                        InviteToSession(data, packet);
                        break;

                    case 9:
                        SubmitPerformance(data, packet);
                        break;

                    case 10:
                        GetPerformanceValues(data, packet);
                        break;

                    case 12:
                        UpdateSessionPlayers(data, packet);
                        break;

                    case 13:
                        FindSessionsPaged(data, packet);
                        break;

                    case 14:
                        FindSessionsByEntityIDs(data, packet);
                        break;

                    default:
                        Log.Debug("unknown packet " + call + " in bdMatchMaking");
                        //DWRouter.Unknown(data, packet);
                        break;
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e.ToString());
                }
            }
        }
Esempio n. 10
0
        public static void DW_PacketReceived(MessageData data)
        {
            var type = data.Get <int>("type");

            if (type == 7)
            {
                var packet = DWRouter.GetMessage(data);

                bool   initialBool;
                uint   gameID, randomNumber;
                byte[] ticket;

                packet.BitBuffer.UseDataTypes = false;
                packet.BitBuffer.ReadBoolean(out initialBool);
                packet.BitBuffer.UseDataTypes = true;

                packet.BitBuffer.ReadUInt32(out gameID);
                packet.BitBuffer.ReadUInt32(out randomNumber);

                packet.BitBuffer.ReadBytes(128, out ticket);

                // parse LSG ticket
                var key = DWTickets.GetKeyFromLSGTicket(ticket);
                DWRouter.SetGlobalKey(packet.Data, key);

                lock (DWRouter.Connections)
                {
                    var id = DWTickets.GetIDFromLSGTicket(ticket);
                    DWRouter.Connections[id] = packet.Data.Get <string>("cid");
                }

                lock (DWRouter.CIDToUser)
                {
                    var id = DWTickets.GetUserFromLSGTicket(ticket);
                    DWRouter.CIDToUser[packet.Data.Get <string>("cid")] = id;
                }

                lock (DWRouter.ConnectionsReverse)
                {
                    var id = DWTickets.GetIDFromLSGTicket(ticket);
                    DWRouter.ConnectionsReverse[packet.Data.Get <string>("cid")] = id;
                }

                lock (DWRouter.CIDToName)
                {
                    var name = DWTickets.GetNameFromLSGTicket(ticket);
                    DWRouter.CIDToName[packet.Data.Get <string>("cid")] = name;
                }

                lock (DWRouter.CIDToTitle)
                {
                    var title = (TitleID)gameID;
                    DWRouter.CIDToTitle[packet.Data.Get <string>("cid")] = title;
                }

                // now make a reply.

                /*
                 * var reply = packet.MakeReply(1, false);
                 * reply.ByteBuffer.Write(0x8000000000000000);
                 * reply.ByteBuffer.Write(0);
                 * reply.ByteBuffer.Write((byte)6);
                 * reply.ByteBuffer.Write(1);
                 * reply.ByteBuffer.Write(1);
                 * reply.ByteBuffer.Write(0x12345678);
                 * reply.Send(true);*/
            }
        }