오래된
-
[HackerSchool] Level19오래된/HackerSchool 2011. 5. 10. 05:45
[level19@ftz level19]$ cat hint main() { char buf[20]; gets(buf); printf("%s\n",buf); } [ level19 hint ] Buffer Overflow 문제인데, 지금까지와 다른점이라면 setreuid 함수가 실행되지 않는 다는 점이다. 이전까지 사용해왔던 쉘코드를 수정해서 setreuid 함수가 같이 실행 되도록 변경해서 문제를 해결 할 수 있다. 1. setreuid 를 포함한 Shellcode 제작 먼저 setreuid 함수의 assm 코드를 확인하기 위해서 C 코드를 만든다. #include int main(void) { setreuid(3100, 3100); } [ setreuid level20 코드 ] setreuid 함수의 as..
-
[HackerSchool] Level18오래된/HackerSchool 2011. 5. 10. 05:40
[level18@ftz level18]$ cat hint #include #include #include #include void shellout(void); int main() { char string[100]; int check; int x = 0; int count = 0; fd_set fds; printf("Enter your command: "); fflush(stdout); while(1) { if(count >= 100) printf("what are you trying to do?\n"); if(check == 0xdeadbeef) shellout(); else { FD_ZERO(&fds); FD_SET(STDIN_FILENO,&fds); if(select(FD_SETSIZE, &fds, ..
-
[HackerSchool] Level17오래된/HackerSchool 2011. 5. 10. 05:10
#include void printit() { printf("Hello there!\n"); } main() { int crap; void (*call)()=printit; char buf[20]; fgets(buf,48,stdin); setreuid(3098,3098); call(); } [ level17 hint ] 이번 문제는 level16 문제에서 shell 을 실행 시켜주는 함수만 빠진 상태다. 따라서, 쉘 코드를 환경변수에 올려놓고 그 주소로 모두 덮어씌어 문제를 해결할 수 있다.
-
[HackerSchool] Level16오래된/HackerSchool 2011. 5. 10. 04:44
[level16@ftz level16]$ cat hint #include void shell() { setreuid(3097,3097); system("/bin/sh"); } void printit() { printf("Hello there!\n"); } main() { int crap; void (*call)()=printit; char buf[20]; fgets(buf,48,stdin); call(); } [ level16 hint ] 이 문제 역시 Buffer Overflow 문제로서 함수 포인터가 가르키는 주소공간을 shell 로 변경하여 문제를 해결 할 수 있다. [level16@ftz tmp]$ cp ../attackme . [level16@ftz tmp]$ gdb ./attackme (gdb..
-
[HackerSchool] Level15오래된/HackerSchool 2011. 5. 10. 04:36
[level15@ftz level15]$ cat hint #include main() { int crap; int *check; char buf[20]; fgets(buf,45,stdin); if (*check==0xdeadbeef) { setreuid(3096,3096); system("/bin/sh"); } } [ level15 hint ] level14 문제와 비슷한 내용인데 단지 level14 에서는 문자열을 확인 했던 방식이라면 이번 문제에서는 주소값을 확인 한다는 것 정도 일 것이다. 환경변수에 0xdeadbeef 를 올려놓고, 그 주소 값으로 전체를 채워버리면 쉽게 문제해결이 가능하다.
-
[HackerSchool] Level14오래된/HackerSchool 2011. 5. 10. 04:01
[level14@ftz level14]$ cat hint 레벨14 이후로는 mainsource의 문제를 그대로 가져왔습니다. 버퍼 오버플로우, 포맷스트링을 학습하는데는 이 문제들이 최고의 효과를 가져다줍니다. #include #include main() { int crap; int check; char buf[20]; fgets(buf,45,stdin); if (check==0xdeadbeef) { setreuid(3095,3095); system("/bin/sh"); } } [ level14 hint ] 단순 Buffer Overflow 문제이다. 쉘을 올릴 필요도 없다. 문제 풀이 방법이라면 Level12 를 참조하면 되겠다.
-
[HackerSchool] Level13오래된/HackerSchool 2011. 5. 10. 03:55
[level13@ftz level13]$ cat hint #include main(int argc, char *argv[]) { long i=0x1234567; char buf[1024]; setreuid( 3094, 3094 ); if(argc > 1) strcpy(buf,argv[1]); if(i != 0x1234567) { printf(" Warnning: Buffer Overflow !!! \n"); kill(0,11); } } [ level13 hint ] 이 문제는 Buffer Overflow 공격을 막기 위해 dummy 공간을 이용 exploit code 를 이용한 무분별한 공격을 더디게 만들어주었던 것처럼 이 문제에서 말하려는 security cookie 역시 이와 같은 형태로 만들어지게 ..
-
[HackerSchool] Level12오래된/HackerSchool 2011. 5. 6. 08:00
[level12@ftz level12]$ cat hint #include #include #include int main( void ) { char str[256]; setreuid( 3093, 3093 ); printf( "문장을 입력하세요.\n" ); gets( str ); printf( "%s\n", str ); } [ level12 hint ] hint 의 소스를 보면 gets 함수를 이용해서 str 변수에 사용자 입력을 제한없이 받아 들이는 것을 알 수 있다. 따라서, 이것 역시 Buffer Overflow 공격이 가능하다. 단지 입력 받는 방법이 프로그램 인자가 아니라 stdin 형태로 받아 들이기 때문에 공격방법이 약간 달라질 뿐 공격코드의 내용은 동일하다. (perl -e 'print "~..
-
[HackerSchool] Level11오래된/HackerSchool 2011. 4. 29. 23:36
[level11@ftz level11]$ cat hint #include #include int main( int argc, char *argv[] ) { char str[256]; setreuid( 3092, 3092 ); strcpy( str, argv[1] ); printf( str ); } [ level11 hint ] Buffer Overflow, FSB 공격으로 문제를 해결 할 수 있다. 1. Buffer Overflow Buffer Overflow 공격 기법은 버퍼가 넘치도록 문자열을 채워넣어 코드의 흐름을 공격자가 원하는 방향으로 바꿔버리는 공격 이다. 취약한 프로그램인 attackme 를 통해 어떻게 Buffer Overflow 공격이 가능 하고 어떤 이유로 인해 코드의 흐름이 변경되어지..
-
[HackerSchool] Level10오래된/HackerSchool 2011. 4. 29. 19:49
[level10@ftz level10]$ cat hint 두명의 사용자가 대화방을 이용하여 비밀스런 대화를 나누고 있다. 그 대화방은 공유 메모리를 이용하여 만들어졌으며, key_t의 값은 7530이다. 이를 이용해 두 사람의 대화를 도청하여 level11의 권한을 얻어라. - 레벨을 완료하셨다면 소스는 지우고 나가주세요. [ level10 hint ] 1. Shared Memory 프로세스간 데이터 전송통로로 사용되는 메모리 공간으로 명시한 크기의 영역을 할당 받은 후 권한을 설정하여 사용 할 수 있다. 메모리 공간을 할당 받기 위해서는 shmget 함수를 사용하게 되며, 할당 받은 영역을 사용하기 위해서는 shmat 함수를 사용하게 된다. 또한 영역에 대한 사용이 모두 끝난 경우 shmdt 를 통해 ..
-
[HackerSchool] Level9오래된/HackerSchool 2011. 4. 28. 01:07
[level9@ftz level9]$ cat hint 다음은 /usr/bin/bof의 소스이다. #include #include #include main(){ char buf2[10]; char buf[10]; printf("It can be overflow : "); fgets(buf,40,stdin); if ( strncmp(buf2, "go", 2) == 0 ) { printf("Good Skill!\n"); setreuid( 3010, 3010 ); system("/bin/bash"); } } 이를 이용하여 level10의 권한을 얻어라. [ level9 hint ] bufferoverflow 공격을 이해하기 위한 문제이다. 1. Buffer Overflow buffer overflow 는 말 그..
-
[HackerSchool] Level8오래된/HackerSchool 2011. 4. 27. 23:43
[level8@ftz level8]$ cat hint level9의 shadow 파일이 서버 어딘가에 숨어있다. 그 파일에 대해 알려진 것은 용량이 "2700"이라는 것 뿐이다. [ level8 hint ] level1 에서 학습 했던 find 명령을 이용 하면 해당 파일을 찾을 수 있다. -size n[bckw] File uses n units of space. The units are 512-byte blocks by default or if `b' follows n, bytes if `c' follows n, kilobytes if `k' follows n, or 2-byte words if `w' follows n. The size does not count indirect blocks, but ..
-
[HackerSchool] Level7오래된/HackerSchool 2011. 4. 27. 22:47
[level7@ftz level7]$ cat hint /bin/level7 명령을 실행하면, 패스워드 입력을 요청한다. 1. 패스워드는 가까운곳에.. 2. 상상력을 총동원하라. 3. 2진수를 10진수를 바꿀 수 있는가? 4. 계산기 설정을 공학용으로 바꾸어라 [ level7 hint ] 힌트에 모든 풀이방법과 답이 들어 있기 때문에 특별한 설명이 필요 없어 보인다. [level7@ftz level7]$ /bin/level7 Insert The Password : 올바르지 않은 패스워드 입니다. 패스워드는 가까운곳에... --_--_- --____- ---_-__ --__-_- [ 실행 화면 ] 엉뚱한 곳에서 헤매지 않게 하기 위해 힌트를 더 준다면, 빨강색으로 표시한 문자열이 힌트에서 말하는 2진수 이다.
-
[HackerSchool] Level6오래된/HackerSchool 2011. 4. 27. 22:40
hint - 인포샵 bbs의 텔넷 접속 메뉴에서 많이 사용되던 해킹 방법이다. ##################################### ## ## ## 텔넷 접속 서비스 ## ## ## ## ## ## 1. 하이텔 2. 나우누리 ## ## 3. 천리안 ## ## ## ##################################### 접속하고 싶은 bbs를 선택하세요 : [ level6 hint] level6 권한으로 접속을 하면 위와 같은 hint 하나가 나오고 접속은 끊어진다. 단순히 프로그램이 실행 되는 과정을 살펴보면 아래와 같을 것이다. telnet->특정 프로그램->종료->접속 끊김 telnet 으로 우리가 접속을 시도하면, 어떤 특정 프로그램이 실행되고 해당 프로그램이 종료됨과 동..
-
[HackerSchool] Level5오래된/HackerSchool 2011. 4. 27. 22:25
[level5@ftz level5]$ cat hint /usr/bin/level5 프로그램은 /tmp 디렉토리에 level5.tmp 라는 이름의 임시파일을 생성한다. 이를 이용하여 level6의 권한을 얻어라. [ level5 hint] 사실 hint만 봐서는 어떤 취약점인지 알기가 많이 힘들다. 하지만, strace 라는 프로그램을 이용하면 해당 프로그램이 어떤 명령을 수행하는지 한 눈에 볼 수 있다. 문제는 문제를 만들기 위한 문제이다보니, strace로 확인하는 경우 password가 그대로 노출되기 때문에 좀 허무하게 끝날 수 있다. creat("/tmp/level5.tmp", 0600) = 3 write(3, "next password : \n\0", 31) = 31 close(3) = 0 rm..
-
[HackerSchool] Level4오래된/HackerSchool 2011. 4. 27. 20:54
[level4@ftz level4]$ cat hint 누군가 /etc/xinetd.d/에 백도어를 심어놓았다.! [ Level4 hint ] 백도어를 이용한 권한상승이 목표인것을 예상해 볼 수 있겠다. 1. xinetd xinetd 데몬은 서비스 하고싶은 프로그램들을 대신하여 실행 시켜주는 역할을 한다. 해당 서비스들은 /etc/xinetd.d/ 디렉토리에 형식을 맞추어 파일을 작성하여 넣어두면 xinetd 데몬이 해당 파일을 읽어들여 서비스 하려는 프로그램을 실행 시켜주는 역할을 하게 된다. [level4@ftz xinetd.d]$ pstree init-+-anacron---run-parts-+-00-logwatch---sh-+-applystddate | | |-cat ...[중략]... |-sshd-..
-
[HackerSchool] Level3오래된/HackerSchool 2011. 4. 26. 08:45
[level3@ftz level3]$ cat hint 다음 코드는 autodig의 소스이다. #include #include #include int main(int argc, char **argv){ char cmd[100]; if( argc!=2 ){ printf( "Auto Digger Version 0.9\n" ); printf( "Usage : %s host\n", argv[0] ); exit(0); } strcpy( cmd, "dig @" ); strcat( cmd, argv[1] ); strcat( cmd, " version.bind chaos txt"); system( cmd ); } 이를 이용하여 level4의 권한을 얻어라. more hints. - 동시에 여러 명령어를 사용하려면? - ..
-
[HackerSchool] Level2오래된/HackerSchool 2011. 4. 26. 07:42
[level2@ftz level2]$ cat hint 텍스트 파일 편집 중 쉘의 명령을 실행시킬 수 있다는데... [ Level2 hint ] Level1 문제를 해결할 때 처럼 find 명령을 이용해서 level3 이 소유자 이면서 setuid 가 설정된 파일을 찾아낸다. 해당 파일을 실행 시켜보면 문서 편집툴이 실행 된다. 1. VIM 리눅스 시스템의 대표적인 문서 편집툴이다. http://www.google.com/cse?cx=partner-pub-6915143203050178%3A3221174078&ie=UTF-8&q=vim vim 에는 크게 input mode 와 command mode 가 존재한다. http://www.google.com/cse?cx=partner-pub-691514320305..
-
[HackerSchool] Level1오래된/HackerSchool 2011. 4. 26. 07:21
HackerSchool F.T.Z 에 접속 하면 레벨업 문제와 관련된 Hint 파일을 User 홈 디렉토리에서 찾을 수 있는데, 이름이 hint 이다. [level1@ftz level1]$ cat hint level2 권한에 setuid가 걸린 파일을 찾는다. 1. SETUID 파일에 setuid 를 설정하고 group 이나 other 에 실행 권한을 부여하면 프로그램이 실행 되는 동안 파일의 소유자 권한을 갖도록 한다. 이와 비슷하게 setgid가 존재한다. Man 페이지에서 확인하기. http://www.google.com/cse?cx=partner-pub-6915143203050178%3A3221174078&ie=UTF-8&q=setuid&sa=%EA%B2%80%EC%83%89 Wiki & Term..
-
솔라리스 truss 명령어오래된/Linux 2011. 4. 9. 03:26
User Commands truss(1) NAME truss - trace system calls and signals SYNOPSIS truss [-fcaeildD] [ - [tTvx] [!] syscall ,...] [ - [sS] [!] signal ,...] [ - [mM] [!] fault ,...] [ - [rw] [!] fd ,...] [ - [uU] [!] lib ,... : [:] [!] func ,...] [-o outfile] com- mand | -p pid... DESCRIPTION Truss 유틸리티는 인자로 주어진 명령어를 수행하며 시스템 콜, 수신되는 시그널, 기계적 결함을 유발하는 곳을 추적한다. 결과로 출력된 각각의 줄에는 각기 결함이나 시그널 이름 또는 시스템 콜 이름과..
-
Mysql.com Sql Injection 공격에 털림오래된/기타 2011. 4. 4. 21:31
Mysql.com 등 mysql 관련 도메인들이 Sql Injection 공격에 무참히 털렸단 내용이 올라왔네요. Sql Injection 공격이 가장 빈번하게 일어나고 있는 상황에서 mysql 사이트가 대처를 못할 정도의 공격이 가능한 것을 보면 공격이 점점 지능화 되어가고 있다는 걸 알수 있는 사례인 것 같습니다... http://thenextweb.com/industry/2011/03/27/irony-mysql-and-sun-websites-hacked-using-sql-injection/
-
[C언어] 문자는 되는데 문자열은 안된다.오래된/C언어 2009. 4. 4. 21:48
개요 배열에 문자열을 넣으면 왜 제대로 들어가지 않는 것일까. 포인터를 선언하고 동적할당을 받은뒤 문자열을 해당 주소에 넣으려고 하면 왜 제대로 들어가지 않는 것일까. 동일한 두가지 질문에 대한 답같은것(?)을 포함하고 있다. 본론 char buf[20]; buf = "abcd"; printf("%s\n", buf); >위 소스를 컴파일 하고 실행하면 이상한 값들을 볼 수 있다. char * buf; buf = malloc(20) *buf = "abcd"; printf("%s\n", buf); >위 소스를 컴파일 하고 실행하면 이상한 값들을 볼 수 있다. char buf[20]; buf[0] = 'a'; buf[1] = 'b'; buf[2] = 'c'; buf[3] = 'd'; printf("%s\n",..
-
[Linux] 사용자 관리오래된/Linux 2009. 3. 19. 00:44
명령어들 useradd 새로운 계정을 만들거나 새로운 계정의 기본정보를 변경하는 경우 사용 useradd -D 새로운 계정을 추가하는 경우 사용되는 시스템에 정의된 기본 옵션 정보를 화면에 표시 dnipen@hayanho:~$ useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/sh SKEL=/etc/skel CREATE_MAIL_SPOOL=no useradd -D [option] 시스템에 정의된 기본 옵션을 [option] 에 설정한 것으로 변경 할 수 있다. ( 이외의 것은 지원되지 않음, Valid default-changing options are: 12/08/2008) -b, base-dir 이것은 기본 옵션중 HOME의 값을 변경 한..