Crypto - XorD

I just discovered bitwise operators, so I guess 1 XOR 1 = 1?

The flag is encrypted byte-by-byte using XOR with a random key. The Python random module is used with a fixed seed (1337), making the keystream predictable.

XOR is reversible. random.seed(1337) makes the random numbers deterministic The same random keystream can be regenerated to decrypt the flag

We have xord.py and output.txt from the challenge.

xord.py

import os
import random

def xor(a, b):
    return bytes([a ^ b])

flag = os.getenv('FLAG', 'pascalCTF{REDACTED}')
encripted_flag = b''
random.seed(1337)

for i in range(len(flag)):
    random_key = random.randint(0, 255)
    encripted_flag += xor(ord(flag[i]), random_key)

with open('output.txt', 'w') as f:
    f.write(encripted_flag.hex())

output.txt

Solve.py

FLAG: pascalCTF{1ts_4lw4ys_4b0ut_x0r1ng_4nd_s33d1ng}

Last updated