Daddy told me about cool MD5 hash collision today.
I wanna do something like that too!
ssh col@pwnable.kr -p2222 (pw:guest)
파일 목록을 보았다.
col@pwnable:~$ ls
col col.c flag
col.c 파일 내용을 보았다.
col@pwnable:~$ cat col.c
#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;
}
0x21DD09EC는 dec으로 568134124이다.
113626824는 hex로 0x6C5CEC8이고, 113626828은 hex로 0x6C5CECC이다.
리틀 엔디안을 따르므로 반대로 적어 넣어주면 아래와 같다.
col@pwnable:~$ ./col `python -c 'print("\xC8\xCE\xC5\x06" * 4 + "\xCC\xCE\xC5\x06")'`
daddy! I just managed to create a hash collision :)
Flag? : daddy! I just managed to create a hash collision :)