연구실:System

[pwnable.kr] collision (3pt) write up

작성자 정보

  • za9uar 작성
  • 작성일

컨텐츠 정보

본문

※ 지문 

 Daddy told me about cool MD5 hash collision today.

I wanna do something like that too!

 

ssh [email protected] -p2222 (pw:guest)

 

※ 소스코드 

 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;

}

 

gdb로 분석해봅시다,,
 

$ebp-0x8에 입력 값(char)이 누적되는 것을 볼 수 있습니다.

 

1) $ebp-0x8 증가 확인

3b60f6944e0d6993c21c278c97faa46d_1686506695_8599.png

 

2) $ebp-0x8 증가 확인
f40b2350279081b9bca27d25d19c83e6_1686506803_4634.png
 

누적된 값을 소스코드의 hashcode = 0x21DD09EC; 값과 일치시켜야 한다는 말이겠죠?


 

5등분을 해봅시다.

0x21DD09EC / 5 = 0x6C5CEC8 

 

그런데 0x6C5CEC8 * 5는 0x21DD09E8 이군요?


 

약간의 보정을 해서 던져줍니다.


 

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 ? DRAG HERE !

 

 

 

관련자료

댓글 0
등록된 댓글이 없습니다.

최근글


새댓글