write-ups-challenges-2020-2021/fancy_text/serverside.py
2022-11-24 18:03:20 +01:00

56 lines
1.2 KiB
Python

from art import text2art
from time import sleep
from random import randint
from datetime import datetime
FLAG = 'IGCTF{You_should_really_consider_buying_AMC_stocks.<3}'
print(text2art('Welcome!'))
def example():
exString = input('Provide a string: ')
exString = " ".join(exString[i:i+1] for i in range(0, len(exString), 1))
print(text2art(exString))
def forReal():
solution = ''
for i in range(0, randint(7,9)):
solution += chr(randint(33,125))
startTime = datetime.now()
print(text2art(" ".join(solution[i:i+1] for i in range(0, len(solution), 1))))
tried = input('What does it say? ')
totaltime = (datetime.now() - startTime).seconds
if (totaltime > 2):
print("Too late!")
elif (tried == solution):
print("Congratulations!")
print(FLAG)
return True
else:
print("Wrong! (correct: " + solution + ")")
while(True):
print()
print(" -- MENU --")
print("1. Give an example")
print("2. Try yourself")
print("3. Close connection")
choice = input('Choose a number: ')
if (choice == '1'):
example()
elif(choice == '2'):
if forReal():
break
elif(choice == '3'):
break
else:
print(choice, "not recognized...")
print()
print("Bye!")