Skip to content

Instantly share code, notes, and snippets.

@lovasoa
Last active February 2, 2020 05:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lovasoa/a4efdd4f30cc0ee4cd9f0563fb7ec64e to your computer and use it in GitHub Desktop.
Save lovasoa/a4efdd4f30cc0ee4cd9f0563fb7ec64e to your computer and use it in GitHub Desktop.
Cybersecurity challenge: will you be able to extract the SECRET by running this script ?
#!/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