From 066c7f330566d9ca77145481f962b507cd826789 Mon Sep 17 00:00:00 2001 From: Lili Date: Tue, 25 Jan 2022 14:50:17 +0100 Subject: [PATCH 1/3] add accidental exit protection --- assistant.py | 94 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 39 deletions(-) diff --git a/assistant.py b/assistant.py index 186d4c8..a0941ab 100755 --- a/assistant.py +++ b/assistant.py @@ -302,49 +302,65 @@ def game_loop(): print("Basic commands are:") print("(S)tart, (N)ext, (H)elp, (C)heck, (E)xit") while True: - print("Waiting for your input:") - command = input() - command = command.lower() - if command in ("a", "abort", "(a)bort"): - abort_game(game, hint_giver, flag_checker) - elif command in ("e", "exit"): - abort_game(game, hint_giver, flag_checker) - print("Exiting...") - return - elif command in ("s", "start", "(s)tart"): - start_game(game, level_selector) - elif command in ("n", "next", "(n)ext"): - try: - if game.level == 0: - print("Can't continue, (S)tart the game first!") - elif game.level == 5: - print("Can't continue, you are on the last level!") - print("Make sure to run (F)inish and (L)og your progress before exiting.") + try: + print("Waiting for your input:") + command = input() + command = command.lower() + if command in ("a", "abort", "(a)bort"): + abort_game(game, hint_giver, flag_checker) + elif command in ("e", "exit"): + abort_game(game, hint_giver, flag_checker) + print("Exiting...") + return + elif command in ("s", "start", "(s)tart"): + start_game(game, level_selector) + elif command in ("n", "next", "(n)ext"): + try: + if game.level == 0: + print("Can't continue, (S)tart the game first!") + elif game.level == 5: + print("Can't continue, you are on the last level!") + print("Make sure to run (F)inish and (L)og your progress before exiting.") + else: + if check_flag(game.level, flag_checker): + try_next_level(game, level_selector) + except NoLevelFoundError as err: + print("Error encountered: {}".format(err)) + elif command in ("f", "finish", "(f)inish"): + if (not game.game_in_progress and not game.game_finished): + print("Can't finish game, game was not started yet.") + elif (not game.game_in_progress and game.game_finished): + print("Can't finish game, game was already finished earlier.") else: if check_flag(game.level, flag_checker): - try_next_level(game, level_selector) - except NoLevelFoundError as err: - print("Error encountered: {}".format(err)) - elif command in ("f", "finish", "(f)inish"): - if (not game.game_in_progress and not game.game_finished): - print("Can't finish game, game was not started yet.") - elif (not game.game_in_progress and game.game_finished): - print("Can't finish game, game was already finished earlier.") + finish_game(game) + elif command in ("i", "info", "information", "(i)nfo", "(i)nformation"): + game.print_info() + elif command in ("h", "help", "(h)elp"): + print_help() + elif command in ("c", "check", "(c)heck"): + check_prerequisites() + elif command in ("l", "log", "(l)og"): + player_logging(game, hint_giver, flag_checker) + elif command in ("t", "hint", "hin(t)"): + give_hint(game, hint_giver) else: - if check_flag(game.level, flag_checker): - finish_game(game) - elif command in ("i", "info", "information", "(i)nfo", "(i)nformation"): - game.print_info() - elif command in ("h", "help", "(h)elp"): - print_help() - elif command in ("c", "check", "(c)heck"): - check_prerequisites() - elif command in ("l", "log", "(l)og"): - player_logging(game, hint_giver, flag_checker) - elif command in ("t", "hint", "hin(t)"): - give_hint(game, hint_giver) - else: + print("Unknown command. Enter another command or try (H)elp.") + except EOFError: print("Unknown command. Enter another command or try (H)elp.") + print("If you want to exit the assistant, please use the `exit` command.") + except KeyboardInterrupt: + print("You sent a keyboard interrupt to the program.") + print("Would you like to exit? yes/no") + confirmation = input() + confirmation = confirmation.lower() + if confirmation in ("y", "yes"): + abort_game(game, hint_giver, flag_checker) + print("Exiting...") + return + else: + print("Not exiting. Continuing normal operation.") + print("Next time, please use the `exit` command to exit.") if __name__ == "__main__": From 22652402e192d1949a423d100f0d00f8a2c4b742 Mon Sep 17 00:00:00 2001 From: Lili Date: Thu, 24 Feb 2022 13:45:12 +0100 Subject: [PATCH 2/3] fix hard exit option --- assistant.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/assistant.py b/assistant.py index a0941ab..a6550e9 100755 --- a/assistant.py +++ b/assistant.py @@ -351,16 +351,14 @@ def game_loop(): print("If you want to exit the assistant, please use the `exit` command.") except KeyboardInterrupt: print("You sent a keyboard interrupt to the program.") - print("Would you like to exit? yes/no") + print("Would you like to exit?") + print("This will NOT save your log or end the game. yes/no") confirmation = input() confirmation = confirmation.lower() if confirmation in ("y", "yes"): - abort_game(game, hint_giver, flag_checker) - print("Exiting...") return else: print("Not exiting. Continuing normal operation.") - print("Next time, please use the `exit` command to exit.") if __name__ == "__main__": From 8415320435f62b786eddfdd2d15ccd78691f608b Mon Sep 17 00:00:00 2001 From: Lili Date: Mon, 7 Mar 2022 11:26:56 +0100 Subject: [PATCH 3/3] fix typo in hint --- resources/hints.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/hints.yml b/resources/hints.yml index 7a2f95f..a9b86cc 100644 --- a/resources/hints.yml +++ b/resources/hints.yml @@ -31,7 +31,7 @@ level4: "Password cracking": "The password appears to be encrypted with a simple MD5 hash. A tool like John the Ripper, which is already installed on the computer, could be used to crack the password." "Command line options": 'The arguments you will need to crack the password are "--format=" and "--wordlist="' "Database interaction": "Use the [SQL] button in the web shell to interact with log into local databases and interact with them using SQL queries." - "Solution": "Place to hash in to_crack.txt. Run `john --format=raw-md5 --wordlist=passwords.txt to_crack.txt` to get the password." + "Solution": "Place the hash in to_crack.txt. Run `john --format=raw-md5 --wordlist=passwords.txt to_crack.txt` to get the password." level5: level5: "Database interaction": "You can communicate with local databases using SQL queries."