EPFL's CTF team

CSAW CTF 2018: Algebra


This was a challenge in the Misc category with the following description:

Are you a real math wiz?

nc misc.chal.csaw.io 9002

On connecting to the server, we receive an equation:

4 - X = 55

What does X equal?:

If we solve the equation, we get a new one. The idea is to solve for X till we (hopefully) get the flag.


My initial thought was to write my own solver in python. However, a quick Google search revealed a nice library, SymPy, that eases the process of calculation.

The script, algebra.py, has the code to solve the challenge using SymPy. I also used the pwn library for handling the netcat connection with the server.

The challenge was relatively straightforward; I only had to spend a little bit of time reading the SymPy documentation to ensure that my inputs were in the correct format for the module. Code flow is as follows: