247CTF — Tips and Tricks Write up
this is the last challenge from the Beginner Tutorial category
basically it is a programming skills test , in order to solve this challenge you must automate solving 500 math quiz , so lets start by analyzing the solution code.

we will be using pwn lib for this challenge , i recommend reading the documentation
1- at line 6 we initialize the connection to the remote host an then after that we retrieve two lines ,those fist two lines are not important for us because our numbers appear in the third line we retrive from the server

after that in line 11 we initialize a for loop that will loop through the code below it for 500 times , at line 13 we initialize the variable math that will contain the last line of the data we received
so now the variable math contains the string ‘what is the answer to (number) + (number)’
the line 14 we will initialize an array called nums it will contain the two numbers provide by the server to us , we can choose these two numbers by sanitizing the variable math using the function findall from re (Regular Expressions ) library , for further understanding on what this function does feel free to look at the documentation of it
this function will return a two element array that contains the numbers we want to do the mathematical operation on them , the lines 16 and 17 are responsible for attaching the numbers to two separate values , then we add them to each other and store the result in a variable called result
at line 20 we re encode the string so we can send it as bytes , last we send the string ( notice that we add a ‘\n’ and ‘\t’ for jumping to a new line , the hint at the challenge says that ‘\n’ is not the only way to jump to a new line )
this code will loop 500 times and solve 500 mathematical operation and at the end we just receive a line that should be the flag … XD

the code link
https://github.com/toka0x/ctf-solutions/blob/main/247ctf/tipsandtricks.py