defsolve(start, end): global p,c mid = (start + end) // 2 full = (end - start) // 2 * 10 s = str.encode(' '.join(map(lambda x: str(x), range(start, mid)))) p.sendline(s) r = p.recvline() real = int(r) c -= 1 if c >= 0: if real < full: return start if mid - start == 1else solve(start, mid) else: return mid if end - mid == 1else solve(mid, end)
defworker(): global p,c r = str(p.recv()) pattern = re.compile(r'N=(\d+) C=(\d+)') n,c = list(map(lambda x: int(x),pattern.match(r).groups())) result = solve(0,n) while c>=0: p.sendline(str(result)) r = p.recvline() c -= 1
p = remote('pwnable.kr', 9007) p.recvuntil("Ready? starting in 3 sec... -\n\t\n") for i in range(100): print("round {}".format(i)) worker() flag = p.recv() print(flag)