python recv() and eval()

Question:

can someone please help me understand this code

clientsock.send("Welcome to Maths_Server 1.0n")

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

Asked By: AdoobII

||

Answers:

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.

Answered By: adib

The answer to this riddle is this is actually the server code, but you need to make a client which will connect to that server, and produce equal results to get the flag.

Answered By: Guy
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.