コード例 #1
0
        public static async Task InvokeHandler(AuthPacket reader, AuthSession session)
        {
            var message = (AuthClientMessage)reader.Header.Message;

            Tuple<MethodInfo, Type, AuthChannel> data;

            if (MessageHandlers.TryGetValue(message, out data))
            {
                var handlerObj = Activator.CreateInstance(data.Item2) as ClientPacket;

                handlerObj.Packet = reader;

                await Task.Run(() => handlerObj.Read());

                /*if (handlerObj.IsReadComplete)
                    data.Item1.Invoke(null, new object[] { handlerObj, session });
                else
                    Log.Packet($"Packet read for '{data.Item2.Name}' failed.");*/
                data.Item1.Invoke(null, new object[] { handlerObj, session });
            }
            else
            {
                var msgName = Enum.GetName(typeof(AuthClientMessage), message);

                if (msgName == null)
                    Log.Packet($"Received unknown opcode '0x{message:X}, Length: {reader.Data.Length}'.");
                else
                    Log.Packet($"Packet handler for '{msgName} (0x{message:X}), Length: {reader.Data.Length}' not implemented.");
            }
        }
コード例 #2
0
        public static void OnJoinRequest(AuthPacket packet, Client client)
        {
            var clientSalt = BitConverter.GetBytes(packet.Read<uint>(32));
            var serverSalt = new byte[0].GenerateRandomKey(4);

            client.Session.GenerateSessionKey(clientSalt, serverSalt);

            // Continue if sessionKey is not empty
            if (client.Session.GameAccount.SessionKey != "")
            {
                var joinResponse = new AuthPacket(AuthServerMessage.JoinResponse, AuthChannel.WoW);

                joinResponse.Write(Manager.RealmMgr.RealmList.Count == 0, 1);

                joinResponse.Write(BitConverter.ToUInt32(serverSalt, 0), 32);
                joinResponse.Write(Manager.RealmMgr.RealmList.Count, 5);

                foreach (var realm in Manager.RealmMgr.RealmList)
                {
                    var ip = IPAddress.Parse(realm.Value.IP).GetAddressBytes();
                    var port = BitConverter.GetBytes(realm.Value.Port);

                    Array.Reverse(port);

                    joinResponse.Write(ip);
                    joinResponse.Write(port);
                }

                joinResponse.Write(0, 5);

                client.SendPacket(joinResponse);
            }
        }
コード例 #3
0
ファイル: WebHandler.cs プロジェクト: GlassFace/Arctium-WoW
        public static void OnHTTPReceive(AuthPacket packet, Client client)
        {
            packet.ReadString();

            var path = packet.ReadString();

            Manager.PatchMgr.Send(path, client);
        }
コード例 #4
0
        public void Write(AuthPacket packet)
        {
            packet.WriteFourCC(Data.Type);
            packet.WriteFourCC("\0\0" + Enum.GetName(typeof(Region), AccountRegion));
            packet.Write(Data.Hash.ToByteArray());
            packet.Write(Size == 0 ? Data.Size : Size, 10);

            WriteData(packet);
        }
コード例 #5
0
ファイル: AuthHandler.cs プロジェクト: janbures12/Arctium-WoW
        public static void SendAuthComplete(bool failed, AuthResult result, AuthSession session)
        {
            var complete = new AuthPacket(AuthServerMessage.Complete);

            complete.Write(failed, 1);

            if (failed)
            {
                complete.Write(false, 1);       // false - disable optional modules
                complete.Write(1, 2);           // 1 - enable AuthResults
                complete.Write(result, 16);     // AuthResults (Error codes)
                complete.Write(0x80000000, 32); // Unknown
            }
            else
            {
                complete.Write(0, 3);
                complete.Write(0x80005000, 32); // Ping request, ~10 secs

                var hasOptionalData = true;

                complete.Write(hasOptionalData, 1);

                if (hasOptionalData)
                {
                    var hasConnectionInfo = true;

                    complete.Write(hasConnectionInfo, 1);

                    if (hasConnectionInfo)
                    {
                        complete.Write(25000000, 32);
                        complete.Write(1000, 32);
                    }
                }

                complete.Write(false, 1);

                complete.WriteString("", 8, false); // FirstName not implemented
                complete.WriteString("", 8, false); // LastName not implemented

                complete.Write(session.Account.Id, 32);

                complete.Write(0, 8);
                complete.Write(0, 64);
                complete.Write(0, 8);

                complete.WriteString(session.Account.Email, 5, false, -1);

                complete.Write(0, 64);
                complete.Write(0, 32);

                complete.Write(0, 8);
            }

            session.Send(complete);
        }
コード例 #6
0
        public static bool InvokeHandler(AuthPacket reader, Client client)
        {
            var message = (AuthClientMessage)reader.Header.Message;

            Log.Message(LogType.Packet, "Received Opcode: {0} (0x{0:X}), Length: {1}", message, reader.Data.Length);

            if (MessageHandlers.TryGetValue(Tuple.Create(message, reader.Header.Channel), out HandlePacket packet))
            {
                packet.Invoke(reader, client);

                return true;
            }

            return false;
        }
コード例 #7
0
        void ProcessPacket(int size)
        {
            var packet = new AuthPacket(dataBuffer, size);

            PacketLog.Write <AuthClientMessage>(packet.Header.Message, packet.Data, client.RemoteEndPoint);

            if (packet != null)
            {
                var currentClient = Manager.SessionMgr.Clients.AsParallel().SingleOrDefault(c => c.Value.Session.Equals(this));

                if (currentClient.Value != null)
                {
                    PacketManager.InvokeHandler(packet, currentClient.Value);
                }
            }
        }
コード例 #8
0
        public void Write(AuthPacket packet)
        {
            packet.WriteString(Account.GivenName, 8, false);
            packet.WriteString(Account.Surname, 8, false);

            packet.Write(Account.Id, 32);
            packet.Write((byte)Account.Region, 8);
            packet.Write((ulong)Account.Flags, 64);

            packet.Write((byte)GameAccount.Region, 8);
            packet.WriteString(GameAccount.AccountId + "#" + GameAccount.Index, 5, false, -1);
            packet.Write((ulong)GameAccount.Flags, 64);

            packet.Write(Account.LoginFailures, 32);
            packet.Write(0, 8);
        }
コード例 #9
0
ファイル: RealmHandler.cs プロジェクト: GlassFace/Arctium-WoW
        public static void OnListSubscribeRequest(AuthPacket packet, Client client)
        {
            Log.Debug("Received ListSubscribeRequest.");

            // Battlenet::Client::WoWRealm::ListSubscribeResponse
            var listSubscribeResponse = new AuthPacket(AuthServerMessage.ListSubscribeResponse, AuthChannel.WoWRealm);

            listSubscribeResponse.Write(0, 1);
            listSubscribeResponse.Write(0, 7);

            var realmCounter = 0;

            // Battlenet::Client::WoWRealm::ListUpdate
            foreach (var realm in Manager.RealmMgr.RealmList)
            {
                var listUpdate = new AuthPacket(AuthServerMessage.ListUpdate, AuthChannel.WoWRealm);

                listUpdate.Write(true, 1);
                listUpdate.Write(realm.Value.Category, 32);          // RealmCategory
                listUpdate.Write(0, 32);                             // RealmPopulation, float written as uint32
                listUpdate.Write(realm.Value.State, 8);              // RealmState
                listUpdate.Write(realm.Value.Id, 19);                // RealmId
                listUpdate.Write(0x80000000 + realm.Value.Type, 32); // RealmType
                listUpdate.WriteString(realm.Value.Name, 10, false); // RealmName
                listUpdate.Write(false, 1);                          // Battlenet::VersionString, not used for now
                listUpdate.Write(realm.Value.Flags, 8);              // RealmInfoFlags
                listUpdate.Write(0, 8);
                listUpdate.Write(0, 12);
                listUpdate.Write(0, 8);
                listUpdate.Write(++realmCounter, 32);

                listUpdate.Finish();

                // Write ListUpdate data to ListSubscribeResponse
                listSubscribeResponse.Write(listUpdate.Data);
            }

            // Battlenet::Client::WoWRealm::ListComplete
            var listComplete = new AuthPacket(AuthServerMessage.ListComplete, AuthChannel.WoWRealm);

            listComplete.Finish();

            // Write ListComplete data to ListSubscribeResponse end
            listSubscribeResponse.Write(listComplete.Data);

            client.SendPacket(listSubscribeResponse);
        }
コード例 #10
0
ファイル: AuthHandler.cs プロジェクト: Dramacydal/Arctium-WoW
        public static void OnProofResponse(AuthPacket packet, AuthSession session)
        {
            var moduleCount = packet.Read <byte>(3);

            for (int i = 0; i < moduleCount; i++)
            {
                var dataSize = packet.Read <int>(10);
                var stateId  = packet.Read(1)[0];

                switch (stateId)
                {
                case 1:
                    SendAuthComplete(false, AuthResult.GlobalSuccess, session);
                    break;

                case 2:
                    // Wrong password module data size
                    if (dataSize != 0x121)
                    {
                        return;
                    }

                    var a  = packet.Read(0x80);
                    var m1 = packet.Read(0x20);
                    var clientChallenge = packet.Read(0x80);

                    session.SecureRemotePassword.CalculateU(a);
                    session.SecureRemotePassword.CalculateClientM(a);

                    if (session.SecureRemotePassword.ClientM.Compare(m1))
                    {
                        session.SecureRemotePassword.CalculateServerM(m1);

                        SendProofVerification(session, clientChallenge);
                    }
                    else
                    {
                        SendAuthComplete(true, AuthResult.BadLoginInformation, session);
                    }

                    break;

                default:
                    break;
                }
            }
        }
コード例 #11
0
ファイル: AuthHandler.cs プロジェクト: Dramacydal/Arctium-WoW
        public static void SendProofVerification(AuthSession session, byte[] clientChallenge)
        {
            var proofVerification = new AuthPacket(AuthServerMessage.ProofRequest);

            proofVerification.Write(2, 3);

            session.Modules.ForEach(module =>
            {
                var moduleStart = module.Hash.Substring(0, 2);

                switch (moduleStart)
                {
                case "2e":
                case "85":
                case "20":
                    proofVerification.WriteFourCC("auth");
                    proofVerification.WriteFourCC("\0\0EU");
                    proofVerification.Write(module.Hash.ToByteArray());
                    proofVerification.Write(161, 10);

                    // Flush & write the state id
                    proofVerification.Flush();
                    proofVerification.Write(3, 8);

                    proofVerification.Write(session.SecureRemotePassword.ServerM);
                    proofVerification.Write(session.SecureRemotePassword.S2);

                    break;

                case "5e":
                case "8c":
                case "1a":
                    proofVerification.WriteFourCC("auth");
                    proofVerification.WriteFourCC("\0\0EU");
                    proofVerification.Write(module.Hash.ToByteArray());
                    proofVerification.Write(module.Size, 10);

                    break;

                default:
                    Log.Message(LogType.Error, "Module '{0}' not used in this state", moduleStart);
                    break;
                }
            });

            session.Send(proofVerification);
        }
コード例 #12
0
        public static void OnListSubscribeRequest(AuthPacket packet, Client client)
        {
            Log.Debug("Received ListSubscribeRequest.");

            // Battlenet::Client::WoWRealm::ListSubscribeResponse
            var listSubscribeResponse = new AuthPacket(AuthServerMessage.ListSubscribeResponse, AuthChannel.WoWRealm);

            listSubscribeResponse.Write(0, 1);
            listSubscribeResponse.Write(0, 7);

            var realmCounter = 0;

            // Battlenet::Client::WoWRealm::ListUpdate
            foreach (var realm in Manager.RealmMgr.RealmList)
            {
                var listUpdate = new AuthPacket(AuthServerMessage.ListUpdate, AuthChannel.WoWRealm);

                listUpdate.Write(true, 1);
                listUpdate.Write(realm.Value.Category, 32);          // RealmCategory
                listUpdate.Write(0, 32);                             // RealmPopulation, float written as uint32
                listUpdate.Write(realm.Value.State, 8);              // RealmState
                listUpdate.Write(realm.Value.Id, 19);                // RealmId
                listUpdate.Write(0x80000000 + realm.Value.Type, 32); // RealmType
                listUpdate.WriteString(realm.Value.Name, 10, false); // RealmName
                listUpdate.Write(false, 1);                          // Battlenet::VersionString, not used for now
                listUpdate.Write(realm.Value.Flags, 8);              // RealmInfoFlags
                listUpdate.Write(0, 8);
                listUpdate.Write(0, 12);
                listUpdate.Write(0, 8);
                listUpdate.Write(++realmCounter, 32);

                listUpdate.Finish();

                // Write ListUpdate data to ListSubscribeResponse
                listSubscribeResponse.Write(listUpdate.Data);
            }

            // Battlenet::Client::WoWRealm::ListComplete
            var listComplete = new AuthPacket(AuthServerMessage.ListComplete, AuthChannel.WoWRealm);

            listComplete.Finish();

            // Write ListComplete data to ListSubscribeResponse end
            listSubscribeResponse.Write(listComplete.Data);

            client.SendPacket(listSubscribeResponse);
        }
コード例 #13
0
ファイル: PacketManager.cs プロジェクト: jwoff78/Project-WoW
        public static bool InvokeHandler(AuthPacket reader, Client client)
        {
            var message = (AuthClientMessage)reader.Header.Message;

            Log.Packet($"Received Opcode: {message} (0x{message:X}), Length: {reader.Data.Length}");

            HandlePacket packet;

            if (MessageHandlers.TryGetValue(Tuple.Create(message, reader.Header.Channel), out packet))
            {
                packet.Invoke(reader, client);

                return(true);
            }

            return(false);
        }
コード例 #14
0
 private void DoSending()
 {
     while (this.working)
     {
         AuthPacket ap = outAPQueue.Dequeue();
         if (ap != null)
         {
             int sentLength = clientSocket.Send(ap.GetPacketBuffer());
             if (sentLength < 1)
             {
                 MLogger.NetworkLogger.Error("Auth client socket sent 0 bytes : " + this.clientSocket.Handle);
                 this.StopSession();
             }
         }
         Thread.Sleep(10);
     }
 }
コード例 #15
0
        public override void WriteData(AuthPacket packet)
        {
            packet.Flush();
            packet.Write(State, 8);

            if (State == PasswordModuleState.ServerChallenge)
            {
                packet.Write(SecureRemotePassword.I);
                packet.Write(SecureRemotePassword.S);
                packet.Write(SecureRemotePassword.B);
                packet.Write(SecureRemotePassword.S2);
            }
            else if (State == PasswordModuleState.ValidateProof)
            {
                packet.Write(SecureRemotePassword.ServerM);
                packet.Write(SecureRemotePassword.S2);
            }
        }
コード例 #16
0
ファイル: AuthSocket.cs プロジェクト: YunTM/YTMVPN_Server
        private static void Working()
        {
            while (true)
            {
                byte[]   buffer   = new byte[4096]; //省略MTU和缓冲区设置 是的 我也先作死new
                EndPoint remoteEP = new IPEndPoint(IPAddress.Any, 0);
                //接收数据
                int count = socket.ReceiveFrom(buffer, ref remoteEP);

                //省略对分段包的处理
                AuthPacket ap = new AuthPacket(buffer);

#if DEBUG
                LogHelper.Logging("\nRecvAuthPacket" +
                                  "\n\tSize: " + ap.RawData.Length +
                                  "\n\tState: " + BitConverter.ToString(new byte[] { (byte)ap.State }) +
                                  "\n");
#endif

                //握手
                switch (ap.State)
                {
                case AuthPacketState.Hello:
                    //回应Hello_ACK
                    ap.State     = AuthPacketState.Hello_ACK;
                    ap.LogicAddr = config.Logic_LocalAddr;
                    socket.SendTo(ap.RawData, remoteEP);
                    break;

                case AuthPacketState.Hello_Succsss:
                    //加入转发表 这里还要加判断之前客户端是否有请求 Hello
                    ForwardSrv.ForwardTable.Add(new ForwardItem(ap.LogicAddr, remoteEP));
                    ap.State = AuthPacketState.Hello_Done;
                    socket.SendTo(ap.RawData, remoteEP);
                    break;

                default:
#if DEBUG
                    LogHelper.Logging("Unknow AuthPacketState");
#endif
                    break;
                }
            }
        }
コード例 #17
0
        protected override void OnAuthServerPacketReceive(AuthClient client, AuthPacket packet)
        {
            if (packet.ID != AuthPacketEnum.SERVER_KEEPALIVE)
            {
                WriteConsole.WriteLine("[SYNC_RECEIVED_PACKET]:  " + packet.ID);
            }
            switch (packet.ID)
            {
            case AuthPacketEnum.SERVER_KEEPALIVE:     //KeepAlive
            {
            }
            break;

            case AuthPacketEnum.SERVER_CONNECT:
            {
            }
            break;

            case AuthPacketEnum.RECEIVES_USER_UID:
                break;

            case AuthPacketEnum.SEND_DISCONNECT_PLAYER:
            {
                uint UID = packet.Message.ID;

                var player = GetPlayerByUID(UID);

                if (player != null)
                {
                    DisconnectPlayer(player);
                }
            }
            break;

            case AuthPacketEnum.SERVER_COMMAND:
                break;

            default:
                WriteConsole.WriteLine("[AUTH_PACKET]:  " + packet.ID);
                break;
            }
        }
コード例 #18
0
ファイル: Form1.cs プロジェクト: Hurobaki/CSharp-Project
        private void connect_Click(object sender, EventArgs e)
        {
            AuthPacket ap = new AuthPacket(login_input.Text, password_input.Text);

            Packet.Send(ap, stream);

            Thread.Sleep(100);

            Packet paquet = Packet.Receive(stream);

            bool flag = false;

            if (paquet is LoginPacket)
            {
                LoginPacket bp = (LoginPacket)paquet;

                if (bp.value == 1)
                {
                    MessageBox.Show("Welcome " + login_input.Text, "Connexion successful !", MessageBoxButtons.OK);
                    login = login_input.Text;
                    flag  = true;
                }
                else if (bp.value == 2)
                {
                    label_log.ForeColor = Color.Red;
                    label_log.Text      = "Wrong password, try again.";
                }
                else
                {
                    label_log.ForeColor = Color.Red;
                    label_log.Text      = "User not found, try again.";
                }
            }

            if (flag)
            {
                Form2 f2 = new Form2();
                f2.Text = "Connected as " + login;
                f2.Show();
                this.Hide();
            }
        }
コード例 #19
0
        /// <summary>
        /// Manuseia Comunicação do Cliente
        /// </summary>
        private void HandleClient(object obj)
        {
            //Recebe cliente a partir do parâmetro
            TcpClient tcpClient = (TcpClient)obj;

            NetworkStream clientStream = tcpClient.GetStream();

            #region READ ON CONNECT INICIAL

            AuthPacket packet = ReceivePacket(clientStream);

            var client = new AuthClient(tcpClient, packet);

            Clients.Add(client);
            Console.Title = string.Format("Pangya Fresh Up! AuthServer - LOGIN: {0}, GAMES: {1}, MESSENGER: {2}", Clients.Model.Where(c => c.Data.Type == AuthClientTypeEnum.LoginServer).ToList().Count, Clients.Model.Where(c => c.Data.Type == AuthClientTypeEnum.GameServer).ToList().Count, Clients.Model.Where(c => c.Data.Type == AuthClientTypeEnum.MessengerServer).ToList().Count);
            ClientConnected(client);

            OnPacketReceived?.Invoke(client, packet);

            #endregion

            //Escuta contínuamente as mensagens dos clientes (Servidores) enquanto estiver conectado
            while (tcpClient.Connected)
            {
                try
                {
                    packet = ReceivePacket(clientStream);

                    OnPacketReceived?.Invoke(client, packet);
                }
                catch
                {
                    //Desconecta client
                    DisconnectClient(client);
                }
            }
            //Caso o Client não estiver mais conectado
            if (tcpClient.Connected)
            {
                DisconnectClient(client);
            }
        }
コード例 #20
0
        protected override void OnAuthServerPacketReceive(AuthClient client, AuthPacket packet)
        {
            switch (packet.ID)
            {
            case AuthPacketEnum.SERVER_KEEPALIVE:
                break;

            case AuthPacketEnum.SERVER_CONNECT:
                break;

            case AuthPacketEnum.RECEIVES_USER_UID:
                break;

            case AuthPacketEnum.SEND_DISCONNECT_PLAYER:
            {
                uint UID = packet.Message.ID;

                var player = GetPlayerByUID(UID);

                if (player != null)
                {
                    DisconnectPlayer(player);
                }
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_TICKET:
                break;

            case AuthPacketEnum.SERVER_RELEASE_BOXRANDOM:
                break;

            case AuthPacketEnum.SERVER_RELEASE_NOTICE:
                break;

            case AuthPacketEnum.SERVER_COMMAND:
            default:
                WriteConsole.WriteLine("[AUTH_PACKET]:  " + packet.ID);
                break;
            }
        }
コード例 #21
0
ファイル: AuthHandler.cs プロジェクト: janbures12/Arctium-WoW
        public static void OnProofResponse(AuthPacket packet, AuthSession session)
        {
            var moduleCount = packet.Read<byte>(3);

            for (int i = 0; i < moduleCount; i++)
            {
                var dataSize = packet.Read<int>(10);
                var state = packet.Read<PasswordModuleState>(8);

                switch (state)
                {
                    case PasswordModuleState.ClientChallenge:
                        SendAuthComplete(false, AuthResult.GlobalSuccess, session);
                        break;
                    case PasswordModuleState.ClientProof:
                        // Wrong password module data size
                        if (dataSize != 0x121)
                            return;

                        var a = packet.Read(0x80);
                        var m1 = packet.Read(0x20);
                        var clientChallenge = packet.Read(0x80);

                        session.SecureRemotePassword.CalculateU(a);
                        session.SecureRemotePassword.CalculateClientM(a);

                        if (session.SecureRemotePassword.ClientM.Compare(m1))
                        {
                            session.SecureRemotePassword.CalculateServerM(m1);

                            SendProofValidation(session, clientChallenge);
                        }
                        else
                            SendAuthComplete(true, AuthResult.BadLoginInformation, session);

                        break;
                    default:
                        break;
                }
            }
        }
コード例 #22
0
        internal static async Task <bool> checkClientAuth(string authToken)
        {
            AuthPacket p = new AuthPacket()
            {
                ClientAuth = authToken
            };
            var rsp = await SendandRecieveHTTPData(p);

            if (rsp.Header == "good_client")
            {
                return(true);
            }
            if (rsp.Header == "bad_client")
            {
                return(false);
            }
            else
            {
                throw new Exception($"server error: {rsp.Header}");
            }
        }
コード例 #23
0
        protected static void HandlePlayerDisconnect(AuthPacket packet)
        {
            int UID = packet.Message.ID;

            var check  = Server.Players.Model.Where(c => c.GetUID == UID);
            var member = db.Pangya_Member.FirstOrDefault(c => c.UID == UID);

            if (check.Any())
            {
                Server.Players.Remove(check.First());
            }
            if (member != null)
            {
                member.Logon = 0;

                db.SaveChanges();

                packet.ID = AuthPacketEnum.SEND_DISCONNECT_PLAYER;
                Server.SendToAll(packet);
            }
        }
コード例 #24
0
        protected override void OnHandle(IPacket packet, NetState netState, ServerWorldState worldState)
        {
            AuthPacket         incomingPacket = (AuthPacket)packet;
            PlayerSessionModel session        = worldState.GetPlayerSession(incomingPacket.SessionId);

            //worldState.AuthenticateClient(netState, incomingPacket.SessionId, incomingPacket.CharacterId);

            if (session != null)
            {
                IPAddress sessionIPAddress = IPAddress.Parse(session.ClientAddress);

                if (netState.Address == sessionIPAddress || sessionIPAddress.Equals(IPAddress.IPv6Loopback) || sessionIPAddress.Equals(IPAddress.Loopback))
                {
                    netState.Id = session.Id;
                    ServerCharacter selectedChar = worldState.LoadCharacter(session.CharacterID);
                    if (selectedChar != null)
                    {
                        selectedChar.Owner         = netState;
                        selectedChar.Owner.WorldId = selectedChar.Id;
                        worldState.AddCharacter(selectedChar);
                        netState.WriteConsole("Session confirmed, character: {0} selected.", selectedChar.Id);
                    }
                    else
                    {
                        netState.WriteConsole("AUTHERROR: Invalid characterID: {0}.", session.CharacterID);
                        netState.Dispose();
                    }
                }
                else
                {
                    netState.WriteConsole("AUTHERROR: Session failed, adress '{0}' did not match session address '{1}'.", netState.Address.ToString(), sessionIPAddress.ToString());
                    netState.Dispose();
                }
            }
            else
            {
                netState.WriteConsole("AUTHERROR: Invalid sessionID '{0}'.", incomingPacket.SessionId);
                netState.Dispose();
            }
        }
コード例 #25
0
        public static void OnRealmUpdate(AuthPacket packet, AuthSession session)
        {
            Log.Message(LogType.Debug, "Received realm update.");

            var complete = new AuthPacket(AuthServerMessage.Complete, AuthChannel.WoW);

            complete.Flush();
            complete.Write(0, 8);

            var realmCounter = 0;

            foreach (var realm in Manager.Realms.RealmList)
            {
                var realmlist = new AuthPacket(AuthServerMessage.RealmUpdate, AuthChannel.WoW);

                realmlist.Write(true, 1);
                realmlist.Write(1, 32);
                realmlist.Write(0f, 32);
                realmlist.Write(realm.Value.Flags, 8);
                realmlist.Write(realm.Value.Id, 19);
                realmlist.Write(0x80000000 + realm.Value.Type, 32);
                realmlist.WriteString(realm.Value.Name, 10, false);
                realmlist.Write(false, 1);
                realmlist.Write(realm.Value.Status, 8);
                realmlist.Write(0, 12);
                realmlist.Write(0, 8);
                realmlist.Write(0, 32);
                realmlist.Write(++realmCounter, 8);

                // End
                realmlist.Flush();
                realmlist.Write(new byte[] { 0x43, 0x02 });
                realmlist.Finish();

                complete.Write(realmlist.Data);
            }

            session.Send(complete);
        }
コード例 #26
0
ファイル: AuthHandler.cs プロジェクト: TagsRocks/Arctium-WoW
        public static void SendProofRequest(Client client)
        {
            var session = client.Session;

            client.Modules = Manager.ModuleMgr.Modules.Where(m => m.System == client.OS);

            var thumbprintModule = client.Modules.SingleOrDefault(m => m.Name == "Thumbprint");
            var passwordModule   = client.Modules.SingleOrDefault(m => m.Name == "Password");

            var proofRequest = new AuthPacket(AuthServerMessage.ProofRequest);

            // Send two modules (Thumbprint & Password).
            proofRequest.Write(2, 3);

            /// Thumbprint module
            Manager.ModuleMgr.WriteModuleHeader(client, proofRequest, thumbprintModule);

            // Data
            proofRequest.Write(thumbprintModule.Data.ToByteArray());

            session.SecureRemotePassword = new SRP6a(session.Account.Salt, session.Account.Email, session.Account.PasswordVerifier);
            session.SecureRemotePassword.CalculateB();

            /// Password module
            Manager.ModuleMgr.WriteModuleHeader(client, proofRequest, passwordModule);

            // State
            proofRequest.Flush();
            proofRequest.Write(PasswordModuleState.ServerChallenge, 8);

            // Data
            proofRequest.Write(session.SecureRemotePassword.I);
            proofRequest.Write(session.SecureRemotePassword.S);
            proofRequest.Write(session.SecureRemotePassword.B);
            proofRequest.Write(session.SecureRemotePassword.S2);

            client.SendPacket(proofRequest);
        }
コード例 #27
0
        public static void OnRealmUpdate(AuthPacket packet, Client client)
        {
            Log.Message(LogType.Debug, "Received realm update.");

            var complete = new AuthPacket(AuthServerMessage.RealmComplete, AuthChannel.WoW);

            complete.Flush();
            complete.Write(0, 8);

            var realmCounter = 0;

            foreach (var realm in Manager.RealmMgr.RealmList)
            {
                var realmlist = new AuthPacket(AuthServerMessage.RealmUpdate, AuthChannel.WoW);

                realmlist.Write(true, 1);
                realmlist.Write(1, 32);
                realmlist.Write(0f, 32);
                realmlist.Write(realm.Value.Flags, 8);
                realmlist.Write(realm.Value.Id, 19);
                realmlist.Write(0x80000000 + realm.Value.Type, 32);
                realmlist.WriteString(realm.Value.Name, 10, false);
                realmlist.Write(false, 1);
                realmlist.Write(realm.Value.Status, 8);
                realmlist.Write(0, 12);
                realmlist.Write(0, 8);
                realmlist.Write(0, 32);
                realmlist.Write(++realmCounter, 8);

                // End
                realmlist.Write(new byte[] { 0x43, 0x02 });
                realmlist.Finish();

                complete.Write(realmlist.Data);
            }

            client.SendPacket(complete);
        }
コード例 #28
0
ファイル: AuthHandler.cs プロジェクト: GlassFace/Arctium-WoW
        public static void SendProofRequest(Client client)
        {
            var session = client.Session;

            client.Modules = Manager.ModuleMgr.Modules.Where(m => m.System == client.OS);

            var thumbprintModule = client.Modules.SingleOrDefault(m => m.Name == "Thumbprint");
            var passwordModule = client.Modules.SingleOrDefault(m => m.Name == "Password");

            var proofRequest = new AuthPacket(AuthServerMessage.ProofRequest);

            // Send two modules (Thumbprint & Password).
            proofRequest.Write(2, 3);

            /// Thumbprint module
            Manager.ModuleMgr.WriteModuleHeader(client, proofRequest, thumbprintModule);

            // Data 
            proofRequest.Write(thumbprintModule.Data.ToByteArray());

            session.SecureRemotePassword = new SRP6a(session.Account.Salt, session.Account.Email, session.Account.PasswordVerifier);
            session.SecureRemotePassword.CalculateB();

            /// Password module
            Manager.ModuleMgr.WriteModuleHeader(client, proofRequest, passwordModule);

            // State
            proofRequest.Flush();
            proofRequest.Write(PasswordModuleState.ServerChallenge, 8);

            // Data
            proofRequest.Write(session.SecureRemotePassword.I);
            proofRequest.Write(session.SecureRemotePassword.S);
            proofRequest.Write(session.SecureRemotePassword.B);
            proofRequest.Write(session.SecureRemotePassword.S2);

            client.SendPacket(proofRequest);
        }
コード例 #29
0
        public static void OnJoinRequest(AuthPacket packet, Client client)
        {
            var clientSalt = BitConverter.GetBytes(packet.Read <uint>(32));
            var serverSalt = new byte[0].GenerateRandomKey(4);

            client.Session.GenerateSessionKey(clientSalt, serverSalt);

            // Continue if sessionKey is not empty
            if (client.Session.GameAccount.SessionKey != "")
            {
                var joinResponse = new AuthPacket(AuthServerMessage.JoinResponse, AuthChannel.WoWRealm);

                joinResponse.Write(Manager.RealmMgr.RealmList.Count == 0, 1);

                joinResponse.Write(BitConverter.ToUInt32(serverSalt, 0), 32);

                // Battlenet::WoW::IP4AddressList
                joinResponse.Write(Manager.RealmMgr.RealmList.Count, 5);

                foreach (var realm in Manager.RealmMgr.RealmList)
                {
                    var ip   = IPAddress.Parse(realm.Value.IP).GetAddressBytes();
                    var port = BitConverter.GetBytes(realm.Value.Port);

                    Array.Reverse(port);

                    joinResponse.Write(ip);
                    joinResponse.Write(port);
                }

                // Battlenet::WoW::IP6AddressList, not implemented
                joinResponse.Write(0, 5);

                client.SendPacket(joinResponse);
            }
        }
コード例 #30
0
        public void Send(AuthPacket packet)
        {
            try
            {
                packet.Finish();

                if (packet.Header != null)
                {
                    PacketLog.Write <AuthServerMessage>(packet.Header.Message, packet.Data, client.RemoteEndPoint);
                }

                if (Crypt != null && Crypt.IsInitialized)
                {
                    Crypt.Encrypt(packet.Data, packet.Data.Length);
                }

                var socketEventargs = new SocketAsyncEventArgs();

                socketEventargs.SetBuffer(packet.Data, 0, packet.Data.Length);

                socketEventargs.Completed     += SendCompleted;
                socketEventargs.UserToken      = packet;
                socketEventargs.RemoteEndPoint = client.RemoteEndPoint;
                socketEventargs.SocketFlags    = SocketFlags.None;

                client.Send(packet.Data);
            }
            catch (Exception ex)
            {
                Dispose();

                ExceptionLog.Write(ex);

                Log.Error(ex.Message);
            }
        }
コード例 #31
0
        public static void OnJoinRequest(AuthPacket packet, AuthSession session)
        {
            var clientSalt = BitConverter.GetBytes(packet.Read <uint>(32));
            var serverSalt = new byte[0].GenerateRandomKey(4);

            session.GenerateSessionKey(clientSalt, serverSalt);

            // Continue if sessionKey is not empty
            if (session.Account.SessionKey != "")
            {
                var joinResponse = new AuthPacket(AuthServerMessage.JoinResponse, AuthChannel.WoW);

                joinResponse.Write(Manager.Realms.RealmList.Count == 0, 1);

                joinResponse.Write(BitConverter.ToUInt32(serverSalt, 0), 32);
                joinResponse.Write(Manager.Realms.RealmList.Count * 2, 5);

                foreach (var realm in Manager.Realms.RealmList)
                {
                    var ip   = IPAddress.Parse(realm.Value.IP).GetAddressBytes();
                    var port = BitConverter.GetBytes(realm.Value.Port);

                    Array.Reverse(port);

                    joinResponse.Write(ip);
                    joinResponse.Write(port);
                    joinResponse.Write(ip);
                    joinResponse.Write(port);
                }

                joinResponse.Flush();
                joinResponse.Write(0, 5);

                session.Send(joinResponse);
            }
        }
コード例 #32
0
        public static async Task SendProofValidation(AuthSession session, byte[] clientChallenge)
        {
            var proofRequest = new ProofRequest { AccountRegion = session.Account.Region };

            proofRequest.Modules.Add(new PasswordModule
            {
                Data = Manager.ModuleMgr.Modules.SingleOrDefault(m => m.Name == "Password" && m.System == session.Platform),
                State = PasswordModuleState.ValidateProof,
                AccountRegion = proofRequest.AccountRegion,
                SecureRemotePassword = session.SecureRemotePassword, 
                Size = 161
            });

            /// SelectGameAccount module
            if (session.GameAccounts?.Count > 1)
            {
                var gameAccountBuffer = new AuthPacket();

                gameAccountBuffer.Write(0, 8);
                gameAccountBuffer.Write(session.GameAccounts.Count, 8);

                session.GameAccounts.ForEach(ga =>
                {
                    gameAccountBuffer.Write(ga.Region, 8);
                    gameAccountBuffer.WriteString(ga.Game + ga.Index, 8, false);
                });

                gameAccountBuffer.Finish();

                proofRequest.Modules.Add(new SelectGameAccountModule
                {
                    Data = Manager.ModuleMgr.Modules.SingleOrDefault(m => m.Name == "SelectGameAccount" && m.System == session.Platform),
                    AccountRegion = proofRequest.AccountRegion,
                    GameAccountData = gameAccountBuffer.Data,
                    Size = (uint)gameAccountBuffer.Data.Length
                });
            }
            else
                proofRequest.Modules.Add(new RiskFingerprintModule
                {
                    Data = Manager.ModuleMgr.Modules.SingleOrDefault(m => m.Name == "RiskFingerprint" && m.System == session.Platform)
                });

            await session.Send(proofRequest);
        }
コード例 #33
0
        public static void OnDisconnect(AuthPacket packet, Client client)
        {
            Log.Message(LogType.Debug, "Client '{0}' disconnected.", client.ConnectionInfo);

            Manager.SessionMgr.RemoveClient(client.Id);
        }
コード例 #34
0
ファイル: AuthSession.cs プロジェクト: GlassFace/Arctium-WoW
        void ProcessPacket(int size)
        {
            var packet = new AuthPacket(dataBuffer, size);
            
            PacketLog.Write<AuthClientMessage>(packet.Header.Message, packet.Data, client.RemoteEndPoint);

            if (packet != null)
            {
                var currentClient = Manager.SessionMgr.Clients.AsParallel().SingleOrDefault(c => c.Value.Session.Equals(this));

                if (currentClient.Value != null)
                    PacketManager.InvokeHandler(packet, currentClient.Value);
            }
        }
コード例 #35
0
 public void SendPacket(AuthPacket packet)
 {
     Session?.Send(packet);
 }
コード例 #36
0
 public void Write(AuthPacket packet)
 {
     packet.Write(Threshold, 32);
     packet.Write(Rate, 32);
 }
コード例 #37
0
ファイル: AuthSession.cs プロジェクト: GlassFace/Arctium-WoW
        public void Send(AuthPacket packet)
        {
            try
            {
                packet.Finish();

                if (packet.Header != null)
                    PacketLog.Write<AuthServerMessage>(packet.Header.Message, packet.Data, client.RemoteEndPoint);

                if (Crypt != null && Crypt.IsInitialized)
                    Crypt.Encrypt(packet.Data, packet.Data.Length);

                var socketEventargs = new SocketAsyncEventArgs();

                socketEventargs.SetBuffer(packet.Data, 0, packet.Data.Length);

                socketEventargs.Completed += SendCompleted;
                socketEventargs.UserToken = packet;
                socketEventargs.RemoteEndPoint = client.RemoteEndPoint;
                socketEventargs.SocketFlags = SocketFlags.None;

                client.Send(packet.Data);
            }
            catch (Exception ex)
            {
                Dispose();

                ExceptionLog.Write(ex);

                Log.Error(ex.Message);
            }
        }
コード例 #38
0
ファイル: AuthHandler.cs プロジェクト: janbures12/Arctium-WoW
        public static void SendProofValidation(AuthSession session, byte[] clientChallenge)
        {
            var passwordModule = session.Modules.SingleOrDefault(m => m.Name == "Password");
            var riskFingerprintModule = session.Modules.SingleOrDefault(m => m.Name == "RiskFingerprint");

            var proofValidation = new AuthPacket(AuthServerMessage.ProofRequest);

            // Send two modules (Password & RiskFingerprint).
            proofValidation.Write(2, 3);

            /// Password module
            Manager.Module.WriteModuleHeader(session, proofValidation, passwordModule, 161);

            // State
            proofValidation.Flush();
            proofValidation.Write(PasswordModuleState.ValidateProof, 8);

            // Data
            proofValidation.Write(session.SecureRemotePassword.ServerM);
            proofValidation.Write(session.SecureRemotePassword.S2);

            /// RiskFingerprint module
            Manager.Module.WriteModuleHeader(session, proofValidation, riskFingerprintModule);

            session.Send(proofValidation);
        }
コード例 #39
0
        public static void OnProofResponse(AuthPacket packet, Client client)
        {
            var session = client.Session;

            var moduleCount = packet.Read<byte>(3);

            for (int i = 0; i < moduleCount; i++)
            {
                var dataSize = packet.Read<int>(10);
                var state = packet.Read<PasswordModuleState>(8);

                switch (state)
                {
                    case PasswordModuleState.ClientChallenge:
                        if (session.GameAccount == null && session.GameAccounts.Count >= 1)
                        {
                            if (session.GameAccounts.Count > 1)
                            {
                                var region = packet.Read<Regions>(8);
                                var gameLength = packet.Read<byte>(8);
                                var game = packet.ReadString(gameLength);

                                session.GameAccount = session.GameAccounts.SingleOrDefault(ga => ga.Game + ga.Index == game && ga.Region == region);

                                var riskFingerprint = new AuthPacket(AuthServerMessage.ProofRequest);

                                riskFingerprint.Write(1, 3);

                                Manager.ModuleMgr.WriteRiskFingerprint(client, riskFingerprint);

                                client.SendPacket(riskFingerprint);

                                return;
                            }
                            else
                                session.GameAccount = session.GameAccounts[0];
                        }

                        if (!session.GameAccount.IsOnline)
                        {
                            if (session.GameAccount == null)
                                SendAuthComplete(true, AuthResult.NoGameAccount, client);
                            else
                                SendAuthComplete(false, AuthResult.GlobalSuccess, client);
                        }

                        break;
                    case PasswordModuleState.ClientProof:
                        // Wrong password module data size
                        if (dataSize != 0x121)
                            return;

                        var a = packet.Read(0x80);
                        var m1 = packet.Read(0x20);
                        var clientChallenge = packet.Read(0x80);

                        session.SecureRemotePassword.CalculateU(a);
                        session.SecureRemotePassword.CalculateClientM(a);

                        if (session.SecureRemotePassword.ClientM.Compare(m1))
                        {
                            session.SecureRemotePassword.CalculateServerM(m1);

                            // Assign valid game accounts for the account
                            if (session.Account.GameAccounts != null)
                                session.GameAccounts = session.Account.GameAccounts.Where(ga => ga.Game == client.Game && ga.Region == session.Account.Region).ToList();

                            SendProofValidation(client, clientChallenge);
                        }
                        else
                            SendAuthComplete(true, AuthResult.BadLoginInformation, client);

                        break;
                    default:
                        break;
                }
            }
        }
コード例 #40
0
        protected override void OnAuthServerPacketReceive(AuthClient client, AuthPacket packet)
        {
            if (packet.ID != AuthPacketEnum.SERVER_KEEPALIVE)
            {
                WriteConsole.WriteLine("[SYNC_RECEIVED_PACKET]:  " + packet.ID);
            }
            switch (packet.ID)
            {
            case AuthPacketEnum.SERVER_KEEPALIVE:     //KeepAlive
            {
            }
            break;

            case AuthPacketEnum.SERVER_CONNECT:
            {
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_CHAT:
            {
                string GetNickName = packet.Message.PlayerNick;
                string GetMessage  = packet.Message.PlayerMessage;
                GameTools.PacketCreator.ChatText(GetNickName, GetMessage, true);
            }
            break;

            case AuthPacketEnum.RECEIVES_USER_UID:
                break;

            case AuthPacketEnum.SEND_DISCONNECT_PLAYER:
            {
                uint UID = packet.Message.ID;

                var player = GetPlayerByUID(UID);

                if (player != null)
                {
                    DisconnectPlayer(player);
                }
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_TICKET:
            {
                string GetNickName = packet.Message.GetNickName;
                string GetMessage  = packet.Message.GetMessage;
                using (var result = new PangyaBinaryWriter())
                {
                    result.Write(new byte[] { 0xC9, 0x00 });
                    result.WritePStr(GetNickName);
                    result.WritePStr(GetMessage);
                    SendToAll(result.GetBytes());
                }
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_BOXRANDOM:
            {
                string GetMessage = packet.Message.GetMessage;
                Notice(GetMessage);
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_NOTICE_GM:
            {
                string Nick    = packet.Message.GetNick;
                string message = packet.Message.mensagem;
                HandleStaffSendNotice(Nick, message);
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_NOTICE:
            {
                string message = packet.Message.mensagem;
                using (var result = new PangyaBinaryWriter())
                {
                    result.Write(new byte[] { 0x42, 0x00 });
                    result.WritePStr("Aviso: " + message);
                    SendToAll(result.GetBytes());
                }
            }
            break;

            case AuthPacketEnum.PLAYER_LOGIN_RESULT:
            {
                LoginResultEnum loginresult = packet.Message.Type;

                if (loginresult == LoginResultEnum.Error || loginresult == LoginResultEnum.Exception)
                {
                    WriteConsole.WriteLine("[CLIENT_ERROR]: Sorry", ConsoleColor.Red);
                    return;
                }
            }
            break;

            case AuthPacketEnum.SERVER_COMMAND:
                break;

            default:
                WriteConsole.WriteLine("[AUTH_PACKET]:  " + packet.ID);
                break;
            }
        }
コード例 #41
0
 public override void WriteData(AuthPacket packet)
 {
     packet.Write(ModuleData);
 }
コード例 #42
0
 protected static void HandleWinBoxRandomNotice(AuthPacket packet)
 {
     Server.Send(AuthClientTypeEnum.GameServer, packet);
 }
コード例 #43
0
 protected static void HandleTicket(AuthPacket packet)
 {
     Server.Send(AuthClientTypeEnum.GameServer, packet);
 }
コード例 #44
0
ファイル: MiscHandler.cs プロジェクト: GlassFace/Arctium-WoW
        public static void OnDisconnect(AuthPacket packet, Client client)
        {
            Log.Debug($"Client '{client.ConnectionInfo}' disconnected.");

            Manager.SessionMgr.RemoveClient(client.Id);
        }
コード例 #45
0
 /// <summary>
 /// É Disparado quando um packet é recebido do AuthServer
 /// </summary>
 private void AuthServer_OnPacketReceived(AuthClient authClient, AuthPacket packet)
 {
     OnAuthServerPacketReceive(authClient, packet);
 }
コード例 #46
0
 protected abstract void OnAuthServerPacketReceive(AuthClient client, AuthPacket packet);
コード例 #47
0
        public override void RunCommand(string[] Command)
        {
            string  ReadCommand;
            GPlayer P;

            if (Command.Length > 1)
            {
                ReadCommand = Command[1];
            }
            else
            {
                ReadCommand = "";
            }
            switch (Command[0])
            {
            case "cls":
            case "limpar":
            case "clear":
            {
                Console.Clear();
            }
            break;

            case "kickuid":
            {
                P = (GPlayer)GetPlayerByUID(uint.Parse(ReadCommand.ToString()));
                if (P == null)
                {
                    WriteConsole.WriteLine("[SYSTEM_COMMAND]: THIS UID IS NOT ONLINE!", ConsoleColor.Red);
                    break;
                }
                DisconnectPlayer(P);
            }
            break;

            case "kickname":
            {
                P = (GPlayer)GetPlayerByNickname(ReadCommand);
                if (P == null)
                {
                    WriteConsole.WriteLine("[SYSTEM_COMMAND]: THIS NICKNAME IS NOT ONLINE!", ConsoleColor.Red);
                    return;
                }
                DisconnectPlayer(P);
            }
            break;

            case "kickuser":
            {
                P = (GPlayer)GetPlayerByUsername(ReadCommand);
                if (P == null)
                {
                    WriteConsole.WriteLine("[SYSTEM_COMMAND]: THIS USERNAME IS NOT ONLINE!", ConsoleColor.Red);
                    return;
                }
                DisconnectPlayer(P);
            }
            break;

            case "topnotice":
            {
                if (ReadCommand.Length > 0)
                {
                    Notice(ReadCommand);
                }
            }
            break;

            case "lobby":
            case "listalobby":
            case "canais":
            case "listacanais":
            case "showlobby":
            case "showchannel":
            {
                LobbyList.ShowChannel();
            }
            break;

            case "comandos":
            case "commands":
            case "ajuda":
            case "help":
            {
                ShowHelp();
            }
            break;

            case "reload":
            case "reconfigurar":
            case "reconfig":
            {
                Ini  = new IniFile(ConfigurationManager.AppSettings["ServerConfig"]);
                Data = new ServerSettings
                {
                    Name            = Ini.ReadString("Config", "Name", "Pippin"),
                    Version         = Ini.ReadString("Config", "Version", "SV_GS_Release_2.0"),
                    UID             = Ini.ReadUInt32("Config", "UID", 20201),
                    MaxPlayers      = Ini.ReadUInt32("Config", "MaxPlayers", 3000),
                    Port            = Ini.ReadUInt32("Config", "Port", 20201),
                    IP              = Ini.ReadString("Config", "IP", "127.0.0.1"),
                    Property        = Ini.ReadUInt32("Config", "Property", 2048),
                    BlockFunc       = Ini.ReadInt64("Config", "BlockFuncSystem", 0),
                    EventFlag       = Ini.ReadInt16("Config", "EventFlag", 0),
                    ImgNo           = Ini.ReadInt16("Config", "Icon", 1),
                    GameVersion     = "824.00",
                    Type            = AuthClientTypeEnum.GameServer,
                    AuthServer_Ip   = Ini.ReadString("Config", "AuthServer_IP", "127.0.0.1"),
                    AuthServer_Port = Ini.ReadInt32("Config", "AuthServer_Port", 7997),
                    Key             = "3493ef7ca4d69f54de682bee58be4f93"
                };
                ShowLog          = Ini.ReadBool("Config", "PacketLog", false);
                Messenger_Active = Ini.ReadBool("Config", "Messenger_Server", false);

                var packet = new AuthPacket()
                {
                    ID      = AuthPacketEnum.SERVER_UPDATE,
                    Message = new
                    {
                        _data = Data
                    }
                };


                this.AuthServer.Send(packet);
            }
            break;

            default:
            {
                WriteConsole.WriteLine("[SYSTEM_COMMAND]: Sorry Unknown Command, type 'help' to get the list of commands", ConsoleColor.Red);
            }
            break;
            }
        }
コード例 #48
0
        async Task ProcessPacket(byte[] data, int size)
        {
            var packet = new AuthPacket(data, size);
            
            if (PacketLog.Initialized)
                PacketLog.Write<AuthClientMessage>(packet.Header.Message, packet.Data, client.RemoteEndPoint);

            if (packet != null)
                await PacketManager.InvokeHandler(packet, this);
        }
コード例 #49
0
        static void TcpServer_OnPacketReceived(AuthClient client, AuthPacket packet)
        {
            WriteConsole.WriteLine($"[SYNC_CALL_PACKET]: [{packet.ID}, {client.Data.Name}]", ConsoleColor.Cyan);
            switch (packet.ID)
            {
            case AuthPacketEnum.SERVER_KEEPALIVE:
            {
                client.Send(new AuthPacket()
                    {
                        ID = AuthPacketEnum.SERVER_KEEPALIVE
                    });
            }
            break;

            case AuthPacketEnum.SERVER_CONNECT:
            {
                var response = new AuthPacket();

                if (client.Data.Key != AuthKey)
                {
                    response.Message = new
                    {
                        Success   = false,
                        Exception = "Chave de autenticação inválida"
                    };

                    Server.Send(client, response);
                    Server.DisconnectClient(client);
                }
                else
                {
                    response.Message = new
                    {
                        Success = true,
                    };

                    Server.Send(client, response);
                }
            }
            break;

            case AuthPacketEnum.RECEIVES_USER_UID:
            {
                HandlePlayerUID(packet);
            }
            break;

            case AuthPacketEnum.DISCONNECT_PLAYER_ALL_ON_SERVERS:
            {
                HandlePlayerDisconnect(packet);
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_CHAT:
            {
                byte Type = packet.Message.IsGM;
                if (Type == 15 || Type == 4)
                {
                    var response = new AuthPacket
                    {
                        ID      = AuthPacketEnum.SERVER_RELEASE_CHAT,
                        Message = new { PlayerNick = packet.Message.GetNickName, PlayerMessage = packet.Message.GetMessage }
                    };
                    Server.Send(AuthClientTypeEnum.GameServer, response);
                }
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_TICKET:
            {
                HandleTicket(packet);
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_BOXRANDOM:
            {
                HandleWinBoxRandomNotice(packet);
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_NOTICE_GM:
            {
                HandleNotice(packet);
            }
            break;

            case AuthPacketEnum.SERVER_RELEASE_NOTICE:
            {
                HandleNotice(packet);
            }
            break;

            case AuthPacketEnum.LOGIN_RESULT:
            {
                HandleLogin(client, packet);
            }
            break;

            case AuthPacketEnum.SERVER_COMMAND:
                break;

            default:
                WriteConsole.WriteLine("[SYNC_REQUEST_PACKET_UNK]: " + packet.ID);
                break;
            }
        }
コード例 #50
0
        public static void SendAuthComplete(bool failed, AuthResult result, Client client)
        {
            client.Session.GameAccount.IsOnline = true;

            var complete = new AuthPacket(AuthServerMessage.Complete);

            complete.Write(failed, 1);

            if (failed)
            {
                complete.Write(false, 1);       // false - disable optional modules
                complete.Write(1, 2);           // 1 - enable AuthResults
                complete.Write(result, 16);     // AuthResults (Error codes)
                complete.Write(0x80000000, 32); // Unknown
            }
            else
            {
                // No modules supported here.
                complete.Write(0, 3);

                var pingTimeout = 0x80005000;
                var hasRegulatorRules = true;

                complete.Write(pingTimeout, 32);
                complete.Write(hasRegulatorRules, 1);

                if (hasRegulatorRules)
                {
                    var hasRegulatorInfo = true;

                    complete.Write(hasRegulatorInfo, 1);

                    if (hasRegulatorInfo)
                    {
                        var threshold = 25000000;
                        var rate = 1000;

                        complete.Write(threshold, 32);
                        complete.Write(rate, 32);
                    }
                }

                var haslogonInfo = true;
                var account = client.Session.Account;
                var gameAccount = client.Session.GameAccount;

                complete.Write(!haslogonInfo, 1);

                complete.WriteString(account.GivenName, 8, false);
                complete.WriteString(account.Surname, 8, false);

                complete.Write(account.Id, 32);
                complete.Write((byte)account.Region, 8);
                complete.Write((ulong)account.Flags, 64);

                complete.Write((byte)gameAccount.Region, 8);
                complete.WriteString(gameAccount.AccountId + "#" + gameAccount.Index, 5, false, -1);
                complete.Write((ulong)gameAccount.Flags, 64);

                complete.Write(account.LoginFailures, 32);
                complete.Write(0, 8);
            }

            client.SendPacket(complete);
        }
コード例 #51
0
        public async Task Send(AuthPacket packet)
        {
            try
            {
                await Task.Run(() => packet.Finish());

                client.Send(packet.Data);
            }
            catch (Exception ex)
            {
                Dispose();

                Log.Error(ex.Message);
            }
        }
コード例 #52
0
ファイル: AuthHandler.cs プロジェクト: TagsRocks/Arctium-WoW
        public static void SendAuthComplete(bool failed, AuthResult result, Client client)
        {
            var complete = new AuthPacket(AuthServerMessage.Complete);

            complete.Write(failed, 1);

            if (failed)
            {
                complete.Write(false, 1);       // false - disable optional modules
                complete.Write(1, 2);           // 1 - enable AuthResults
                complete.Write(result, 16);     // AuthResults (Error codes)
                complete.Write(0x80000000, 32); // Unknown
            }
            else
            {
                // No modules supported here.
                complete.Write(0, 3);

                var pingTimeout       = 0x80005000;
                var hasRegulatorRules = true;

                complete.Write(pingTimeout, 32);
                complete.Write(hasRegulatorRules, 1);

                if (hasRegulatorRules)
                {
                    var hasRegulatorInfo = true;

                    complete.Write(hasRegulatorInfo, 1);

                    if (hasRegulatorInfo)
                    {
                        var threshold = 25000000;
                        var rate      = 1000;

                        complete.Write(threshold, 32);
                        complete.Write(rate, 32);
                    }
                }

                var haslogonInfo = true;
                var account      = client.Session.Account;
                var gameAccount  = client.Session.GameAccount;

                complete.Write(!haslogonInfo, 1);

                complete.WriteString(account.GivenName, 8, false);
                complete.WriteString(account.Surname, 8, false);

                complete.Write(account.Id, 32);
                complete.Write((byte)account.Region, 8);
                complete.Write((ulong)account.Flags, 64);

                complete.Write((byte)gameAccount.Region, 8);
                complete.WriteString(gameAccount.AccountId + "#" + gameAccount.Index, 5, false, -1);
                complete.Write((ulong)gameAccount.Flags, 64);

                complete.Write(account.LoginFailures, 32);
                complete.Write(0, 8);
            }

            client.SendPacket(complete);
        }
コード例 #53
0
        public void WriteRiskFingerprint(Client client, AuthPacket packet)
        {
            var riskFingerprintModule = client.Modules.SingleOrDefault(m => m.Name == "RiskFingerprint");

            WriteModuleHeader(client, packet, riskFingerprintModule);
        }
コード例 #54
0
ファイル: AuthHandler.cs プロジェクト: TagsRocks/Arctium-WoW
        public static void OnProofResponse(AuthPacket packet, Client client)
        {
            var session = client.Session;

            var moduleCount = packet.Read <byte>(3);

            for (int i = 0; i < moduleCount; i++)
            {
                var dataSize = packet.Read <int>(10);
                var state    = packet.Read <PasswordModuleState>(8);

                switch (state)
                {
                case PasswordModuleState.ClientChallenge:
                    if (session.GameAccount == null && session.GameAccounts.Count >= 1)
                    {
                        if (session.GameAccounts.Count > 1)
                        {
                            var region     = packet.Read <Regions>(8);
                            var gameLength = packet.Read <byte>(8);
                            var game       = packet.ReadString(gameLength);

                            session.GameAccount = session.GameAccounts.SingleOrDefault(ga => ga.Game + ga.Index == game && ga.Region == region);

                            var riskFingerprint = new AuthPacket(AuthServerMessage.ProofRequest);

                            riskFingerprint.Write(1, 3);

                            Manager.ModuleMgr.WriteRiskFingerprint(client, riskFingerprint);

                            client.SendPacket(riskFingerprint);

                            return;
                        }
                        else
                        {
                            session.GameAccount = session.GameAccounts[0];
                        }
                    }

                    if (session.GameAccount == null)
                    {
                        SendAuthComplete(true, AuthResult.NoGameAccount, client);
                    }
                    else if (!session.GameAccount.IsOnline)
                    {
                        SendAuthComplete(false, AuthResult.GlobalSuccess, client);

                        client.Session.GameAccount.IsOnline = true;
                    }

                    break;

                case PasswordModuleState.ClientProof:
                    // Wrong password module data size
                    if (dataSize != 0x121)
                    {
                        return;
                    }

                    var a  = packet.Read(0x80);
                    var m1 = packet.Read(0x20);
                    var clientChallenge = packet.Read(0x80);

                    session.SecureRemotePassword.CalculateU(a);
                    session.SecureRemotePassword.CalculateClientM(a);

                    if (session.SecureRemotePassword.ClientM.Compare(m1))
                    {
                        session.SecureRemotePassword.CalculateServerM(m1);

                        // Assign valid game accounts for the account
                        if (session.Account.GameAccounts != null)
                        {
                            session.GameAccounts = session.Account.GameAccounts.Where(ga => ga.Game == client.Game && ga.Region == session.Account.Region).ToList();
                        }

                        SendProofValidation(client, clientChallenge);
                    }
                    else
                    {
                        SendAuthComplete(true, AuthResult.BadLoginInformation, client);
                    }

                    break;

                default:
                    break;
                }
            }
        }
コード例 #55
0
        public static void SendProofValidation(Client client, byte[] clientChallenge)
        {
            var passwordModule = client.Modules.SingleOrDefault(m => m.Name == "Password");
            var selectedGameAccountModule = client.Modules.SingleOrDefault(m => m.Name == "SelectGameAccount");

            var proofValidation = new AuthPacket(AuthServerMessage.ProofRequest);

            var moduleCount = 2;

            proofValidation.Write(moduleCount, 3);

            /// Password module
            Manager.ModuleMgr.WriteModuleHeader(client, proofValidation, passwordModule, 161);

            // State
            proofValidation.Flush();
            proofValidation.Write(PasswordModuleState.ValidateProof, 8);

            // Data
            proofValidation.Write(client.Session.SecureRemotePassword.ServerM);
            proofValidation.Write(client.Session.SecureRemotePassword.S2);

            /// SelectGameAccount module
            if (client.Session.GameAccounts.Count > 1)
            {
                var gameAccountBuffer = new AuthPacket();

                gameAccountBuffer.Write(0, 8);
                gameAccountBuffer.Write(client.Session.GameAccounts.Count, 8);

                client.Session.GameAccounts.ForEach(ga =>
                {
                    gameAccountBuffer.Write(ga.Region, 8);
                    gameAccountBuffer.WriteString(ga.Game + ga.Index, 8, false);
                });

                gameAccountBuffer.Finish();

                Manager.ModuleMgr.WriteModuleHeader(client, proofValidation, selectedGameAccountModule, gameAccountBuffer.Data.Length);

                // Data
                proofValidation.Write(gameAccountBuffer.Data);
            }
            else
                Manager.ModuleMgr.WriteRiskFingerprint(client, proofValidation);

            client.SendPacket(proofValidation);
        }
コード例 #56
0
ファイル: MainPage.xaml.cs プロジェクト: quad341/zpd
        private AuthPacket GetAuthPacket()
        {
            Debug.Assert(-1 != _clientId);
            var packet = new AuthPacket {Timeout = AuthTolkenTimeout.SixtySeconds, ClientId = _clientId};

            DateTime now = DateTime.UtcNow;
            int numAdjustedSeconds = 60 + (60 - (now.Second%60));
            DateTime adjustedTime = now.AddSeconds(numAdjustedSeconds);
            // need granularity down to seconds
            var adjustedTimeToSecond = new DateTime(adjustedTime.Year,
                                                    adjustedTime.Month,
                                                    adjustedTime.Day,
                                                    adjustedTime.Hour,
                                                    adjustedTime.Minute,
                                                    adjustedTime.Second);

            string computedAuthTolken =
                Sha1HashOfString(adjustedTimeToSecond.ToString("yyyy-MM-dd:HH:mm:ss") + _settings.Password +
                                 _packetCount++);

            packet.Offset = numAdjustedSeconds;
            packet.AuthTolken = computedAuthTolken;
            return packet;
        }
コード例 #57
0
        public static void OnPing(AuthPacket packet, Client client)
        {
            var pong = new AuthPacket(AuthServerMessage.Pong, AuthChannel.Creep);

            client.SendPacket(pong);
        }
コード例 #58
0
 public virtual void WriteData(AuthPacket packet) { }
コード例 #59
0
        public static void OnInformationRequest(AuthPacket packet, Client client)
        {
            var session = client.Session;
            if (!Manager.GetState())
            {
                AuthHandler.SendAuthComplete(true, AuthResult.ServerBusy, client);
                return;
            }

            var game = packet.ReadFourCC();
            var os = packet.ReadFourCC();
            var language = packet.ReadFourCC();

            Log.Message(LogType.Debug, "Program: {0}", game);
            Log.Message(LogType.Debug, "Platform: {0}", os);
            Log.Message(LogType.Debug, "Locale: {0}", language);

            var componentCount = packet.Read<int>(6);

            for (int i = 0; i < componentCount; i++)
            {
                var program = packet.ReadFourCC();
                var platform = packet.ReadFourCC();
                var build = packet.Read<int>(32);

                Log.Message(LogType.Debug, "Program: {0}", program);
                Log.Message(LogType.Debug, "Platform: {0}", platform);
                Log.Message(LogType.Debug, "Locale: {0}", build);

                if (DB.Auth.Components.Any(c => c.Program == program && c.Platform == platform && c.Build == build))
                    continue;

                if (!DB.Auth.Components.Any(c => c.Program == program))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidProgram, client);
                    return;
                }

                if (!DB.Auth.Components.Any(c => c.Platform == platform))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidPlatform, client);
                    return;
                }

                if (!DB.Auth.Components.Any(c => c.Build == build))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidGameVersion, client);
                    return;
                }
            }

            var hasAccountName = packet.Read<bool>(1);

            if (hasAccountName)
            {
                var accountLength = packet.Read<int>(9) + 3;
                var accountName = packet.ReadString(accountLength);
                var account = DB.Auth.Accounts.SingleOrDefault(a => a.Email == accountName);

                // First account lookup on database
                if ((session.Account = account) != null)
                {
                    // Global base account.
                    session.Account.IP = session.GetClientInfo();
                    session.Account.Language = language;

                    // Assign the possible game accounts based on the game.
                    //session.GameAccounts.ForEach(ga => ga.OS = os);

                    // Save the last changes
                    DB.Auth.Update();

                    // Used for module identification.
                    client.Game = game;
                    client.OS = os;

                    AuthHandler.SendProofRequest(client);
                }
                else
                    AuthHandler.SendAuthComplete(true, AuthResult.BadLoginInformation, client);
            }
        }
コード例 #60
0
ファイル: MiscHandler.cs プロジェクト: samriang/Arctium-WoW
        public static void OnInformationRequest(AuthPacket packet, Client client)
        {
            var session = client.Session;

            if (!Manager.GetState())
            {
                AuthHandler.SendAuthComplete(true, AuthResult.ServerBusy, client);
                return;
            }

            var game     = packet.ReadFourCC();
            var os       = packet.ReadFourCC();
            var language = packet.ReadFourCC();

            Log.Message(LogType.Debug, "Program: {0}", game);
            Log.Message(LogType.Debug, "Platform: {0}", os);
            Log.Message(LogType.Debug, "Locale: {0}", language);

            var componentCount = packet.Read <int>(6);

            for (int i = 0; i < componentCount; i++)
            {
                var program  = packet.ReadFourCC();
                var platform = packet.ReadFourCC();
                var build    = packet.Read <int>(32);

                Log.Message(LogType.Debug, "Program: {0}", program);
                Log.Message(LogType.Debug, "Platform: {0}", platform);
                Log.Message(LogType.Debug, "Locale: {0}", build);

                if (DB.Auth.Any <Component>(c => c.Program == program && c.Platform == platform && c.Build == build))
                {
                    continue;
                }

                if (!DB.Auth.Any <Component>(c => c.Program == program))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidProgram, client);
                    return;
                }

                if (!DB.Auth.Any <Component>(c => c.Platform == platform))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidPlatform, client);
                    return;
                }

                if (!DB.Auth.Any <Component>(c => c.Build == build))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidGameVersion, client);
                    return;
                }
            }

            var hasAccountName = packet.Read <bool>(1);

            if (hasAccountName)
            {
                var accountLength = packet.Read <int>(9) + 3;
                var accountName   = packet.ReadString(accountLength);
                var account       = DB.Auth.Single <Account>(a => a.Email == accountName);

                // First account lookup on database
                if ((session.Account = account) != null)
                {
                    // Global base account.
                    session.Account.IP       = session.GetClientInfo();
                    session.Account.Language = language;

                    // Assign the possible game accounts based on the game.
                    //session.GameAccounts.ForEach(ga => ga.OS = os);

                    // Save the last changes
                    DB.Auth.Update(session.Account, "IP", session.Account.IP, "Language", session.Account.Language);

                    // Used for module identification.
                    client.Game = game;
                    client.OS   = os;

                    AuthHandler.SendProofRequest(client);
                }
                else
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.BadLoginInformation, client);
                }
            }
        }