Rating:

[Link to original writuep](https://wrecktheline.com/writeups/m0lecon-2021/#README)

# Key-Lottery (116 solves, 70 points)
by Qyn

```
Just guess the correct key an you'll win a flag!

Author: mr96
```

We're given the source code of the server and we see that we have to guess a random sequence of 32 characters to get the flag.
Guessing the sequence is obviously impossible, but we can see that we maybe able to leak the sequence because of this:
```py
return f"got empty key set: {repr(key_set)}", 400
```
To get here, we can simply use as input `,,,`, because it will will pass the first check of `if keys.startswith(","):` and remote the first `,`, then it will go here: `if keys.endswith(","):`, and remove the last `,`, leaving us with just `,` passing `if len(keys) == 0:`, since `len(keys)=1`. Then the last line: `keys = set(keys.split(",")) - {"", }` will split by `,` and remove all empty lines, leaving us with nothing in `keys`.
So using `,,,` as input gives us our sequence of random characters, which we then can use to get the flag: `ptm{u_guessed_it_alright_mate}`

Original writeup (https://wrecktheline.com/writeups/m0lecon-2021/#README).