python recv()和eval()

时间:2016-02-11 17:19:50

标签: python recv

有人可以帮我理解这段代码

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()

我想知道recv()的作用以及如何使if语句成为真正的

1 个答案:

答案 0 :(得分:0)

嗯,您无法确定firstNum值,因为它是由用户输入的,因此您在firstNum中输入一个随机数,然后输入secondNum您输入的firstNum firstNum 1}},所以它的作用是eval()获取secondNum值并将其转换为routes.php的字符串,这将使if语句成立。希望这会成功。