can someone please help me understand this code
clientsock.send("Welcome to Maths_Server 1.0\n")
try:
clientsock.send("Enter the first number, so I can EVALuate it:\n")
firstNum = eval(clientsock.recv(1024))
firstNum = firstNum + firstNum + ord(flag[4]) + ord(flag[8]) + ord(flag[5])
clientsock.send("Enter the second number, so I can EVALuate it:\n")
secondNum = eval(clientsock.recv(1024))
if secondNum == firstNum:
clientsock.send("The flag is: " + flag + "\n")
firstNum = 0
secondNum = 0
except:
pass
clientsock.close()
i want to know what does recv() does and how can i make the if statement true
Well, you can't determine the firstNum
value because it's inputted by the user, so you input a random number into the firstNum
, then for the secondNum
you enter firstNum
, so what this does is the eval() takes the firstNum
value and convert it into string for the secondNum
which will make the if-statement true. Hope this works out.