본문 바로가기

system

2019 holyshield babyheap 2019 holyshield babyheapmalloc mmaped large chunkoob double free ld.so arealeak libc && overwrite _rtld_global + 3840(dl_fini)shellfrom pwn import * ​ #context.log_level= 'debug' ​ e = ELF('babyheap') #s = process(e.path, env={'LD_PRELOAD': './libc.so.6'}) s = process(e.path) l = ELF('/lib/x86_64-linux-gnu/libc.so.6', checksec=False) #l = ELF('libc.so.6', checksec=False) ​ ru = lambda x: s.recvu.. 더보기
2018 0ctf final baby 2018 0ctf final babydouble fetch 취약점이 발생하는 모듈이 존재한다.리눅스 커널에서의 race condition이라고 생각하면 된다.user-space binary보다 double fetch 취약점이 리눅스 커널상에서 많이 발생하는 이유는 context switch의 유무 차이인 것 같다.일단 모듈은 굉장히 작으며, 간단하게 살펴보면 다음과 같다.flag의 주소를 출력해준다.난잡한 조건문을 거친 뒤 *input == flag라면 flag를 출력해준다.즉, input에 얻은 flag의 주소를 넣어줘야 한다.여기서 __chk_range_not_ok 함수를 살펴보자.첫 번째 인자와 두 번째 인자를 __CFADD__를 통해 더하는데, 만약 첫 번째 인자에 커널 주소, 즉 flag의 주소.. 더보기
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.. 더보기
iretq, fops, tty, tty_ops struct iretq, fops, tty, tty_ops structiretqstruct trap_frame { size_t user_rip ; // instruction pointer size_t user_cs ; // code segment size_t user_rflags ; // CPU flags size_t user_rsp ; // stack pointer size_t user_ss ; // stack segment };fopsstruct file_operations { struct module *owner; loff_t (*llseek) (struct file *, loff_t, int); ssize_t (*read) (struct file *, char __user *, size_t, loff_t *).. 더보기
kernel debugging with vmware kernel debugging with vmwareVMware Hypervisor를 이용하여 debugee를 만들고, 이의 kernel을 debugging하는 방법을 소개한다.make debugeeVMware로 분석 대상 kernel이 구축되어 있는 vmx를 로딩하거나, 딱히 상관없다면 편하게 아무 linux나 만들어서 debugee를 만들자.debugee를 만들었다면 먼저 uname -r로 kernel version을 확인하자.ubuntu@ubuntu:~$ uname -r 4.15.0-70-generic그리고, 디버깅을 위해 vmlinux를 추출해야 한다.vmlinux란 정적으로 링크된 실행 파일 형식의 Linux kernel을 말한다.vmlinuz는 vmlinux를 zlib, bzip2 등으로 압축한.. 더보기