internal static void OnAuthRealmList(AuthServerSession session, byte[] data)
        {
            Log.Print(LogType.AuthServer, $"[{session.ConnectionSocket.RemoteEndPoint}] CMD_AUTH_REALMLIST");

            // Get Realms
            var realms = MainProgram.Database.GetRealms();

            session.SendPacket(new PsAuthRealmList(realms));
        }
Beispiel #2
0
 internal static void CallHandler(AuthServerSession authServerSession, AuthCMD opcode, byte[] data)
 {
     if (MCallbacks.ContainsKey(opcode))
     {
         MCallbacks[opcode](authServerSession, data);
     }
     else
     {
         Log.Print(LogType.AuthServer, $"Missing handler: {opcode}");
         AuthServerSession.DumpPacket(data, authServerSession);
     }
 }
Beispiel #3
0
        public static void DumpPacket(byte[] data, AuthServerSession client)
        {
            int    j;
            string buffer = "";

            if (client == null)
            {
                Log.Print("DEBUG: Packet Dump");
            }
            else
            {
                Log.Print($"[{client.ConnectionSocket.RemoteEndPoint}] DEBUG: Packet Dump");
            }

            if (data.Length % 16 == 0)
            {
                for (j = 0; j <= data.Length - 1; j += 16)
                {
                    Log.Print($"| {BitConverter.ToString(data, j, 16).Replace("-", " ")} | " +
                              Encoding.ASCII.GetString(data, j, 16)
                              .Replace("\t", "?")
                              .Replace("\b", "?")
                              .Replace("\r", "?")
                              .Replace("\f", "?")
                              .Replace("\n", "?") + " |");
                }
            }
            else
            {
                for (j = 0; j <= data.Length - 1 - 16; j += 16)
                {
                    Log.Print($"| {BitConverter.ToString(data, j, 16).Replace("-", " ")} | " +
                              Encoding.ASCII.GetString(data, j, 16)
                              .Replace("\t", "?")
                              .Replace("\b", "?")
                              .Replace("\r", "?")
                              .Replace("\f", "?")
                              .Replace("\n", "?") + " |");
                }

                Log.Print($"| {BitConverter.ToString(data, j, data.Length % 16).Replace("-", " ")} " +
                          $"{buffer.PadLeft((16 - data.Length % 16) * 3, ' ')}" +
                          "| " + Encoding.ASCII.GetString(data, j, data.Length % 16)
                          .Replace("\t", "?")
                          .Replace("\b", "?")
                          .Replace("\r", "?")
                          .Replace("\f", "?")
                          .Replace("\n", "?") +
                          $"{buffer.PadLeft(16 - data.Length % 16, ' ')}|");
            }
        }
Beispiel #4
0
        internal static void OnAuthLogonProof(AuthServerSession session, AuthLogonProof handler)
        {
            session.Srp.ClientEphemeral = handler.A.ToPositiveBigInteger();
            session.Srp.ClientProof     = handler.M1.ToPositiveBigInteger();

            if (session.Srp.ClientProof == session.Srp.GenerateClientProof())
            {
                MainProgram.Database.SetSessionKey(session.AccountName, session.Srp.SessionKey.ToProperByteArray());
                session.SendData(new PsAuthLogonProof(session.Srp, AccountState.OK));
                return;
            }

            var dataResponse = new byte[2];

            dataResponse[0] = (byte)AuthCMD.CMD_AUTH_LOGON_PROOF;
            dataResponse[1] = (byte)AccountState.UNKNOWN_ACCOUNT;
            session.SendData(dataResponse, "RS_LOGON_PROOF-WRONGPASS");
        }
Beispiel #5
0
        /// <summary>
        ///     Send packet Realm List
        /// </summary>
        /// <param name="session"></param>
        /// <param name="data"></param>
        internal static void OnAuthRealmList(AuthServerSession session, byte[] data)
        {
            var realms = MainProgram.Database.GetRealms();

            session.SendPacket(new PsAuthRealmList(realms, session.AccountName));
        }
Beispiel #6
0
        internal static void OnAuthLogonChallenge(AuthServerSession session, AuthLogonChallenge packet)
        {
            Log.Print(LogType.AuthServer,
                      $"[{session.ConnectionSocket.RemoteEndPoint}] CMD_AUTH_LOGON_CHALLENGE [{packet.Username}], " +
                      $"WoW Version [{packet.Version}.{packet.Build}] {packet.Country}");

            var dataResponse = new byte[2];

            dataResponse[0] = (byte)LoginErrorCode.RESPONSE_FAILURE;

            switch (packet.Version)
            {
            case "1.12.1":
            case "1.12.2":
            case "1.12.3":
            {
                AccountState accState;
                try
                {
                    // Get Account info
                    _user = MainProgram.Database.GetAccount(packet.Username);

                    if (_user != null)
                    {
                        accState = _user.bannet_at != null ? AccountState.BANNED : AccountState.OK;
                    }
                    else
                    {
                        accState = AccountState.UNKNOWN_ACCOUNT;
                    }
                }
                catch (Exception e)
                {
                    accState = AccountState.DBBUSY;
                    var trace = new StackTrace(e, true);
                    Log.Print(LogType.Error,
                              $"{e.Message}: {e.Source}" +
                              $"{trace.GetFrame(trace.FrameCount - 1).GetFileName()}:{trace.GetFrame(trace.FrameCount - 1).GetFileLineNumber()}");
                }

                switch (accState)
                {
                case AccountState.OK:
                    Log.Print(LogType.AuthServer,
                              $"[{session.ConnectionSocket.RemoteEndPoint}] Account found [{packet.Username}]");
                    session.AccountName = _user?.username;
                    if (_user != null)
                    {
                        session.Srp = new Srp6(_user.username.ToUpper(), _user.password.ToUpper());
                    }
                    session.SendData(new PsAuthLogonChallange(session.Srp, AccountState.OK));
                    return;

                case AccountState.UNKNOWN_ACCOUNT:
                    dataResponse[1] = (byte)AccountState.UNKNOWN_ACCOUNT;
                    break;

                case AccountState.BANNED:
                    dataResponse[1] = (byte)AccountState.BANNED;
                    break;

                case AccountState.NOTIME:
                    dataResponse[1] = (byte)AccountState.NOTIME;
                    break;

                case AccountState.ALREADYONLINE:
                    dataResponse[1] = (byte)AccountState.ALREADYONLINE;
                    break;

                case AccountState.FAILED:
                    dataResponse[1] = (byte)AccountState.FAILED;
                    break;

                case AccountState.BAD_PASS:
                    dataResponse[1] = (byte)AccountState.BAD_PASS;
                    break;

                case AccountState.DBBUSY:
                    dataResponse[1] = (byte)AccountState.DBBUSY;
                    break;

                case AccountState.BADVERSION:
                    dataResponse[1] = (byte)AccountState.BADVERSION;
                    break;

                case AccountState.DOWNLOADFILE:
                    dataResponse[1] = (byte)AccountState.DOWNLOADFILE;
                    break;

                case AccountState.SUSPENDED:
                    dataResponse[1] = (byte)AccountState.SUSPENDED;
                    break;

                case AccountState.PARENTALCONTROL:
                    dataResponse[1] = (byte)AccountState.PARENTALCONTROL;
                    break;

                default:
                    dataResponse[1] = (byte)AccountState.FAILED;
                    break;
                }

                break;
            }

            default:
                dataResponse[1] = (byte)AccountState.BADVERSION;
                break;
            }

            session.SendData(dataResponse, "CMD_AUTH_LOGON_CHALLENGE");
        }
        internal static void OnAuthLogonChallenge(AuthServerSession session, AuthLogonChallenge packet)
        {
            Log.Print(LogType.AuthServer,
                      $"[{session.ConnectionSocket.RemoteEndPoint}] CMD_AUTH_LOGON_CHALLENGE [{packet.Username}], WoW Version [{packet.Version}.{packet.Build}]");

            byte[] dataResponse;

            if (packet.Version == null)
            {
                Log.Print(LogType.Error, $"[{session.ConnectionSocket.RemoteEndPoint}] Invalid Client");

                dataResponse    = new byte[2];
                dataResponse[0] = (byte)AuthCMD.CMD_AUTH_LOGON_PROOF;
                dataResponse[1] = (byte)AccountState.BADVERSION;
                session.SendData(dataResponse, "CMD_AUTH_LOGON_CHALLENGE [LOGIN_BADVERSION]");
            }
            else if (packet.Version == "1.12.1")
            {
                AccountState accState;
                try
                {
                    // Get Account info
                    _user = MainProgram.Database.GetAccount(packet.Username);

                    if (_user != null)
                    {
                        accState = _user.bannet_at != null ? AccountState.BANNED : AccountState.OK;
                    }
                    else
                    {
                        accState = AccountState.UNKNOWN_ACCOUNT;
                    }
                }
                catch (Exception)
                {
                    accState = AccountState.DBBUSY;
                }

                switch (accState)
                {
                case AccountState.OK:
                    Log.Print(LogType.AuthServer, $"[{session.ConnectionSocket.RemoteEndPoint}] Account found [{packet.Username}]");
                    session.AccountName = _user?.username;
                    if (_user != null)
                    {
                        session.Srp = new Srp6(_user.username.ToUpper(), _user.password.ToUpper());
                    }
                    session.SendData(new PsAuthLogonChallange(session.Srp, AccountState.OK));
                    break;

                case AccountState.UNKNOWN_ACCOUNT:
                    dataResponse    = new byte[2];
                    dataResponse[0] = (byte)AuthCMD.CMD_AUTH_LOGON_PROOF;
                    dataResponse[1] = (byte)AccountState.UNKNOWN_ACCOUNT;
                    session.SendData(dataResponse, "CMD_AUTH_LOGON_CHALLENGE [LOGIN_UNKNOWN_ACCOUNT]");
                    break;

                case AccountState.BANNED:
                    dataResponse    = new byte[2];
                    dataResponse[0] = (byte)AuthCMD.CMD_AUTH_LOGON_PROOF;
                    dataResponse[1] = (byte)AccountState.BANNED;
                    session.SendData(dataResponse, "CMD_AUTH_LOGON_CHALLENGE [LOGIN_BANNED]");
                    break;

                case AccountState.NOTIME:
                    dataResponse    = new byte[2];
                    dataResponse[0] = (byte)AuthCMD.CMD_AUTH_LOGON_PROOF;
                    dataResponse[1] = (byte)AccountState.NOTIME;
                    session.SendData(dataResponse, "CMD_AUTH_LOGON_CHALLENGE [LOGIN_NOTIME]");
                    break;

                case AccountState.ALREADYONLINE:
                    dataResponse    = new byte[2];
                    dataResponse[0] = (byte)AuthCMD.CMD_AUTH_LOGON_PROOF;
                    dataResponse[1] = (byte)AccountState.ALREADYONLINE;
                    session.SendData(dataResponse, "CMD_AUTH_LOGON_CHALLENGE [LOGIN_ALREADYONLINE]");
                    break;

                default:
                    dataResponse    = new byte[2];
                    dataResponse[0] = (byte)AuthCMD.CMD_AUTH_LOGON_PROOF;
                    dataResponse[1] = (byte)AccountState.FAILED;
                    session.SendData(dataResponse, "CMD_AUTH_LOGON_CHALLENGE [LOGIN_FAILED]");
                    break;
                }
            }
            else
            {
                Log.Print(LogType.Error, $"[{session.ConnectionSocket.RemoteEndPoint}] Wrong Version [{packet.Version}.{packet.Build}]");

                dataResponse    = new byte[2];
                dataResponse[0] = (byte)AuthCMD.CMD_AUTH_LOGON_PROOF;
                dataResponse[1] = (byte)AccountState.BADVERSION;
                session.SendData(dataResponse, "CMD_AUTH_LOGON_CHALLENGE [LOGIN_BADVERSION]");
            }
        }