Skip to content

Latest commit

 

History

History

Random_ECB

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

[Random-ECB]

Summary

  • AES-ECB
  • Brute force

Background Knowledges

Description

  • How a plaintext is encrpyted in given source code.

    def encryption_oracle(plaintext):
        b = getrandbits(1) # 0 or 1
        plaintext = pad((b'A' * b) + plaintext + flag, 16)
        return aes_ecb_encrypt(plaintext, KEY).hex()
    • block size: 16 bytes
    • KEY is random, but not changed when the program was being executed.
    • either plaintext + flag or 'A' + plaintext + flag are generated.
  • How to guess the flag.

    • What if plaintext is 'A'*15?
    • The first encrypted block is of either encrypt('A'*15 + flag[0]) or encrypt('A'*16).
    • Be able to know the ciphertext of 'A'*15 + flag[0]) by comparing with that of 'A'*16.
      • Then, brute-forcing one byte of flag with ascii code.
    • Keep getting the next byte of flag by shortening the length of the plaintext 'AA...A'.
      • Notice that a plaintext can becomes 'A' + plaintext.
      • So, check if the current ciphertext is different from the previous ciphertext.
    • Also, do so in the next block.
    • get_flag.py
  • utflag{3cb_w17h_r4nd0m_pr3f1x}