Level 10 소스는 아래와 같다.[code]#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; …
io.smashthestack.org – Level 9
Level 9 문제 소스는 아래와 같다.[code]#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;}[/code]포멧스트링 문제로 보인다. 확인해 보도록 하자. [code lang-sh]level9@io:/levels$ ./level09 %xbfffdec8level9@io:/levels$ ./level09 …
io.smashthestack.org – Level 8
Level 8 문제 소스는 아래와 같다.우선 gdb를 이용하여 디버깅을 해보도록 하자.[code lang-sh]level8@io:/tmp/by8$ gdb /levels/level08GNU gdb 6.8-debianCopyright (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 law. Type "show copying"and "show warranty" …
io.smashthestack.org – Level 7
Level 7 문제 소스는 아래와 같다. [code]#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[]) …
io.smashthestack.org – Level 6
Level 6 문제 소스는 아래와 같다.[code]#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;}[/code]특별히 오버플로우가 날거 같은 부분이 보이지 않는다. 하지만 아래와 같이 …
io.smashthestack.org – Level 5
Level 5의 소스는 아래와 같다. [code]#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;}[/code] 문제는 간단하다. argv[1]을 buf 변수에 strcpy() 함수를 이용하여 …
io.smashthestack.org – Level 4
Level 4 문제 소스는 아래와 같다. [code]#include <stdlib.h> int main() { system("id"); return 0;}[/code] id를 실행시키는 간단한 소스다..PATH 환경변수를 설정해서 우리가 직접 작성한 id를 실행시키면 쉘을 획득할 수 있을 것이다. /tmp/by4 폴더에 id를 새로 작성하여 아래와 같이 공격을 시도 하였다. [code lang-sh]level4@io:/tmp/by4$ envTERM=linuxSHELL=/bin/bashSSH_CLIENT=211.218.16.99 23923 22OLDPWD=/tmpSSH_TTY=/dev/pts/2USER=level4MAIL=/var/mail/level4PATH=/usr/local/bin:/usr/bin:/bin:/usr/gamesPWD=/tmp/by4SHLVL=1HOME=/home/level4LOGNAME=level4SSHCONNECTION=211.218.16.99 23923 192.168.1.32 …
io.smashthestack.org – Level 3
Level 3 문제 소스는 아래와 같다.[code]#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 …
io.smashthestack.org – Level 2
Level 2 문제를 실행하면 아래와 같다.[code lang-sh]level2@io:/tmp/by$ /levels/level02Append 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 581321level2@io:/tmp/by$ [/code]위 수열에서 39번째부터 42번째를 이어서 쓴 값을 argv[1]로 넣으라고 한다… [code lang-python]#!/usr/bin/python”’Append …
io.smashthestack.org – Level 1
http://io.smashthestack.org:84 ssh level1@io.smashthestack.org -p2224 password: level1 오늘 부터 시작해보자! Level 1 문제는 생각보다 단순하다. [code lang-sh]level1@io:/levels$ ./level01Usage: ./level01 <password>level1@io:/levels$ ./level01 testFail.level1@io:/levels$ strings level01/lib/ld-linux.so.2gmon_start__libc.so.6printfexeclputsstrncmp_IO_stdin_usedlibc_start_mainGLIBC2.0PTRh0Y][^][^]omgpasswordUsage: %s <password>Win./bin/shFail.level1@io:/levels$ ./level01 omgpasswordWin.sh-3.2$ cat /home/level2/.passep4kbyqesh-3.2$ [/code]