Hello, I have a CTF challenge at my university and unfortunately I don’t know what to do next.
Here are all the clues:
I can enter my student ID and get a cipher text back.
Flags have the format {f=XXX}, where XXX consists of 12 pseudo-random characters from the alphabet “0123456789abcdef”.
Here is the code that calculates the cipher text:
import os
from Crypto.Cipher import AES
def encrypt(msg):
nonce = os.urandom(8)
key = os.urandom(32)
c = b''
for i in range((len(msg)//16)+1):
aes = AES.new(key,AES.MODE_CTR, nonce = nonce)
c +=aes.encrypt(msg[16*i:16*(i+1)])
return c
plaintext = '''GET / HTTP/1.1\r\nHost: ctf.itsc.uni-xxx.de\r\nUser-Agent: Mozilla\5.9 (X11; Ubuntu: Linux x86_64; rv:62.0) Gecko/20100101 Firefox/ 62.0\r\nAccept: text/html,application/xhtml+xml,application/xml;qU0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate, br\r\nConnection: keep-alive\r\nCookie: {{f={}}}'''.format(flag)
ciphertext = encrypt(plaintext.encode()).hex()
The encryption code was implemented in Python3 and the PyCryptoDome library. There is another note that you should pay particular attention to how the counter mode was implemented.
Example for student ID 1950243 is the cipher text:
cb581035f90f6091ba1e9857a25f081bc4723761ec0f4bb18860de12ff0d2b64e2746962a35f58a09c3ad60aa20a601c86483770a40269a28b20c35cac236a6be5712874f91a06f5ce66ef57bd552544ee682a61a31408898720c21eac163d27d32b702ef65d5effd87c9956a54e4274ef762b3ae41f19f5de7f8757ac286c63e97b2b6df9191aebde43bd27ef0d6061f8276461b3575cea863ada0aa00f7561e0742774a24647abc136df12e1022e69e1716874a65f44ac8d2fc30fe3002a69e1717f64eb1f06fcc264984cb71f3821a225491f974c4ba09e3a9a2aed006264ed7a212ff64a46e8bb1d9b03e255742cbc337118dc6e4ba68b3ec34bc900667ee8742a72ec0f4fbf873e9b46e80b637ded692139f64d5ac8e40dd808e20b6665e5722a2ff6444da09e63d60ae518601c865e2b7abd464dffce35d15bbf0c3025e8297624e11b19f393
I tried reversing the calculation but without the key I couldn’t find myself in much progress. I also tried analyzing the cipher texts and while I was able to find similarities, I can’t seem to find anything else.
I am not particularly looking for the complete solution, rather some clues as to what I might be missing.
I would be happy if anyone could point the way