Skip to content

Instantly share code, notes, and snippets.

@k4lizen
Last active March 31, 2024 13:54
Show Gist options
  • Save k4lizen/21ff273f794616e425d2040d102f9923 to your computer and use it in GitHub Desktop.
Save k4lizen/21ff273f794616e425d2040d102f9923 to your computer and use it in GitHub Desktop.
Binary Exploitation template with custom LIBC
#!/usr/bin/env python
from pwn import *
def start():
if args.GDB or args.DBG:
return gdb.debug([ld.path, elff.path], gdbinit, aslr=using_aslr, env={"LD_PRELOAD": libc.path})
elif args.REMOTE:
return remote(sys.argv[1], sys.argv[2])
return process([ld.path, elff.path], aslr=using_aslr, env={"LD_PRELOAD": libc.path})
using_aslr = False
elff = context.binary = ELF('./vuln', checksec=False)
libc = ELF('./libc.so.6', checksec=False)
ld = ELF('./ld-linux.so', checksec=False)
context.log_level = 'debug'
context.terminal = ['tmux', 'split', '-h', '-l', '65%', '-b']
# TEMPLATE END
gdbinit = '''
init-pwndbg
break main
'''
p = start()
p.interactive()
p.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment