# MORXOR
This puzzle was part of the Gold Bug Zine. It was a single page which had a diagram of an encryption algorithm along with some ciphertext:

The algorithm is based on bitwise rotations and XOR. Each plaintext block of 32 bits is encrypted by XORing with data from the previous _ciphertext_ blocks. Since we are given the ciphertext blocks, we can decrypt all but the first block by essentially running the encryption algorithm over the ciphertexts and with a null key:
```py=
from pwn import xor
def unrol24(v):
return v[-1:] + v[:-1]
def unrol16(v):
return v[-2:] + v[:-2]
def unrol8(v):
return v[-3:] + v[:-3]
ct = ['a6d677fa', 'b9e99232', '65140016', '16001e1c', 'd5c41ee5', 'a68d9232', '7f140b0e', '0b151e0b']
ct = [bytes.fromhex(c) for c in ct]
C0, C2, C3, C4, C5, C6, C7, C8 = ct
P2 = xor(unrol24(C0), C2)
print('P2:', P2.decode())
P3 = xor(unrol24(C2), unrol16(C0), C3)
print('P3:', P3.decode())
P4 = xor(unrol24(C3), unrol16(C2), unrol8(C0), C4)
print('P4:', P4.decode())
P5 = xor(unrol24(C4), unrol16(C3), unrol8(C2), C5)
print('P5:', P5.decode())
P6 = xor(unrol24(C5), unrol16(C4), unrol8(C3), C6)
print('P6:', P6.decode())
P7 = xor(unrol24(C6), unrol16(C5), unrol8(C4), C7)
print('P7:', P7.decode())
P8 = xor(unrol24(C7), unrol16(C6), unrol8(C5), C8)
print('P8:', P8.decode())
```
::: spoiler Answer
The ciphertext decrypts to "THE CODE IS **VIVIDVISIONSFIX**"