use after free (2) 썸네일형 리스트형 [Wargame] uaf_overwrite 1. 실습 코드 C 코드, 바이너리 파일, libc-2.27.so가 주어진다. // Name: uaf_overwrite.c // Compile: gcc -o uaf_overwrite uaf_overwrite.c #include #include #include #include struct Human { char name[16]; int weight; long age; }; struct Robot { char name[16]; int weight; void (*fptr)(); }; struct Human *human; struct Robot *robot; char *custom[10]; int c_idx; void print_name() { printf("Name: %s\n", robot->name); } .. [Lecture] Use After Free 1. Use-After-Free 메모리 참조에 사용한 포인터를 메모리 해제 후, 제대로 초기화하지 않아 발생하는 취약점이다. 해제한 메모리를 초기화하지 않고 다음 청크에 재할당해주기 때문이다. 즉, 해제된 메모리에 접근할 수 있을 때, 발생하는 취약점이다. Chunk(청크) 란? • malloc에 메모리 할당을 요청하면, 넓은 메모리의 영역을 다양한 크기의 덩어리(chunk)로 나눈다. • chunk는 사용중인 덩어리, 해제된 덩어리, Top 덩어리, Last Remainder 덩어리가 있다. • 위에서 말하고 있는 청크는 "해제된 덩어리"로 응용프로그램에서 시스템에 반환한 덩어리를 의미하는 것이다. 2. Dangling Pointer 2-1. 정의 컴퓨터 과학에서 'Dangling Pointer'는 유.. 이전 1 다음