print("Thanks for using our encryption service! To get the encrypted flag, type 1. To encrypt a message, type 2.") whileTrue: print("What would you like to do (1 - get encrypted flag, 2 - encrypt a message)?") user_input = int(input()) if(user_input == 1): break
print("What is your message?") message = input() print("Here is your encrypted message:", encrypt(message.encode()))
flag = open('./src/flag.txt', 'r').read() print("Here is the encrypted flag:", encrypt(flag.encode()))
So, basically, we’re provided an AES oracle. It is seeded with a random number in the range [0, 10**6), which is used to calculate the keys for all encryptions.
10**6 is a small seed space. Therefore, this challenge is as simple as brute-forcing the seed. We can simply ask for the encrypted flag, and try all possible seeds (and each resulting key for the first encryption) and try to decrypt to get the flag! See the following implementation: