Tags: netcat 

Rating:

# Quickmaths

the server literally just gives u 1000 math questions one after other such as `a+b`. so we use python to implement a script to connect to the server and do the maths for us. after solving 1000 questions in a row u get a flag

cool thing is that the server sends the questions formatted in a way that running `eval()` on what it sends will give us the answer in python

however, running `eval()` is dangerous
therefore i suggest future organisers use this same challenge but send a reverse shell at the end to hack the competitors
you thought you were here to hack us, but we were here to hack you! - future organisers hopefully

solve
```py
#nc 34.148.103.218 1228

import telnetlib
from string import ascii_lowercase as ab

HOST = "34.148.103.218"
PORT = 1228

tn = telnetlib.Telnet(HOST, PORT)
print(tn.read_until(b"\n"))
print(tn.read_until(b"\n"))
print(tn.read_until(b"\n"))
print(tn.read_until(b"\n"))

for i in range(0, 1000):
print(tn.read_until(b"\n"))
q=tn.read_until(b"\n").decode()
ans=str(eval(q)) #hope the server did not send a reverse shell script
print(q)
print(ans)
tn.write(bytes(ans, "utf-8")+b"\n")
print(i)

tn.interact() #idk if this was needed
```

it timed out a few times then i complained to the admins who said the challenge creator was offline. so i just ran it a few times until it stop disconnecting and worked