Rotiple

collision

WarGame/Pwnable2015. 6. 25. 13:46

col@ubuntu:~$ cat col.c
#include 
#include 
unsigned long hashcode = 0x21DD09EC;
unsigned long check_password(const char* p){
	int* ip = (int*)p;
	int i;
	int res=0;
	for(i=0; i<5; i++){
		res += ip[i];
	}
	return res;
}

int main(int argc, char* argv[]){
	if(argc<2){
		printf("usage : %s [passcode]\n", argv[0]);
		return 0;
	}
	if(strlen(argv[1]) != 20){
		printf("passcode length should be 20 bytes\n");
		return 0;
	}

	if(hashcode == check_password( argv[1] )){
		system("/bin/cat flag");
		return 0;
	}
	else
		printf("wrong passcode.\n");
	return 0;
}



코드를 보시면 인자 20byte를 받아서 check_password라는 함수를 거쳐서 res변수와 hashcode를 비교하게 되있습니다. 입력반은 인자를 int 변수(4byte)에 담고 5번을 더한 값이 res의 값이 되겠습니다. 그리하여 0x21DD09EC를 5로 나눈값 + 나머지값을 값으로 입력하면 정답이 되겠습니다. 자세한 사항은 직접 해보세요 .



col@ubuntu:~$ ./col `python -c "print '\xc8\xce\xc5\x06'*4+'\xcc\xce\xc5\x06'"`

'WarGame > Pwnable' 카테고리의 다른 글

shellshock  (0) 2015.07.06
mistake  (0) 2015.07.06
random  (0) 2015.07.06
passcode  (0) 2015.06.25
fd  (0) 2015.06.25