Ejemplo n.º 1
0
        private void LoginPasswordInput(SessionBase session)
        {
            //Only Process on CR
            if (session.GetStatus() != EnumUserStatus.CR_TERMINATED_STRING_AVAILABLE)
            {
                return;
            }

            //Get The Password
            session.Password = Encoding.ASCII.GetString(session.InputBuffer.ToArray());
            session.InputBuffer.SetLength(0);
            session.SessionState = EnumSessionState.LoginPasswordDisplay;

            //See if the Account exists
            var account = _accountRepository.GetAccountByUsernameAndPassword(session.Username, session.Password);

            if (account == null)
            {
                session.SendToClient("\r\n|B||RED|Invalid Credentials|RESET|\r\n".EncodeToANSIArray());
                session.Username          = "";
                session.EchoSecureEnabled = false;
                session.SessionState      = EnumSessionState.LoginUsernameDisplay;
                return;
            }

            //Populate Session Variables from mbbsemu.db
            session.Username      = account.userName;
            session.UsrAcc.credat = account.createDate.ToDosDate();

            //Lookup User in BBSUSR.db
            var accountBtrieve = _globalCache.Get <BtrieveFileProcessor>("ACCBB-PROCESSOR");

            var result = accountBtrieve.PerformOperation(0, new Span <byte>(new UserAccount
            {
                userid = Encoding.ASCII.GetBytes(session.Username.ToUpper()),
                psword = Encoding.ASCII.GetBytes("<<HASHED>>")
            }.Data).Slice(0, 55), EnumBtrieveOperationCodes.AcquireEqual);

            if (!result)
            {
                session.SendToClient("\r\n|B||RED|USER MISMATCH IN BBSUSR.DAT -- PLEASE NOTIFY SYSOP|RESET|\r\n".EncodeToANSIArray());
                session.Username          = "";
                session.EchoSecureEnabled = false;
                session.SessionState      = EnumSessionState.LoginUsernameDisplay;
                return;
            }

            //Populate Session Variables from BBSUSR.db
            session.UsrAcc.sex = accountBtrieve.GetRecord().ElementAt(213);

            //Start Session
            session.SessionState      = EnumSessionState.LoginRoutines;
            session.EchoSecureEnabled = false;
            session.SessionTimer.Start();

            if (_accountKeyRepository.GetAccountKeysByUsername(session.Username).Any(x => x.accountKey == "SYSOP"))
            {
                session.SendToClient("|RED||B|/SYS to access SYSOP commands\r\n".EncodeToANSIArray());
            }
        }
Ejemplo n.º 2
0
        public bool ProcessCommand(ReadOnlySpan <byte> command, ushort channelNumber, PointerDictionary <SessionBase> sessions, Dictionary <string, MbbsModule> modules)
        {
            //Fast Return
            if (command.Length < 6)
            {
                return(false);
            }

            //Verify it's a /SYSOP command
            if (!Encoding.ASCII.GetString(command).ToUpper().StartsWith("/SYSOP"))
            {
                return(false);
            }

            //Verify the user has SYSOP key
            if (_accountKeyRepository.GetAccountKeysByUsername(sessions[channelNumber].Username)
                .Count(x => x.accountKey == "SYSOP") == 0)
            {
                return(false);
            }

            //Set Class Variables
            _sessions      = sessions;
            _channelNumber = channelNumber;

            //Verify the command has at least one action
            if (command.IndexOf((byte)' ') == -1)
            {
                Help();
                return(true);
            }

            var commandSequence = Encoding.ASCII.GetString(command).TrimEnd('\0').Split(' ');

            switch (commandSequence[1].ToUpper())
            {
            case "LISTACCOUNTS":
            {
                ListAccounts();
                break;
            }

            case "REMOVEACCOUNT":
            {
                RemoveAccount(commandSequence);
                break;
            }

            case "RESETPASSWORD":
            {
                ResetPassword(commandSequence);
                break;
            }

            case "ADDKEY":
            {
                AddKey(commandSequence);
                break;
            }

            case "REMOVEKEY":
            {
                RemoveKey(commandSequence);
                break;
            }

            case "LISTKEYS":
            {
                ListKeys(commandSequence);
                break;
            }

            case "CLEANUP":
            {
                _globalCache.Set("SYSOPGLOBAL-CLEANUP", true);
                break;
            }

            case "BROADCAST":
            {
                Broadcast(commandSequence);
                break;
            }

            case "KICK":
            {
                Kick(commandSequence);
                break;
            }

            case "HELP":
            {
                Help();
                break;
            }

            default:
                return(false);
            }

            return(true);
        }