image.png

This is a fairly basic XOR brute-force challenge.

If you want to learn more about XOR encryption, I have a lab here that goes over it in detail.

solution.py

import string

# Open the file and read the encrypted content
with open("enc.bin", "r") as enc:
    line = enc.read().strip()

# Loop through all letters and digits
for key in string.ascii_letters + string.digits:
    # XOR each character in the line with the key to create the decrypted message
    decrypted = ''.join([chr(ord(x) ^ ord(key)) for x in line])
    
    # Check if all characters in the decrypted message are within the printable ASCII range
    if all(32 <= ord(char) <= 126 for char in decrypted):
        print(f"Key: {key} -> Decrypted: {decrypted}")

image.png