0
$\begingroup$

We have a key representing an SHA-256 hash in HEX, and we have the key in AES-ECB. We also have a file with plaintext to cipher messages that were encrypted with our key. How could we find this key?

8cb78d34edfec9db1fa4a044f14c06cd5d9aa8a4fece263c439c5fa62dd1fedadf757d79fa6a28069ddcba4ca624c9694559483254896625392f70bf7df4dd66

The above is the flag encrypted in AES-ECB, we know that the flag is a hex representation of an SHA-256 hash:

79621ca63d052e64 --> ca5b6fdb77e3b1ec39b6c4e1a4b69ba5

55191c3c4eeb107e --> ded63de07b250d83f842d7bc860db40c

We have a whole list with plaintext that was encrypted with our key (flag).

$\endgroup$
1
  • $\begingroup$ You mean, you have the hash of the encryption key? With this knowledge, no! May be you have limited keyspace that you can test it with the hash value? $\endgroup$
    – kelalaka
    Feb 15 at 16:18
1
$\begingroup$

ECB is weak because a given 128 bit input block maps to the same encrypted output block. The only thing you can do is look for matches between blocks of the encrypted flag and outputs in the known plaintext ciphertext pairs file.

Essentially for each 128 bit chunk of ASCII text in the flag E(plaintext)=ciphertext. The known plaintext ciphertext pair file is essentially a big table of E(plaintext)=ciphertext for a bunch of plaintext ciphertext pairs. If you find one of the encrypted flag blocks in that file:

8cb78d34edfec9db1fa4a044f14c06cd
5d9aa8a4fece263c439c5fa62dd1feda
df757d79fa6a28069ddcba4ca624c969
4559483254896625392f70bf7df4dd66

You have the decryption for that block. Just ctrl-f for these values and assemble the decrypted chunks to find the unencrypted flag. They have to be there for the CTF to be solveable.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.