private static async Task Debug(IChecker checker, string host) { for (int i = 0; i < int.MaxValue; i++) { try { var vulns = (await checker.Info().ConfigureAwait(false)).Split(':').Skip(1).Select(v => int.Parse(v.Trim())).ToArray(); await checker.Check(host).ConfigureAwait(false); var vuln = RndDbg.RandomVuln(vulns); var flag = RndDbg.RandomFlag(); var flagid = await checker.Put(host, "", flag, vuln).ConfigureAwait(false); await checker.Get(host, flagid, flag, vuln).ConfigureAwait(false); Console.ForegroundColor = ConsoleColor.Green; await Console.Error.WriteLineAsync(ExitCode.OK.ToString()).ConfigureAwait(false); Console.ResetColor(); } catch (CheckerException e) { await Console.Error.WriteLineAsync(e.ExitCode.ToString()).ConfigureAwait(false); return; } } }
private static async Task Do(IChecker checker, CheckerArgs args) { switch (args.Command) { case Command.Debug: await Debug(checker, args.Host).ConfigureAwait(false); break; case Command.Info: await Console.Out.WriteLineAsync(await checker.Info().ConfigureAwait(false)).ConfigureAwait(false); break; case Command.Check: await checker.Check(args.Host).ConfigureAwait(false); break; case Command.Put: await Console.Out.WriteLineAsync(await checker.Put(args.Host, args.Id, args.Flag, args.Vuln).ConfigureAwait(false)).ConfigureAwait(false); break; case Command.Get: await checker.Get(args.Host, args.Id, args.Flag, args.Vuln).ConfigureAwait(false); break; default: throw new CheckerException(ExitCode.CHECKER_ERROR, "Unknown command"); } }