public static void EventSink_AccountLogin(AccountLoginEventArgs e)
        {
            if (!IPLimiter.SocketBlock && !IPLimiter.Verify(e.State.Address))
            {
                e.Accepted     = false;
                e.RejectReason = ALRReason.InUse;

                Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);

                using (StreamWriter op = new StreamWriter("ipLimits.log", true))
                    op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.Now);

                return;
            }

            string un = e.Username;
            string pw = e.Password;

            e.Accepted = false;
            Account acct = Accounts.GetAccount(un) as Account;

            if (acct == null)
            {
                if (AutoAccountCreation && un.Trim().Length > 0)                   // To prevent someone from making an account of just '' or a bunch of meaningless spaces
                {
                    e.State.Account = acct = CreateAccount(e.State, un, pw);
                    e.Accepted      = acct == null ? false : acct.CheckAccess(e.State);

                    if (!e.Accepted)
                    {
                        e.RejectReason = ALRReason.BadComm;
                    }
                }
                else
                {
                    Console.WriteLine("Login: {0}: Invalid username '{1}'", e.State, un);
                    e.RejectReason = ALRReason.Invalid;
                }
            }
            else if (!acct.HasAccess(e.State))
            {
                Console.WriteLine("Login: {0}: Access denied for '{1}'", e.State, un);
                e.RejectReason = (m_LockdownLevel > AccessLevel.Player ? ALRReason.BadComm : ALRReason.BadPass);
            }
            else if (!acct.CheckPassword(pw))
            {
                Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
                e.RejectReason = ALRReason.BadPass;
            }
            else if (acct.Banned)
            {
                Console.WriteLine("Login: {0}: Banned account '{1}'", e.State, un);
                e.RejectReason = ALRReason.Blocked;
            }
            else
            {
                Console.WriteLine("Login: {0}: Valid credentials for '{1}'", e.State, un);
                e.State.Account = acct;
                e.Accepted      = true;

                acct.LogAccess(e.State);
            }

            if (!e.Accepted)
            {
                AccountAttackLimiter.RegisterInvalidAccess(e.State);
            }
        }
Esempio n. 2
0
        public static void EventSink_AccountLogin(AccountLoginEventArgs e)
        {
            // If the login attempt has already been rejected by another event handler
            // then just return
            if (e.Accepted == false)
            {
                return;
            }

            if (!IPLimiter.SocketBlock && !IPLimiter.Verify(e.State.Address))
            {
                e.Accepted     = false;
                e.RejectReason = ALRReason.InUse;

                Utility.PushColor(ConsoleColor.DarkRed);
                Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);
                Utility.PopColor();

                using (StreamWriter op = new StreamWriter("ipLimits.log", true))
                    op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.UtcNow);

                return;
            }

            string un = e.Username;
            string pw = e.Password;

            e.Accepted = false;
            Account acct = Accounts.GetAccount(un) as Account;

            if (acct == null)
            {
                if (AutoAccountCreation && un.Trim().Length > 0) // To prevent someone from making an account of just '' or a bunch of meaningless spaces
                {
                    e.State.Account = acct = CreateAccount(e.State, un, pw);
                    e.Accepted      = acct == null ? false : acct.CheckAccess(e.State);

                    if (!e.Accepted)
                    {
                        e.RejectReason = ALRReason.BadComm;
                    }
                }
                else
                {
                    Utility.PushColor(ConsoleColor.DarkRed);
                    Console.WriteLine("Login: {0}: Invalid username '{1}'", e.State, un);
                    Utility.PopColor();
                    e.RejectReason = ALRReason.Invalid;
                }
            }
            else if (!acct.HasAccess(e.State))
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Login: {0}: Access denied for '{1}'", e.State, un);
                Utility.PopColor();
                e.RejectReason = (m_LockdownLevel > AccessLevel.VIP ? ALRReason.BadComm : ALRReason.BadPass);
            }
            else if (!acct.CheckPassword(pw))
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
                Utility.PopColor();
                e.RejectReason = ALRReason.BadPass;
            }
            else if (acct.Banned)
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Login: {0}: Banned account '{1}'", e.State, un);
                Utility.PopColor();
                e.RejectReason = ALRReason.Blocked;
            }
            else
            {
                Utility.PushColor(ConsoleColor.Green);
                Console.WriteLine("Login: {0}: Valid credentials for '{1}'", e.State, un);
                Console.WriteLine("Client Type: {0}: {1}", e.State, e.State.IsEnhancedClient ? "Enhanced Client" : "Classic Client");
                Utility.PopColor();
                e.State.Account = acct;
                e.Accepted      = true;

                acct.LogAccess(e.State);
            }

            if (!e.Accepted)
            {
                AccountAttackLimiter.RegisterInvalidAccess(e.State);
            }
        }
Esempio n. 3
0
        public static void EventSink_GameLogin(GameLoginEventArgs e)
        {
            if (!IPLimiter.SocketBlock && !IPLimiter.Verify(e.State.Address))
            {
                e.Accepted = false;

                Utility.PushColor(ConsoleColor.DarkRed);
                Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);
                Utility.PopColor();

                using (StreamWriter op = new StreamWriter("ipLimits.log", true))
                    op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.UtcNow);

                return;
            }

            string un = e.Username;
            string pw = e.Password;

            Account acct = Accounts.GetAccount(un) as Account;

            if (acct == null)
            {
                e.Accepted = false;
            }
            else if (!acct.HasAccess(e.State))
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Login: {0}: Access denied for '{1}'", e.State, un);
                Utility.PopColor();
                e.Accepted = false;
            }
            else if (!acct.CheckPassword(pw))
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
                Utility.PopColor();
                e.Accepted = false;
            }
            else if (acct.Banned)
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Login: {0}: Banned account '{1}'", e.State, un);
                Utility.PopColor();
                e.Accepted = false;
            }
            else
            {
                acct.LogAccess(e.State);

                Utility.PushColor(ConsoleColor.Yellow);
                Console.WriteLine("Login: {0}: Account '{1}' at character list", e.State, un);
                Utility.PopColor();
                e.State.Account = acct;
                e.Accepted      = true;
                e.CityInfo      = Siege.SiegeShard ? SiegeStartingCities : StartingCities;
            }

            if (!e.Accepted)
            {
                AccountAttackLimiter.RegisterInvalidAccess(e.State);
            }
        }
Esempio n. 4
0
        public static void EventSink_AccountLogin(AccountLoginEventArgs e)
        {
            if (!IPLimiter.SocketBlock && !IPLimiter.Verify(e.State.Address))
            {
                e.Accepted     = false;
                e.RejectReason = ALRReason.InUse;

                Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);

                using (StreamWriter op = new StreamWriter("ipLimits.log", true))
                    op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.Now);

                // tell other accounts on this IP what's going on
                IPLimiter.Notify(e.State.Address);
                return;
            }

            string un = e.Username;
            string pw = e.Password;

            e.Accepted = false;
            Account acct = Accounts.GetAccount(un);

            if (acct == null)
            {
                if (AutoAccountCreation)
                {
                    e.State.Account = acct = CreateAccount(e.State, un, pw);
                    e.Accepted      = acct == null ? false : acct.CheckAccess(e.State);

                    if (!e.Accepted)
                    {
                        e.RejectReason = ALRReason.BadComm;
                    }
                }
                else
                {
                    Console.WriteLine("Login: {0}: Invalid username '{1}'", e.State, un);
                    e.RejectReason = ALRReason.Invalid;
                }
            }
            else if (IPLimiter.IPStillHot(acct, e.State.Address))
            {
                Console.WriteLine("Login: {0}: Access denied for '{1}'. IP too hot", e.State, un);
                e.RejectReason = ALRReason.InUse;
            }
            else if (!acct.HasAccess(e.State))
            {
                Console.WriteLine("Login: {0}: Access denied for '{1}'", e.State, un);
                e.RejectReason = (m_LockdownLevel > AccessLevel.Player ? ALRReason.BadComm : ALRReason.BadPass);
            }
            else if (!acct.CheckPassword(pw))
            {
                Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
                e.RejectReason = ALRReason.BadPass;
            }
            else if (acct.Banned)
            {
                Console.WriteLine("Login: {0}: Banned account '{1}'", e.State, un);
                e.RejectReason = ALRReason.Blocked;
            }
            else
            {
                Console.WriteLine("Login: {0}: Valid credentials for '{1}'", e.State, un);
                e.State.Account = acct;
                e.Accepted      = true;

                acct.LogAccess(e.State);
                acct.LastLogin = DateTime.Now;
            }

            if (!e.Accepted)
            {
                AccountAttackLimiter.RegisterInvalidAccess(e.State);
            }
        }
Esempio n. 5
0
        public static void EventSink_AccountLogin(AccountLoginEventArgs e)
        {
            if (!IPLimiter.SocketBlock && !IPLimiter.Verify(e.State.Address))
            {
                e.Accepted     = false;
                e.RejectReason = ALRReason.InUse;

                log.Info(String.Format("Login: {0}: Past IP limit threshold", e.State));

                return;
            }

            string un = e.Username;
            string pw = e.Password;

            e.Accepted = false;
            Account acct = Accounts.GetAccount(un);

            if (acct == null)
            {
                if (AutoAccountCreation)
                {
                    e.State.Account = acct = CreateAccount(e.State, un, pw);
                    e.Accepted      = acct == null ? false : acct.CheckAccess(e.State);

                    if (!e.Accepted)
                    {
                        e.RejectReason = ALRReason.BadComm;
                    }
                }
                else
                {
                    log.Warn(String.Format("Login: {0}: Invalid username '{1}'", e.State, un));
                    e.RejectReason = ALRReason.Invalid;
                }
            }
            else if (!acct.HasAccess(e.State))
            {
                log.Error(String.Format("Login: {0}: Access denied for '{1}'", e.State, un));
                e.RejectReason = (m_LockdownLevel > AccessLevel.Player ? ALRReason.BadComm : ALRReason.BadPass);
            }
            else if (!acct.CheckPassword(pw))
            {
                log.Error(String.Format("Login: {0}: Invalid password for '{1}'", e.State, un));
                e.RejectReason = ALRReason.BadPass;
            }
            else if (acct.Banned)
            {
                log.Error(String.Format("Login: {0}: Banned account '{1}'", e.State, un));
                e.RejectReason = ALRReason.Blocked;
            }
            else
            {
                log.Info(String.Format("Login: {0}: Valid credentials for '{1}'", e.State, un));
                e.State.Account = acct;
                e.Accepted      = true;

                acct.LogAccess(e.State);
            }

            if (!e.Accepted)
            {
                AccountAttackLimiter.RegisterInvalidAccess(e.State);
            }
        }
Esempio n. 6
0
        public static void EventSink_GameLogin(GameLoginEventArgs e)
        {
            if (!IPLimiter.SocketBlock && !IPLimiter.Verify(e.State.Address))
            {
                e.Accepted = false;

                Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);

                using (StreamWriter op = new StreamWriter("ipLimits.log", true))
                    op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.Now);

                return;
            }

            string un = e.Username;
            string pw = e.Password;

            Account acct = Accounts.GetAccount(un) as Account;

            if (acct == null)
            {
                e.Accepted = false;
            }
            else if (!acct.HasAccess(e.State))
            {
                Console.WriteLine("Login: {0}: Access denied for '{1}'", e.State, un);
                e.Accepted = false;
            }
            else if (!acct.CheckPassword(pw))
            {
                Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
                e.Accepted = false;
                //*****Logging attempt*****
                try
                {
                    Stream       fileStream   = File.Open("Logs/LoginLogout/" + un + ".log", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
                    StreamWriter writeAdapter = new StreamWriter(fileStream);
                    writeAdapter.WriteLine(String.Format("{0}: Invalid password for {1} on {2}", e.State, un, DateTime.Now));
                    writeAdapter.Close();
                }
                catch
                {
                    Console.WriteLine("Record Error... {0} Login", un);
                }
                //**************************
            }
            else if (acct.Banned)
            {
                Console.WriteLine("Login: {0}: Banned account '{1}'", e.State, un);
                e.Accepted = false;
                //*****Logging attempt*****
                try
                {
                    Stream       fileStream   = File.Open("Logs/LoginLogout/" + un + ".log", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
                    StreamWriter writeAdapter = new StreamWriter(fileStream);
                    writeAdapter.WriteLine(String.Format("{0}: Banned account: {1} on {2}", e.State, un, DateTime.Now));
                    writeAdapter.Close();
                }
                catch
                {
                    Console.WriteLine("Record Error... {0} Login", un);
                }
                //**************************
            }
            else
            {
                acct.LogAccess(e.State);

                Console.WriteLine("Login: {0}: Account '{1}' at character list", e.State, un);
                e.State.Account = acct;
                e.Accepted      = true;
                e.CityInfo      = StartingCities;
            }

            if (!e.Accepted)
            {
                AccountAttackLimiter.RegisterInvalidAccess(e.State);
            }
        }
Esempio n. 7
0
        public static void EventSink_AccountLogin(AccountLoginEventArgs e)
        {
            if (!IPLimiter.SocketBlock && !IPLimiter.Verify(e.State.Address))
            {
                e.Accepted     = false;
                e.RejectReason = ALRReason.InUse;

                Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);

                using (StreamWriter op = new StreamWriter("ipLimits.log", true))
                    op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.Now);

                return;
            }

            string un = e.Username;
            string pw = e.Password;

            e.Accepted = false;
            Account acct = Accounts.GetAccount(un) as Account;

            if (acct == null)
            {
                if (AutoAccountCreation && un.Trim().Length > 0)                        //To prevent someone from making an account of just '' or a bunch of meaningless spaces
                {
                    e.State.Account = acct = CreateAccount(e.State, un, pw);
                    e.Accepted      = acct == null ? false : acct.CheckAccess(e.State);

                    if (!e.Accepted)
                    {
                        e.RejectReason = ALRReason.BadComm;
                    }
                }
                else
                {
                    Console.WriteLine("Login: {0}: Invalid username '{1}'", e.State, un);
                    e.RejectReason = ALRReason.Invalid;
                }
            }
            else if (!acct.HasAccess(e.State))
            {
                Console.WriteLine("Login: {0}: Access denied for '{1}'", e.State, un);
                e.RejectReason = (m_LockdownLevel > AccessLevel.Player ? ALRReason.BadComm : ALRReason.BadPass);
            }
            else if (!acct.CheckPassword(pw))
            {
                Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
                e.RejectReason = ALRReason.BadPass;
                //*****Logging attempt*****
                try
                {
                    Stream       fileStream   = File.Open("Logs/LoginLogout/" + un + ".log", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
                    StreamWriter writeAdapter = new StreamWriter(fileStream);
                    writeAdapter.WriteLine(String.Format("{0}: Invalid password for {1} on {2}", e.State, un, DateTime.Now));
                    writeAdapter.Close();
                }
                catch
                {
                    Console.WriteLine("Record Error... {0} Login", un);
                }
                //**************************
            }
            else if (acct.Banned)
            {
                Console.WriteLine("Login: {0}: Banned account '{1}'", e.State, un);
                e.RejectReason = ALRReason.Blocked;
                //*****Logging attempt*****
                try
                {
                    Stream       fileStream   = File.Open("Logs/LoginLogout/" + un + ".log", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
                    StreamWriter writeAdapter = new StreamWriter(fileStream);
                    writeAdapter.WriteLine(String.Format("{0}: Banned account: {1} on {2}", e.State, un, DateTime.Now));
                    writeAdapter.Close();
                }
                catch
                {
                    Console.WriteLine("Record Error... {0} Login", un);
                }
                //**************************
            }
            else
            {
                Console.WriteLine("Login: {0}: Valid credentials for '{1}'", e.State, un);
                e.State.Account = acct;
                e.Accepted      = true;

                acct.LogAccess(e.State);
            }

            if (!e.Accepted)
            {
                AccountAttackLimiter.RegisterInvalidAccess(e.State);
            }
        }
Esempio n. 8
0
        public static void EventSink_GameLogin(GameLoginEventArgs e)
        {
            if (!IPLimiter.SocketBlock && !IPLimiter.Verify(e.State.Address))
            {
                e.Accepted = false;

                Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);

                using (StreamWriter op = new StreamWriter("ipLimits.log", true))
                    op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.Now);

                return;
            }

            string un = e.Username;
            string pw = e.Password;

            //Account acct = Accounts.GetAccount( un ) as Account;

/*** BEGIN ADDED CODE ***/

            SyncDB.PullAccount(un);

            Account acct = Accounts.GetAccount(un) as Account;

/*
 *                      if (acct == null) {
 * Console.WriteLine("pulling {0}", un);
 *                              System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
 *                              foreach (System.Reflection.Assembly assembly in assemblies) {
 *                                      try {
 *                                              Type syncdb = assembly.GetType("Server.Accounting.SyncDB");
 *                                              if (syncdb != null) {
 * Console.WriteLine("found type SyncDB {0} in {1}", syncdb, assembly);
 *                                                      syncdb.InvokeMember("PullAccount",
 *                                                                                              System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public,
 *                                                                                              null,
 *                                                                                              null,
 *                                                                                              new Object[]{ un });
 * Console.WriteLine("after PullAccount");
 *                                                      break;
 *                                              }
 *                                      } catch (Exception ex) {
 * Console.WriteLine("during PullAccount: {0}", ex);
 *                                      }
 *                              }
 *
 *                              acct = Accounts.GetAccount( un ) as Account;
 *                      }
 */
/*** END ADDED CODE ***/


            if (acct == null)
            {
                e.Accepted = false;
            }
            else if (!acct.HasAccess(e.State))
            {
                Console.WriteLine("Login: {0}: Access denied for '{1}'", e.State, un);
                e.Accepted = false;
            }
            else if (!acct.CheckPassword(pw))
            {
                Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
                e.Accepted = false;
            }
            else if (acct.Banned)
            {
                Console.WriteLine("Login: {0}: Banned account '{1}'", e.State, un);
                e.Accepted = false;
            }
            else
            {
                acct.LogAccess(e.State);

                Console.WriteLine("Login: {0}: Account '{1}' at character list", e.State, un);
                e.State.Account = acct;
                e.Accepted      = true;
                e.CityInfo      = StartingCities;
            }

            if (!e.Accepted)
            {
                AccountAttackLimiter.RegisterInvalidAccess(e.State);
            }
        }