Dreamhack out_of_bound 문제풀이
out of bound(OOB)는 버퍼의 길이를 벗어나는 인덱스를 참조하려 할때 발생할 수 있는 취약점이다. 이번 문제의 소스코드를 먼저 살펴보자. char name[16]; char *command[10] = { "cat", "ls", "id", "ps", "file ./oob" }; void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } int main() { int idx; initialize(); printf("Admin name: "); read(0, name, sizeof(name)); printf("What do you want?: "); scanf("%d", &idx); system(command[idx]); return 0; } main함수를 따라가면서 살펴보면 먼저 관리자 이름을 name이라는 변수에 입력 받는다. 이후 What do you want?라는 문구와 함께 어떤 작업을 실행할 것인지 int형을 scanf로 입력 받는다. 이후 입력받은 값을 idx라는 변수에 넣고 system함수를 통해 command[idx]를 실행하고 프로그램은 종료한다. ...