전체보기656 [BOF-Wargames] LOB Load of BOF LEVEL2 (gremlin -> cobolt) 문제풀이 [gremlin@localhost gremlin]$ ls cobolt cobolt.c [gremlin@localhost gremlin]$ ./cobolt argv error [gremlin@localhost gremlin]$ ./cobolt aa aa aa aa [gremlin@localhost gremlin]$ cat cobolt.c /* The Lord of the BOF : The Fellowship of the BOF - cobolt - small buffer */ int main(int argc, char *argv[]) { char buffer[16]; if(argc < 2){ printf("argv error\n"); exit(0); } strcpy(buffer, argv[1]); print.. 2011. 8. 16. [BOF-Wargames] LOB Load of BOF LEVEL1 (gate -> gremlin) 문제풀이 해커스쿨에서 진행하는 버퍼 오버플로우 워게임이라고, Load of Buffer Overflow 이란게 있습니다. 쉽게 다운로드받으실 수 있으며 버추얼박스나 VMWare 로 오픈하기만 하면 실행이 가능합니다. netconfig 명령어를 실행해 설정을 자동세팅으로 해주면 바로 자신의 컴퓨터에서 서버로 접속을 할 수 있습니다. 접속해야하는 정보는 /sbin/ifconfig 명령어로 확인이 가능합니다. 바로 문제를 풀어보겠습니다. 이 보고서는 Level1 ~ Level3 까지 바로바로 작성됩니다. 보고서를 쓰며 기본적으로 담을 내용이 있습니다. 소스코드에 대한 설명, GDB 를 이용한 분석과정 설명(중요포인트만 설명), 메모리구조 설명, 페이로드 구성 및 설명에 대한 내용은 필수적으로 담을려고 하겠습니다. [g.. 2011. 8. 16. 메모리 기본 구조 STACK_EBP EBP + 4 => RET EBP + 8 => argc EBP + 12 => argv[0] 2011. 8. 15. [BOF-Wargames] IO SmashTheStack Level7 문제풀이 IO 워게임 레벨 7 문제풀이를 진행하도록 하겠습니다. level7@io:~$ cd /levels level7@io:/levels$ ./level07 Segmentation fault 이번 문제 또한 실행하면 세그멘테이션 폴트가 뜹니다. level7@io:/levels$ cat level07.c //written by bla #include #include #include int main(int argc, char **argv) { int count = atoi(argv[1]); // argv[1] 을 문자열 정수형으로 변환한다. int buf[10]; (EBP+12) +4 => argv[1] , if(count >= 10 ) // count 가 10보다 커버리면 프로그램이 종료됩니다. return 1;.. 2011. 8. 15. [BOF-Wargames] IO SmashTheStack Level6 문제풀이 level6@io:/levels$ ./level06 Segmentation fault 프로그램을 실행하니 세그멘테이션 폴트가 뜹니다. 버퍼 오버플로우 문제일 가능성이 높아보입니다. level6@io:/levels$ cat level06.c #include // The devil is in the details - nnp void copy_buffers(char *argv[]) { char buf1[32], buf2[32], buf3[32]; LOW [ BUF 3 | BUF 2 | BUF 1 | SFP | RET ] HIGH argv[2] argv[1] strncpy(buf2, argv[1], 31); // argv[1] 의 내용을 31 바이트만큼 buf2 에 복사한다. strncpy(buf3, argv[.. 2011. 8. 14. [BOF-Wargames] IO SmashTheStack Level5 문제풀이 드디어 이번 레벨부터 8 까지 버퍼오버플로우 문제인것 같습니다. 레벨 9 는 포맷스트링에 대한 문제이고 그 이후는 아직 풀어보지 못하였습니다. level5@io:~$ cd /levels level5@io:/levels$ ./level05 이번에는 프로그램을 실행해도 아무 메세지도 뜨지가 않는다. 인자를 전달해줘보자 level5@io:/levels$ ./level05 aa aa level5@io:/levels$ ./level05 aa aa aa 입력한 argv[1] 의 문자열을 다시 출력해주고 있다. 소스가 있으니 먼저 소스를 분석해보고 필요하다면 디버깅을 해보겠다. level5@io:/levels$ cat level05.c #include #include int main(int argc, char **a.. 2011. 8. 12. [USE-Wargames] IO SmashTheStack Level4 문제풀이 level4@io:~$ cd /levels level4@io:/levels$ ./level04 uid=1004(level4) gid=1004(level4) euid=1005(level5) groups=1005(level5),1004(level4),1029(nosu) 프로그램을 실행하니 id 명령어가 실행되는것 같습니다. level4@io:/levels$ id uid=1004(level4) gid=1004(level4) groups=1004(level4),1029(nosu) level4@io:/levels$ cat level04.c #include int main() { system("id"); // 리눅스 명령어 id 를 실행한다. return 0; } 이 문제는 리눅스 시스템에 대한 지식이 있으신분들이.. 2011. 8. 12. [USE-Wargames] IO SmashTheStack Level3 문제풀이 이번에는 Level3 을 풀어보도록 하겠습니다. level3@io:~$ cd /levels level3@io:/levels$ ./level03 Segmentation fault 프로그램을 실행하면 세그폴트가 뜹니다. level3@io:/levels$ ./level03 aa Address of hmm: 0x804847f level3@io:/levels$ ./level03 bb Address of hmm: 0x804847f 어떤값을 입력하든지 고정된 주소를 출력해줍니다. 이번에도 먼저 소스를 보고 필요하면 디버깅을 해보겠습니다. level3@io:/levels$ cat level03.c #include #include #include int good(int addr) { printf("Address of h.. 2011. 8. 12. [USE-Wargames] IO SmashTheStack Level2 문제풀이 level2@io:~$ cd /levels level2@io:/levels$ ./level02 source code is available in level02.c 이번에는 프로그램을 실행하니 소스를 확인하라고 합니다. 소스에는 바로바로 주석을 달아가겠습니다. level2@io:/levels$ cat level02.c //a little fun brought to you by bla #include #include #include #include void catcher(int a) // 쉘 획득 { setresuid(geteuid(),geteuid(),geteuid()); printf("WIN!\n"); system("/bin/sh"); exit(0); } int main(int argc, char **a.. 2011. 8. 12. 이전 1 ··· 24 25 26 27 28 29 30 ··· 73 다음