본문 바로가기

시스템 해킹59

[Dreamhack] basic_exploitation_001 #include #include #include #include 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); } void read_flag() { system("cat /flag"); } int main(int argc, char *argv[]) { char buf[0x80]; initialize(); gets(buf); return 0; } 위 코드는 문제에서 주어진 코드이다. 해당 코드의 취약점은 gets라는 취약함 함수를.. 2021. 4. 11.
[Dreamhack] basic_exploitation_000 #include #include #include #include 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 argc, char *argv[]) { char buf[0x80]; initialize(); printf("buf = (%p)\n", buf); scanf("%141s", buf); return 0; } 위 코드는 문제에서 주어진 코드이다. 취약점은 0x80 바이트 크기의 buf 변수에 sca.. 2021. 4. 6.
[DIMI CTF] ezheap 118명 중에 7명이 위 문제를 풀었다. 문제에서 주어진 파일을 실행하면 다음과 같이 5가지의 선택 메뉴가 출력된다. ghidra 라는 정적 분석 툴을 이용해서 주어진 실행 파일을 분석하겠다. 위 그림은 ghidra로 분석한 메인 함수의 어셈블리 코드다. ghidra의 decompile 기능을 이용해 디컴파일을 시도하면 아래와 같은 코드를 볼 수 있다. void main(void) { undefined8 uVar1; basic_ostream *this; inital(); menu(); uVar1 = scanInt(); switch(uVar1) { case 0: this = operator 2021. 3. 26.
[Pwnable.kr] bof 문제: Nana가 버퍼오버플로우가 가장 흔한 취약점이라고 했어, 진짜야? #include #include #include void func(int key){ char overflowme[32]; printf("overflow me : "); gets(overflowme); // smash me! if(key == 0xcafebabe){ system("/bin/sh"); } else{ printf("Nah..\n"); } } int main(int argc, char* argv[]){ func(0xdeadbeef); return 0; } 문제에서 주어진 코드를 보면 서버에서 gets로 사용자에게 입력 값을 입력받고 key가 0xcafebebe와 같으면 플래그를 출력한다. 따라서 key를 수정하기 위해서 버.. 2021. 3. 24.
[Pwnable.kr] fd 문제: 엄마! 리눅스에 파일 디스크립터가 뭐야?? 문제에서 주어진 서버로 접속하면 fd, fd.c flag 3가지 파일이 있다. fd.c를 열람하면 아래와 같다. char buf[32]; int main(int argc, char* argv[], char* envp[]){ if(argc 2021. 3. 24.