Ugly code from playing around with a ctf problem