from pwn import *

# s1 = ssh(host="172.17.0.2", user="comparer", password="comparer")
s1 = ssh(
    host="pwn.ingehack.ingeniums.club", port=2000, user="comparer", password="comparer"
)

i = 0
j = 2 ** 64 - 1
context.log_level = "error"

# binary search
while 1:
    x = i + (j - i) // 2
    print(f"{i}\t{x}\t{j}")
    p = s1.process(["./comparer", str(x)])
    exit_value = p.poll(block=True)
    # print(exit_value)
    if exit_value == 1:
        j = x
    elif exit_value == 255:
        i = x
    else:
        print("x:", x)
        print(p.recvall().decode())
        break
