exploit.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env python3
  2. from pwn import *
  3. import subprocess
  4. def start(argv=[], *a, **kw):
  5. if args.GDB: # Set GDBscript below
  6. return gdb.debug([exe] + argv, gdbscript=gdbscript, *a, **kw)
  7. elif args.REMOTE: # ('server', 'port')
  8. return remote(sys.argv[1], sys.argv[2], *a, **kw)
  9. else: # Run locally
  10. return process([exe] + argv, *a, **kw)
  11. """
  12. notes:
  13. """
  14. gdbscript = ""
  15. breakpoints = [
  16. # 'breakrva 0xoffset',
  17. "continue"
  18. ]
  19. for s in breakpoints:
  20. gdbscript += s + "\n"
  21. exe = "./vuln"
  22. elf = context.binary = ELF(exe, checksec=False)
  23. # context.log_level = 'info' # use DEBUG in args for debugging. LOG_LEVEL=warn/info/error for anything else
  24. """
  25. if args.REMOTE:
  26. libc = ELF('./libc.so.6', checksec=False)
  27. else:
  28. libc = ELF('/usr/lib/x86_64-linux-gnu/libc.so.6', checksec=False)
  29. """
  30. # ===========================================================
  31. # EXPLOIT GOES HERE
  32. # ===========================================================
  33. offset = 0
  34. io = start()
  35. payload = flat({offset: []})
  36. io.sendlineafter(b">", payload)
  37. io.interactive()