본문 바로가기

pwn/pwnable.kr

collision

problem

MD5 해쉬 충돌

 

#include <stdio.h>
#include <string.h>
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;
}

int형으로 5번 더한값이 hashcode와 같으면 된다

 

flag

'pwn > pwnable.kr' 카테고리의 다른 글

random  (0) 2022.03.23
passcode  (0) 2022.03.23
flag  (0) 2022.03.23
bof  (0) 2022.03.23
fd  (0) 2022.03.23