Ejemplo n.º 1
0
        private string ParseLogon(string command)
        {
            var match = LogonCommand.Match(command);
            var user = match.Groups[1].ToString().ToUpper();

            if(user == "ADMIN" && LogonAdmin != null) {
                var e = new ParserActionEventArgs();
                LogonAdmin(this, e);
                return e.Reply;
            }

            return StaticMessages.BadUser;
        }
Ejemplo n.º 2
0
        private string ParseRun(string command)
        {
            var match = RunCommand.Match(command);
            var mode = match.Groups[1].ToString().ToUpper();
            var file = match.Groups[2].ToString().ToUpper();

            //Console.WriteLine(file);
            //Console.WriteLine(mode);

            if(mode == "DEBUG" && file == "ACCOUNTS.F") {
                if(RunDebugAccounts != null) {
                    var e = new ParserActionEventArgs();
                    RunDebugAccounts(this, e);
                    return e.Reply;
                }

                return StaticMessages.AccessDenied;
            }

            return StaticMessages.BadCommand;
        }
Ejemplo n.º 3
0
        private string ParseSet(string command)
        {
            var match = SetCommand.Match(command);
            var cmd = match.Groups[1].ToString().ToUpper();
            var options = match.Groups[3].ToString();

            ParserActionEventArgs e;

            switch(cmd) {
            case "TERMINAL/INQUIRE":
                return StaticMessages.HackingIntro03;
            case "FILE/PROTECTION":
                e = new ParserActionEventArgs() { Options = options };
                if(SetFileProtection != null) SetFileProtection(this, e);
                return e.Reply;
            case "HALT RESTART/NORMAL":
                e = new ParserActionEventArgs() { Options = options };
                if(HaltRestartNormal != null) HaltRestartNormal(this, e);
                return e.Reply;
            case "HALT RESTART/MAINT":
                e = new ParserActionEventArgs() { Options = options };
                if(HaltRestartMaint != null) HaltRestartMaint(this, e);
                return e.Reply;
            }

            return StaticMessages.BadCommand;
        }
Ejemplo n.º 4
0
        void Handle_parserLogonAdmin(object sender, ParserActionEventArgs e)
        {
            for(var _attempts = 4; _attempts >= 0; _attempts--) {
             			_serial.Write("\r\n" + StaticMessages.HackingHeader2 + "\r\n\r\n");
                _serial.Write(IBM3151.Commands.Prompt);
                var guess = _serial.GetString(true);

                if(_adminPassword != null && guess == _adminPassword)
                {
                    e.ReturnCode = ReturnCodes.Success;
                    e.Reply = string.Empty;
                    return;
                }

                if(_attempts != 0) {
                    _serial.Write("\n");
                    _serial.Write(string.Format(StaticMessages.InvalidPassword, _attempts));
                }
            }

            Lockout();

            e.ReturnCode = ReturnCodes.Failure;
            _runMode = V300.RunModes.Normal;
            e.Reply = StaticMessages.NormalBootMessage;
            return;
        }
Ejemplo n.º 5
0
 void HandleParserSetFileProtection(object sender, ParserActionEventArgs e)
 {
     if(new Regex(@"ACCOUNTS.F$", RegexOptions.IgnoreCase).IsMatch(e.Options)) {
         e.ReturnCode = ReturnCodes.Success;
         _accountsProtected = false;
     }
     e.Reply = (e.ReturnCode == ReturnCodes.Success) ? string.Empty : StaticMessages.BadCommand;
 }
Ejemplo n.º 6
0
        void HandleParserRunDebugAccounts(object sender, ParserActionEventArgs e)
        {
            if(_runMode != V300.RunModes.Maint || _accountsProtected)
            {
                e.Reply = StaticMessages.AccessDenied;
                return;
            }

            e.ReturnCode = new DebugAccounts(this).Launch();
            e.Reply = string.Empty;
            if(e.ReturnCode == ReturnCodes.Success || e.ReturnCode == ReturnCodes.Failure) {
                _runMode = V300.RunModes.Normal;
                e.Reply = StaticMessages.NormalBootMessage;
            }
        }
Ejemplo n.º 7
0
 void HandleParserHaltRestartNormal(object sender, ParserActionEventArgs e)
 {
     _runMode = V300.RunModes.Normal;
     Thread.Sleep(500);
     e.Reply = StaticMessages.NormalBootMessage;
     e.ReturnCode = ReturnCodes.Success;
 }
Ejemplo n.º 8
0
 void HandleParserHaltRestartMaint(object sender, ParserActionEventArgs e)
 {
     _runMode = V300.RunModes.Maint;
     e.ReturnCode = ReturnCodes.Success;
     e.Reply = StaticMessages.MaintainenceModeBootMessage;
     Thread.Sleep(500);
 }