Heap 시리즈 [Heap] Background : Memory Allocator [Heap] Background : Chunk [Heap] Background : Bin (Fastbin, Unsorted bin, Small bin, Large bin) [Heap] Memory Corruption : Use After Free(UAF) (1) [Heap] Exploitation : Unsorted Bin Memory Leak 이 포스트를 읽기 전에 꼭 [Heap] Background : Bin (Fastbin, Unsorted bin, Small bin, Large bin)의 unsorted bin 파트를 다시 한번 읽고 오길 바란다. Memory Leak 오늘은 Unsorted Bin을 통해 라이브러리..
도커 파일 이용하면된다. 이는 힙 익스하는데 glibc.2.29 이상 버전이어서 이전 버전으로 된 것들을 익스플로잇하기 어려웠는데 도커 파일 이용하니까 해당 환경을 구축해서 할 수 있었다. Ubuntu 18.04 64-bit(Glibc 2.27) 실습 환경 Dockerfile FROM ubuntu:18.04 ENV PATH="${PATH}:/usr/local/lib/python3.6/dist-packages/bin" ENV LC_CTYPE=C.UTF-8 RUN apt update RUN apt install -y \ gcc \ git \ python3 \ python3-pip \ ruby \ sudo \ tmux \ vim \ wget # install pwndbg WORKDIR /root RUN git..
Heap 시리즈 [Heap] Background : Memory Allocator [Heap] Background : Chunk [Heap] Background : Bin (Fastbin, Unsorted bin, Small bin, Large bin) [Heap] Memory Corruption : Use After Free(UAF) (1) Bin bin은 free chunk들을 저장하는 freelist이다. freelist는 간단히 free된 청크들의 리스트라고 생각하면된다. 청크가 해제되면 Free chunk가 되어 tcache나 bin에 들어간다. 그리고 새로운 청크를 할당할 때 메모리를 새로 할당하는 것이 아니라 bin이나 tcache에서 꺼내 쓴다. (참고로 할당할 청크의 크기가 일정 크기 이..
Heap 시리즈 [Heap] Background : Memory Allocator [Heap] Background : Chunk [Heap] Background : Bin (Fastbin, Unsorted bin, Small bin, Large bin) [Heap] Memory Corruption : Use After Free(UAF) (1) Chunk malloc 등을 통해 메모리를 동적할당하면 Memory Allocator는 heap을 다양한 크기의 덩어리(chunk)로 나눠 반환해준다. 즉, 동적 할당으로 인해 할당받은 메모리 (혹은 반환한 메모리)와 같이 '힙을 쪼개서 얻어진 덩어리'를 청크라고 한다. 아니면 힙을 통해 동적 할당을 받은 메모리들의 단위라고 볼 수도 있겠다! 또한 memory al..
#include #include unsigned long hashcode = 0x21DD09EC; unsigned long check_password(const char* p){ //p로 argv[1]이 들어온다. int* ip = (int*)p; //argv[1]를 char*에서 int*로 바꾼다. int i; int res=0; for(i=0; i
문제 코드#include #include char buf[32]; int main(int argc, char* argv[], char* envp[]){ if(argc