2022-05-17 12:48:40 +02:00
|
|
|
|
|
|
|
import random
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def str_xor(secret, key):
|
|
|
|
#extend key to secret length
|
|
|
|
new_key = key
|
|
|
|
i = 0
|
|
|
|
while len(new_key) < len(secret):
|
|
|
|
new_key = new_key + key[i]
|
|
|
|
i = (i + 1) % len(key)
|
|
|
|
return "".join([chr(ord(secret_c) ^ ord(new_key_c)) for (secret_c,new_key_c) in zip(secret,new_key)])
|
|
|
|
|
|
|
|
|
|
|
|
flag_enc = chr(0x15) + chr(0x07) + chr(0x08) + chr(0x06) + chr(0x27) + chr(0x21) + chr(0x23) + chr(0x15) + chr(0x5f) + chr(0x05) + chr(0x08) + chr(0x2a) + chr(0x1c) + chr(0x5e) + chr(0x1e) + chr(0x1b) + chr(0x3b) + chr(0x17) + chr(0x51) + chr(0x5b) + chr(0x58) + chr(0x5c) + chr(0x3b) + chr(0x42) + chr(0x57) + chr(0x5c) + chr(0x0d) + chr(0x5f) + chr(0x06) + chr(0x46) + chr(0x5c) + chr(0x13)
|
|
|
|
|
|
|
|
|
|
|
|
num = random.choice(range(10,101))
|
|
|
|
|
|
|
|
print('If ' + str(num) + ' is in decimal base, what is it in binary base?')
|
|
|
|
|
|
|
|
ans = input('Answer: ')
|
|
|
|
|
|
|
|
try:
|
|
|
|
ans_num = int(ans, base=2)
|
|
|
|
|
2022-05-17 12:52:54 +02:00
|
|
|
flag = str_xor(flag_enc, 'enkidu')
|
2022-05-17 12:48:40 +02:00
|
|
|
if ans_num == num:
|
|
|
|
print('That is correct! Here\'s your flag: ' + flag)
|
|
|
|
else:
|
2022-05-17 12:52:54 +02:00
|
|
|
print(str(ans_num) + ' and ' + str(num) + ' are not equal, but here\'s your flag anyway: ' + flag)
|
2022-05-17 12:48:40 +02:00
|
|
|
|
|
|
|
except ValueError:
|
|
|
|
print('That isn\'t a binary number. Binary numbers contain only 1\'s and 0\'s')
|