본문 바로가기

system/writeup

2018 bctf three 2018 bctf three제한된 횟수의 heap 문제의 경우, overlapping chunk가 굉장히 중요함을 깨달음.houseofatum에서 show 사라지고 한 번 더 할당할 수 있다.main_arena 4bit brute forcing해서 stdout magic leak하고 __free_hook 덮어서 풀면 된다.from pwn import * #context.log_level= 'debug' ​ e = ELF('three') s = process(e.path, aslr=False) l = ELF('/lib/x86_64-linux-gnu/libc.so.6', checksec=False) #l = ELF('libc.so.6', checksec=False) ​ ru = lambda x: s.recv.. 더보기
2018 bctf houseofatum 2018 bctf houseofatum신기한 기법이 사용된 문제를 발견해서 한 번 풀어봤다.glibc 2.27 heap 문제이며 작은 바이너리이다.간단하게 분석을 해보자.alloc, edit, delete, show 총 4개의 메뉴가 존재한다.alloc0x48로 size가 고정되어 있고, 총 2개의 heap만 할당할 수 있다.editoob 검사 ,dangling pointer 검사 후 chunk를 수정할 수 있다.deleteuaf가 발생한다. 다만 특별한 점은, 사용자가 dangling pointer를 만들지 안만들지 결정할 수 있다는 점이다.showoob 검사, dangling pointer 검사 후chunk를 출력할 수 있다.exploitchunk를 2개밖에 만들지 못하고, show 메뉴로 tcach.. 더보기
2019 d3ctf new_heap 2019 d3ctf new_heapsolver가 4명밖에 없었던 괴랄한 glibc 2.29 heap 문제다.작은 바이너리라 일단 간단하게 문제의 feature를 살펴보면 다음과 같다.alloc, free, exit 총 세 메뉴가 존재한다.alloc총 18개의 heap을 할당할 수 있다.0x78 이하의 size만 할당할 수 있다.delete명백하게 uaf가 발생한다. double freeexitgetchar로 굳이 사용자에게 허락을 받는다.setbuf가 되어있지 않아 heap에서 buffering이 일어난다.exploitglibc 2.29 환경이므로 tcache double free가 불가능하다.때문에 18개의 heap 개수 제한에서 fastbin을 이용하여 exploit을 하는 것도 불가능하다.getch.. 더보기
2019 csaw final arevenge 2019 csaw final arevengec++ 바이너리로 문제화돼서 한 번 풀어봤는데 어려웠다..이 문제를 통해 알아갈 수 있었던 것이 많았으므로 라업을 한번 써본다.krrr@ubuntu:~/pwn/csaw/arevenge$ file a.out a.out: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=93f2e298bd1e9cd9f8bf146f0b7bdb545b2c6d73, not stripped krrr@ubuntu:~/pwn/csaw/arevenge$ ldd a.out linux-vdso.so.1 (0x00.. 더보기
2019 hack.lu chat hack.lu 2019 chatubuntu@ubuntu:~/pwn/hack.lu/chat$ ./chat Command Channel: > /h Command Commands: /nc - New Chat Channel - Create and join a new Chat Channel. /jc x - Join Chat Channel - Join the Chat Channel number x. /lc - List Chat Channels - Lists the Chat Channels. /q - Quit - Quit this awesome chat program. /h - Help - Print this help message. > /nc Chat Channel 1: > /h Chat Commands: /e -.. 더보기
2019 hitcon lazyhouse lazyhouse hitcon 2019 lazyhouse정말.. 어려운 문제였다일단 전체적으로 흘러가는 흐름은 다음과 같다. mmap 셋팅 후 calloc으로 heap, libc leakunsafe unlink로 overlapping chunkhouse of lore로 tcache_pertheread_struct 공격__malloc_hook에 leave;retorw 이용해서 print flag (mprotect 이용해서 shellcode도 가능) 근데, 이 위 과정이 진짜 미쳤다..일단 이 exploit은 balsn의 writeup을 설명해 놓은 https://syedfarazabrar.com/2019-10-24-hitconctf-lazyhouse-balsn-exploit-analysis/ 이 블로그를 .. 더보기
2019 hitcon trick_or_treat trick_or_treat hitcon 2019 trick_or_treat굉장히 간단한 프로그램이다. 맨 처음에 입력받은 Size로 malloc을 해주고, 2번의 arbitrary write를 제공해준다. 여기서, chunk의 주소를 출력해주니 mmap으로 chunk를 할당받아서 libc를 leak할 수 있다. 그 후, __free_hook을 system으로 덮고, system("ed")를 실행시켜주면 된다. scanf에 큰 입력을 주면 malloc 후 입력을 chunk에 담고 free시키는데, 예를 들어 "A"를 0x500개, ed를 넣으면 chunk는 다음과 같은 형태를 갖는다. free 코드는 vfscanf의 errout LABEL이다. errout: /* Unlock stream. */ UNLOC.. 더보기
2019 codegate maris_shop maris_shop codegate 2019 maris_shop파일포인터에 익숙해질겸 다시 풀어본 문제다. 메뉴로 구성되어있는 heap 문제로 보인다. add를 하면 item과 amount를 입력받고 우리의 chunk를 하나 만들어주는데 다음과 같은 형태이다. xxxxxxxxxx00000000 struc_1 struc ; (sizeof=0x20, mappedto_6)00000000 item_price dq ?00000008 item_amount dq ?00000010 item_name dq 4 dup(?)00000030 struc_1 ends(item_name이 아무리 길어도 4바이트를 안넘으므로 그냥 이렇게 정의했다. 실제론 0x80바이트) 일단 add에서 cart_chunk를 17번째 인덱스까지 입력.. 더보기