private static void DeserializeDescriptionFile(string descriptionTxt, ScenarioPackage package) { var descriptionSections = FileReader.ReadSections(descriptionTxt); var headerSection = descriptionSections["header"]; var descriptionSection = descriptionSections["description"]; package.Title = headerSection.Lines.FirstOrDefault(); package.DescriptionLines = descriptionSection.Lines; var winConditionSection = descriptionSections["wincondition"]; var winConditionDictionary = FileReader.ReadDictionary(winConditionSection); package.WinCondition = new WinCondition { Description = winConditionDictionary["description"], }; var test = winConditionDictionary["test"]; var conditions = test.Split(new[] { "||" }, StringSplitOptions.None); foreach (var condition in conditions) { package.WinCondition.Matches.Add(new WinConditionMatch { NegateMatch = condition[0] == '!', MatchLine = condition.Substring(1).Trim() }); } }
public Scenario(ScenarioPackage scenarioPackage) { Title = scenarioPackage.Title; DescriptionLines = scenarioPackage.DescriptionLines; foreach (var process in scenarioPackage.Processes) { Console.WriteLine("Attaching " + process.Name); var p = process.Process; p.Memory.SetMemoryToDefault(); this.Processes.Add(process.Name, p); } this.WinCondition = scenarioPackage.WinCondition; foreach (var drive in scenarioPackage.Drives) { Console.WriteLine($"Attaching drive {drive.DriveId}"); Console.WriteLine($"Coord range {drive.AllCoordinates.First()} -> {drive.AllCoordinates.Last()}"); drive.SetMemoryToDefault(); this.Disks.Add(drive); } }
private static void DeserializeProgramsFile(string programsTxt, ScenarioPackage package) { var groups = FileReader.ReadArray(programsTxt); foreach (var group in groups) { var sections = FileReader.ReadSections(@group); var metadataSection = sections["metadata"]; var programMetadata = FileReader.ReadDictionary(metadataSection.Lines); var programName = programMetadata["name"]; var prompt = programMetadata["prompt"]; var instruction = programMetadata["instruction"]; var sourceSection = sections["source"]; IReadOnlyCollection <CpuCommand> commands; try { commands = FileReader.ReadCpuCommands(sourceSection.Lines); } catch (Exception e) { Console.WriteLine("program contents was: "); foreach (var line in sourceSection.Lines) { Console.WriteLine(line); } throw; } var memorySection = sections["memory"]; var memory = FileReader.ReadAddressableRegion(memorySection.Lines, null); package.Processes.Add(new ScenarioProcess { Name = programName, Process = new Process { Memory = memory, Prompt = prompt, Instruction = instruction, Source = new CpuProgram { AllCommands = commands.ToList() } } }); } }
public static ScenarioPackage Deserialize(string programsTxt, string descriptionTxt, string disksTxt) { var package = new ScenarioPackage(); DeserializeProgramsFile(programsTxt, package); if (descriptionTxt != null) { DeserializeDescriptionFile(descriptionTxt, package); } if (disksTxt != null) { DeserializeDisksFile(disksTxt, package); } return(package); }
private static void DeserializeDisksFile(string disksTxt, ScenarioPackage package) { int i = 0; var driveArray = FileReader.ReadArray(disksTxt).ToList(); foreach (var driveDefinition in driveArray) { var sections = FileReader.ReadSections(driveDefinition); var contentsSection = sections["contents"]; var metadataSection = sections["metadata"]; var metadata = FileReader.ReadDictionary(metadataSection); var memorySetup = FileReader.ReadAddressableRegion(contentsSection, i++); memorySetup.ReadOnly = metadata["readonly"] == "true"; memorySetup.VolumeName = metadata["name"]; package.Drives.Add(memorySetup); } }
public SqlOpenSearchConstraint(ScenarioPackage package) : base(package) { }
public HelloWorldScenario(ScenarioPackage package) : base(package) { }
public LateralThinkingScenario(ScenarioPackage package) : base(package) { }
public WhatsThePasswordScenario(ScenarioPackage package) : base(package) { }
public SqlReplaceEntireQuery(ScenarioPackage package) : base(package) { }
public SqlFakeGotoLabel(ScenarioPackage package) : base(package) { }
public ExploitNextAddressCheck(ScenarioPackage package) : base(package) { }
public SqlForUsingMemoryAddress(ScenarioPackage package) : base(package) { }
public SqlScenario3(ScenarioPackage package) : base(package) { }
public DereferencingScenario(ScenarioPackage package) : base(package) { }