import hashlib
import itertools
from pwn import *
import string

context.log_level = 'debug'

r = remote("localhost",10001)

strings=r.recvline().decode('utf-8')
alpha_bet = string.ascii_letters+string.digits
strlist = itertools.permutations(alpha_bet, 4)
obj = re.search('\w{64}', strings)[0]
obj2 = re.search('\w{16}', strings)[0]

for i in strlist:
    data=i[0]+i[1]+i[2]+i[3]+obj2
    data_sha=hashlib.sha256(data.encode('utf-8')).hexdigest()
    if(data_sha==obj):
        print(data[:4])
        r.sendline(data[:4].encode())
        break
r.recvline()
r.recvline()
r.close()