0

I got these files for a homework. No clues, no help, just two files, source.py and secret.enc that should make me understand how I should identify that flag by means of the type of encryption used.

This is the code of source.py:

from Crypto.Cipher import AES
from Crypto.Util import Counter
from Crypto.Util.Padding import pad, unpad
import os
import base64


f = open('flag.txt','r')

key = os.urandom(32)
cipher = AES.new(key, AES.MODE_CTR,counter=Counter.new(128))
ciphertext = base64.b64encode(cipher.encrypt(b"Secret Message for our President.After you read this, please burn this message!"))
line = f.readline()
while len(line)>0:
 ciphertext += (base64.b64encode(cipher.encrypt(bytes(line.strip().encode('utf-8')))))+b'\n'
 line = f.readline()
 cipher = AES.new(key, AES.MODE_CTR, counter=Counter.new(128))



g = open('secret.enc','wb')
g.write(ciphertext)

And the encrypted file has a 200 line length so I'll not post it.

Do you have any ideas of how should I solve this CTF?

I guess that I need to apply the AES-CTR decrypt algorithm but I'm not so sure about how should I write it.

bobodrg
  • 1
  • 2

0 Answers0