Rating:

## Solution
The astute reader will realize that we are doing multiple xors with a static key sliding across character by character
With plaintext `flag{1}` and key `bat` the algorithm visualized would be:
```
flag{1}
bat
bat
bat
bat
bat

0: f ^ b
1: l ^ b ^ a
2: a ^ b ^ a ^ t
3: g ^ b ^ a ^ t
4: { ^ b ^ a ^ t
5: 1 ^ a ^ t
6: } ^ t
```

Since [crypto_slide_quest.c](./dist/crypto_slide_quest.c) is given, we know that the key length is 6 (sizeof(key) - null byte). The flag format is `flag{.*}`, so we can recover the key using the known 6 bytes. The first ciphertext character gives us the first key character which then tells us the second one.
The same is true for the last ciphertext character and the last key character.
Then we can just redo the algorithm using the ciphertext and recovered key to get the plaintext flag.

```from pwn import *

def xor_key(a,b,c="\x00",d="\00",e="\x00",f="\x00"):
return chr(ord(a)^ord(b)^ord(c)^ord(d)^ord(e)^ord(f))

conn = process("./crypto_slide_quest")
ciphertext = conn.recv().decode()

key_len = 6 # sizeof - null_byte, from the source code
flag_len = len(ciphertext)

flag = list("flag{" + "?"*(flag_len-6) + "}")
key = list("?" * key_len)

# manually figure out the knowns aka "flag{" and "}" which conveniently gives us the key

key[0] = xor_key(ciphertext[0], flag[0])
key[1] = xor_key(ciphertext[1], flag[1], key[0])
key[2] = xor_key(ciphertext[2], flag[2], key[1], key[0])
key[3] = xor_key(ciphertext[3], flag[3], key[2], key[1], key[0])
key[4] = xor_key(ciphertext[4], flag[4], key[3], key[2], key[1], key[0])
key[-1] = xor_key(ciphertext[-1], flag[-1])

# now that we have the key, we can re the ciphertext

plaintext = list(ciphertext)
for i in range(0, len(ciphertext) - len(key) + 1):
for j in range(0, len(key)):
plaintext[i+j] = xor_key(plaintext[i+j], key[j])

print(''.join(plaintext))
```