Ejemplo n.º 1
0
        public static int ProcessPut(string host, string id, string flag)
        {
            log.Info("Processing Vuln1.Put");

            var r = new Random();
            var candidateUsers       = GenerateCandidates(candidatesMinCount, candidatesMaxCount);
            var candidateWithFlagNum = r.Next(candidateUsers.Length);
            var candidateWithFlag    = candidateUsers[candidateWithFlagNum];

            candidateWithFlag.PrivateMessage = flag;
            log.InfoFormat("Generated {0} candidates (#{1} has flag)", candidateUsers.Length, candidateWithFlagNum);

            candidateUsers = Vuln2Methods.RegisterCandidates(host, candidateUsers).OrderBy(user => user.Login).ToArray();
            var election        = Vuln2Methods.StartElection(host, candidateUsers[0], true, nominateTimeInSec, voteTimeInSec);
            var electionStartDt = DateTime.UtcNow;

            Vuln2Methods.NominateUsers(host, election, candidateUsers.Skip(1).ToArray());

            var state = new Vuln1State
            {
                ElectionStartDate = electionStartDt,
                NominateTimeInSec = nominateTimeInSec,
                VoteTimeInSec     = voteTimeInSec,
                ElectionId        = election.Id.ToString(),
                Candidates        = candidateUsers
            };

            log.Info("Flag put");
            Console.Out.WriteLine(Convert.ToBase64String(Encoding.UTF8.GetBytes(state.ToJsonString())));
            return((int)ExitCode.OK);
        }
Ejemplo n.º 2
0
        public static int ProcessPut(string host, string id, string flag)
        {
            log.Info("Processing Vuln1.Put");

            var r = new Random();
            var candidateUsers = GenerateCandidates(candidatesMinCount, candidatesMaxCount);
            var candidateWithFlagNum = r.Next(candidateUsers.Length);
            var candidateWithFlag = candidateUsers[candidateWithFlagNum];
            candidateWithFlag.PrivateMessage = flag;
            log.InfoFormat("Generated {0} candidates (#{1} has flag)", candidateUsers.Length, candidateWithFlagNum);

            candidateUsers = Vuln2Methods.RegisterCandidates(host, candidateUsers).OrderBy(user => user.Login).ToArray();
            var election = Vuln2Methods.StartElection(host, candidateUsers[0], true, nominateTimeInSec, voteTimeInSec);
            var electionStartDt = DateTime.UtcNow;

            Vuln2Methods.NominateUsers(host, election, candidateUsers.Skip(1).ToArray());

            var state = new Vuln1State
            {
                ElectionStartDate = electionStartDt,
                NominateTimeInSec = nominateTimeInSec,
                VoteTimeInSec = voteTimeInSec,
                ElectionId = election.Id.ToString(),
                Candidates = candidateUsers
            };

            log.Info("Flag put");
            Console.Out.WriteLine(Convert.ToBase64String(Encoding.UTF8.GetBytes(state.ToJsonString())));
            return (int) ExitCode.OK;
        }