Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Initialising Project Aenigma...");

            if (args.Length > 0)
            {
                LevelPath = args[0];
            }

            Console.WriteLine($"Reading levels from {LevelPath}.");

            try
            {
                AenigmaLevelManager.LoadLevelsFromDirectory(LevelPath);
            }
            catch (LevelLoadException lle)
            {
                Console.WriteLine(lle.Message);
                Console.WriteLine("An error occurred while loading a level. Exiting.");
                Thread.Sleep(20000);
                Environment.Exit(1);
            }
            catch (InvalidLevelDataException ilde)
            {
                Console.WriteLine("ERROR: An attempt to load invalid level data was made.");
                Console.WriteLine($"Offending file: {ilde.Path}");
                Console.WriteLine($"{ilde.OriginalException.GetType()}: {ilde.OriginalException.Message}");
                Thread.Sleep(20000);
                Environment.Exit(1);
            }

            Console.TreatControlCAsInput = true;
            Console.CancelKeyPress      += delegate
            {
                AenigmaMenuUtils.WriteStatusMessage("Nice try!");
                return;
            };

            Thread t = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    Thread.Sleep(1000);
                    if (AenigmaMenuUtils.ShouldTimeout)
                    {
                        AenigmaMenuUtils.TimeSinceInputAttempts += 1;
                        if (AenigmaMenuUtils.TimeSinceInputAttempts >= Timeout)
                        {
                            AenigmaMenuUtils.NumberOfTimeouts += 1;
                            AenigmaMenuUtils.BeginBootSequence();
                        }
                    }
                }
            }
                                                  ));

            t.Start();

            AenigmaMenuUtils.BeginBootSequence();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Run through the main menu.
        /// </summary>
        public static void HandleMainMenu()
        {
            ClearBox();

            WriteLineToBox($"[Connected to Aenigma BBS via {PhoneNumber}]");
            WriteLineToBox("[INFO // https://aenigma.mynameistavis.com]");
            WriteLineToBox("[INFO // Retrieving data from BBS...]");

            int amountLoaded = 0;

            while (amountLoaded < 126)
            {
                if (amountLoaded >= 114)
                {
                    amountLoaded += (126 - amountLoaded);
                }

                WriteStatusMessage($"Downloaded {amountLoaded} / 126 KB.");

                amountLoaded += new Random().Next(5, 12);
                Thread.Sleep(300);
            }

            CurrentUsers = new Random().Next(30, 90);


            using (StreamReader sr = new StreamReader("boot/main_menu.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Contains("{0}"))
                    {
                        line = string.Format(line, LifetimeAttempts,
                                             (LastPlayed != DateTime.MinValue) ? LastPlayed.ToString("HH:mm dd/MM/yy") : "00:00 00/00/00",
                                             CurrentUsers);
                    }

                    line = line.Replace("{color_begin}", "\x1B[0;32m");
                    line = line.Replace("{color_end}", "\x1B[0m");

                    WriteLineToBox(line, 0);
                }
            }

            ClearStatusMessage();

            Console.SetCursorPosition(14, 46);

            AenigmaLevel nextLevel            = null;
            int          LastNumberOfTimeouts = NumberOfTimeouts;

            while (nextLevel == null && LastNumberOfTimeouts == NumberOfTimeouts)
            {
                string password = AenigmaUtils.ReadLine();

                if (password == "sudoritual2216")
                {
                    Environment.Exit(255);
                }

                if (password == "sudoritual2217")
                {
                    BeginBootSequence();
                }

                try
                {
                    nextLevel = AenigmaLevelManager.GetLevelByPassword(password);
                }
                catch (LevelNotFoundException)
                {
                    FailedLoginAttempts++;
                    if (FailedLoginAttempts >= 3)
                    {
                        AenigmaMenuUtils.WriteStatusMessage(
                            "Whatever it is you're doing, please stop it and just type \"start\".");
                    }
                    else
                    {
                        AenigmaMenuUtils.WriteStatusMessage("Invalid password!");
                    }

                    Console.SetCursorPosition(14, 46);
                    for (int i = 0; i < password?.Length; i++)
                    {
                        Console.Write(" ");
                    }
                    Console.SetCursorPosition(14, 46);
                }
            }

            FailedLoginAttempts = 0;
            LifetimeAttempts   += 1;

            if (LastNumberOfTimeouts != NumberOfTimeouts)
            {
                return;
            }

            AenigmaLevelHandler.JumpToLevel(nextLevel);
        }
Exemplo n.º 3
0
        public static void HandleLevel(AenigmaLevel level)
        {
            AenigmaLevel nextLevel = AenigmaLevelManager.GetLevelById(level.NextStage);

            if (level.LevelType == AenigmaLevelType.Level)
            {
                Console.SetCursorPosition(107, 43);
                Console.Write("   ");
                Console.SetCursorPosition(107, 43);
                for (int i = 0; i < NumberOfLives; i++)
                {
                    Console.Write("X");
                }

                int LastNumberOfTimeouts = AenigmaMenuUtils.NumberOfTimeouts;
                while (NumberOfLives > 0 && LastNumberOfTimeouts == AenigmaMenuUtils.NumberOfTimeouts)
                {
                    string response = HandleLevelUserInput();

                    if (response.ToLower().Equals(level.CorrectAnswer.ToLower()))
                    {
                        break;
                    }

                    else
                    {
                        NumberOfLives -= 1;

                        Console.SetCursorPosition(107, 43);
                        Console.Write("   ");
                        Console.SetCursorPosition(107, 43);
                        for (int i = 0; i < NumberOfLives; i++)
                        {
                            Console.Write("X");
                        }

                        Thread.Sleep(1000);
                    }
                }
            }
            else if (level.LevelType == AenigmaLevelType.Cutscene)
            {
                if (level.ID != Guid.Parse("994495c4-7bef-4e39-a449-55a3d39743fa") && level.ID != Guid.Parse("38f677db-e167-4f9e-be18-a5def9b7a683"))
                {
                    AenigmaMenuUtils.WriteStatusMessage("Press ENTER to continue.");
                }

                Console.ReadKey(true);
                AenigmaMenuUtils.TimeSinceInputAttempts = 0;
            }

            if (NumberOfLives == 0)
            {
                AenigmaMenuUtils.WriteStatusMessage("You have been banned. Reason: Brute forcing.");
                Thread.Sleep(1000);

                AenigmaMenuUtils.HandleMainMenu();
            }
            else
            {
                NumberOfLives = 3;
                if (!nextLevel.IsFinalStage)
                {
                    JumpToLevel(nextLevel);
                }
                else
                {
                    AenigmaMenuUtils.HandleMainMenu();
                }
            }
        }