You read the title and thought Blockchain? You were successfully baited. Like the people before you, you now have to solve this challenge.

Category: Crypto

Solver: SchizophrenicFish2nds

Flag: GPNCTF{One_T1me_p4ds_m4y_n3v3r_b3_r3u53d!!!}

Writeup

We are given a ciphertext that was produced as $ C = P \oplus K $ for some random, repeating 5 byte key $K$. Since we know several letters of the plaintext, we can compute the key as $ K = P \oplus C $ for the first 5 bytes, then perform the encryption operation to get $ C \oplus K = P \oplus K \oplus K = P \oplus 0 = P$

Mitigations

It is called One-Time Pad because each key should be used exactly once!

Other resources

Scripts

[1] Reversing the encryption

def encrypt(message,key):
    #message = message.encode()
    out = []
    for i in range(len(message)):
        out+= [message[i]^key[i%len(key)]]
    return bytes(out)

# FLAG = "GPNCTF{fake_flag}"
encrypted_flag = bytes.fromhex("d24fe00395d364e12ea4ca4b9f2da4ca6f9a24b2ca729a399efb2cd873b3ca7d9d1fb3a66a9b73a5b43e8f3d")

key = bytes([a ^ b for a,b in zip(b"GPNCT", encrypted_flag[:5])])

print(encrypt(encrypted_flag, key)) # b'GPNCTF{One_T1me_p4ds_m4y_n3v3r_b3_r3u53d!!!}'