Description: Awesome service. Now I don't need to encrypt anything myself!
Connect via: nc chall.rumble.host 2734
We had a service to netcat with: nc chall.rumble.host 2734 and the source code to download & unzip.
Looking at the source code, the program ask for input and then encrypt the flag and the input with AES-CTR-128 mode.
from Crypto.Cipher importAESfrom secret import flagimport oskwargs ={"nonce": os.urandom(8)}key = os.urandom(16)defencrypt(msg): aes =AES.new(key,AES.MODE_CTR,**kwargs)return aes.encrypt(msg).hex()print(encrypt(flag))q =input("Encrypt this string:").encode()print(encrypt(q))
This's how AES CTR works:
The vulnerability here is that the Nonce is reused for all the encryptions, and as the name says, it should be used only (n)once.
So, the encryption of flag is done with:
Ciphertext1 = flag β AES(Key, Nonce)
and the encryption of user input:
Ciphertext2 = input β AES(Key, Nonce)
Note that we used the same Nonce and Key pair, so we can say that: