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; }
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; }
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; }
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; }
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; }
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; } }
void HandleParserHaltRestartNormal(object sender, ParserActionEventArgs e) { _runMode = V300.RunModes.Normal; Thread.Sleep(500); e.Reply = StaticMessages.NormalBootMessage; e.ReturnCode = ReturnCodes.Success; }
void HandleParserHaltRestartMaint(object sender, ParserActionEventArgs e) { _runMode = V300.RunModes.Maint; e.ReturnCode = ReturnCodes.Success; e.Reply = StaticMessages.MaintainenceModeBootMessage; Thread.Sleep(500); }