Ejemplo n.º 1
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");
        }
Ejemplo n.º 2
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}]");

            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]");
            }
        }