Tags: bruteforce crypto 

Rating:

This can easily be solved by bruteforcing each character of the key. Full code: [main_basic_solve.py](https://github.com/CTF-STeam/ctf-writeups/blob/master/2021/UIUCTF/main_basic_solve.py).
```python
def all_valid(b):
return all(x >= 32 and x < 128 for x in b)

def bf_key(flag_enc):
for c in ALPHABET:
try:
flag = base_n_decode(flag_enc, ALPHABET.index(c))
if all_valid(flag):
return c, flag
except:
continue
return None

with open("flag_enc", "rb") as f:
flag_enc = f.read()
print(flag_enc[:16])

key = ''
while len(flag_enc) > 16:
c, flag_enc = bf_key(flag_enc)
key += chr(c)
print(key, flag_enc[:16])
```

Output:
```
b'R4OH278SS4ME1O64'
W b'6LDGG8K88173K5GH'
WM b'4141131300202234'
WM5 b'1S4UTSOJMB2C2LT3'
WM5Z b'3046215040463144'
WM5Z8 b'124A3243B2242697'
WM5Z8C b'138QP2FHMKJ71NED'
WM5Z8CR b'233BDI37C8468GBH'
WM5Z8CRJ b'6721621858612322'
WM5Z8CRJ0 b'1513A70901445151'
WM5Z8CRJ0B b'P3R7VG5G8BHAENEU'
WM5Z8CRJ0BX b'58DE8D165744E76I'
WM5Z8CRJ0BXJ b'2BCB0164601BA772'
WM5Z8CRJ0BXJD b'DCD3D7GB74EB1HFE'
WM5Z8CRJ0BXJDJ b'4023233122443204'
WM5Z8CRJ0BXJDJ5 b'ELKNAORKCPTN4D24'
WM5Z8CRJ0BXJDJ5W b'uiuctf{r4DixAL}'
```

Original writeup (https://github.com/CTF-STeam/ctf-writeups/tree/master/2021/UIUCTF#back_to_basics-crypto---50-pts).