【MoeCTF2024】PWN

vstral的博客 / 2024-10-19 / 原文

1.NotEnoughTime

这道题我发现存在网络问题可能会导致出现问题,建议关闭代理。
第二个就是要注意每个算式返回整数

点击查看代码
from pwn import *
import math

context.log_level='debug'

p = remote('127.0.0.1',19111)
p.recvuntil("Test start, you have only 30 seconds.\nLet's begin with simple ones.\n")
title = p.recvuntil('=').strip().decode()[:-1]
result = eval(title)
p.sendline(str(result))
title = p.recvuntil('=').strip().decode()[:-1]
result = math.floor(eval(title))
p.sendline(str(result))
p.recvuntil('OK, then some tough ones. Be WELL PREPARED!\n')
for i in range(100):
    title = p.recvuntil('=').strip().decode()[:-1]
    title = title.replace("\n","").replace("    ","").replace(" ","")
    print(title)
    result = math.floor(eval(title))
    print(result)
    p.sendline(str(result))