image.png

This can be solved in a variety of ways.

Here’s a python program that will brute-force the string trying integer values between 1-255. It will return only strings that contain all ASCII values.

def brute_force_xor(hex_string):
    # Convert the hex string to bytes
    encrypted_bytes = bytes.fromhex(hex_string)

    # Iterate through all possible XOR keys (1 to 255)
    for key in range(1, 256):
        # XOR each byte in the encrypted data with the key
        decrypted_bytes = bytes([b ^ key for b in encrypted_bytes])

        # Check if all characters in the decrypted string are printable ASCII
        if all(32 <= b <= 126 for b in decrypted_bytes):
            # Print the decrypted string along with the key
            print(f"Key {key}: {decrypted_bytes.decode('ascii')}")

# Example usage
hex_string = "94beb3b5ff8ae2a0e19cb1a0e3a2a6b9e1ab"
brute_force_xor(hex_string)

Save it and run it.

python3 decrypt.py

image.png