[카테고리:] io – SmashTheStack

io.smashthestack.org – Level 10

Level 10 소스는 아래와 같다. #include <stdio.h> #include <stdlib.h> #include <unistd.h> // Contributed by Torch int limit, c; int getebp() { __asm__("movl %ebp, %eax"); } void f(char *s) { int *i; char buf[260]; i = (int *)getebp(); limit = *i – (int)buf + 1; for (c = 0; c < limit && s[c] != '\0'; …

io.smashthestack.org – Level 9

Level 9 문제 소스는 아래와 같다. #include <stdio.h> #include <string.h> int main(int argc, char **argv) { int pad = 0xbabe; char buf[1024]; strncpy(buf, argv[1], sizeof(buf) – 1); printf(buf); return 0; } 포멧스트링 문제로 보인다. 확인해 보도록 하자. level9@io:/levels$ ./level09 %x bfffdec8level9@io:/levels$ ./level09 AAAA%x%x%x%x AAAAbfffdebe3ffbfffd94041414141level9@io:/levels$ 포멧스트링 문제가 맞는 것으로 보인다. 이제 포멧스트링 공격에 필요한 값들을 확인해 …

io.smashthestack.org – Level 8

Level 8 문제 소스는 아래와 같다. 우선 gdb를 이용하여 디버깅을 해보도록 하자. level8@io:/tmp/by8$ gdb /levels/level08 GNU gdb 6.8-debian Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by …

io.smashthestack.org – Level 7

Level 7 문제 소스는 아래와 같다. #include <unistd.h> #include <stdio.h> #include <stdlib.h> // We are never deceived; we deceive ourselves. – Johann Wolfgang von Goethe void check_id(unsigned int id) { if(id > 10) { execl("/bin/sh", "sh", NULL); } else { printf("Not today son\n"); } } int main(int argc, char *argv[]) { int id; sscanf(argv[1], "%d", …

io.smashthestack.org – Level 6

Level 6 문제 소스는 아래와 같다. #include<string.h> // The devil is in the details – nnp void copy_buffers(char *argv[]) { char buf1[32], buf2[32], buf3[32]; strncpy(buf2, argv[1], 31); strncpy(buf3, argv[2], sizeof(buf3)); strcpy(buf1, buf3); } int main(int argc, char *argv[]) { copy_buffers(argv); return 0; } 특별히 오버플로우가 날거 같은 부분이 보이지 않는다. 하지만 아래와 같이 입력을 하면 …

io.smashthestack.org – Level 5

Level 5의 소스는 아래와 같다. #include <stdio.h> #include <string.h> int main(int argc, char **argv) { char buf[128]; if(argc < 2) return 1; strcpy(buf, argv[1]); printf("%s\n", buf); return 0; } 문제는 간단하다. argv[1]을 buf 변수에 strcpy() 함수를 이용하여 옮기나 buf 변수의 크기보다 더 많은 값을 넣으면 오버플로우가 될것임을 알 수 있다. 따라서 환경변수에 NOP + SHELLCODE를 …

io.smashthestack.org – Level 4

Level 4 문제 소스는 아래와 같다. #include <stdlib.h> int main() { system("id"); return 0; } id를 실행시키는 간단한 소스다.. PATH 환경변수를 설정해서 우리가 직접 작성한 id를 실행시키면 쉘을 획득할 수 있을 것이다. /tmp/by4 폴더에 id를 새로 작성하여 아래와 같이 공격을 시도 하였다. level4@io:/tmp/by4$ env TERM=linux SHELL=/bin/bash SSH_CLIENT=211.218.16.99 23923 22 OLDPWD=/tmp SSH_TTY=/dev/pts/2 USER=level4 MAIL=/var/mail/level4 PATH=/usr/local/bin:/usr/bin:/bin:/usr/games PWD=/tmp/by4 …

io.smashthestack.org – Level 3

Level 3 문제 소스는 아래와 같다. #include <stdio.h> #include <unistd.h> #include <string.h> int good(int addr) { printf("Address of hmm: %p\n", addr); } int hmm() { printf("Win.\n"); execl("/bin/sh", "sh", NULL); } extern char **environ; int main(int argc, char **argv) { int i, limit; for(i = 0; environ[i] != NULL; i++) memset(environ[i], 0x00, strlen(environ[i])); int (*fptr)(int) = …

io.smashthestack.org – Level 2

Level 2 문제를 실행하면 아래와 같다. level2@io:/tmp/by$ /levels/level02 Append the 39th through 42nd numbers in the sequence as a string and feed it to this binary via argv[1]. 1, 2, 3, 5, 8, 13, 21… The 4th through the 7th numbers would give you 581321 level2@io:/tmp/by$ 위 수열에서 39번째부터 42번째를 이어서 쓴 값을 argv[1]로 넣으라고 …

io.smashthestack.org – Level 1

http://io.smashthestack.org:84 ssh [email protected] -p2224 password: level1 오늘 부터 시작해보자! Level 1 문제는 생각보다 단순하다. level1@io:/levels$ ./level01 Usage: ./level01 <password> level1@io:/levels$ ./level01 test Fail. level1@io:/levels$ strings level01 /lib/ld-linux.so.2 __gmon_start__ libc.so.6 printf execl puts strncmp _IO_stdin_used __libc_start_main GLIBC_2.0 PTRh 0Y_] [^_] [^_] omgpassword Usage: %s <password> Win. /bin/sh Fail. level1@io:/levels$ ./level01 omgpassword Win. sh-3.2$ cat /home/level2/.pass ep4kbyqe …