Last active
February 2, 2020 05:44
Cybersecurity challenge: will you be able to extract the SECRET by running this script ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import random | |
SECRET = ''.join(random.choice("0123456789") for i in range(64)) | |
class Sandbox: | |
def ask_age(self): | |
self.age = input("How old are you ? ") | |
self.width = input("How wide do you want the nice box to be ? ") | |
def ask_secret(self): | |
if input("What is the secret ? ") == SECRET: | |
print("You found the secret ! I thought this was impossible.") | |
else: | |
print("Wrong secret") | |
def run(self): | |
while True: | |
self.ask_age() | |
to_format = f""" | |
Printing a {self.width}-character wide box: | |
[Age: {{self.age:{self.width}}} ]""" | |
print(to_format.format(self=self)) | |
self.ask_secret() | |
Sandbox().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment