#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;
}

How to Exploit

  1. 길이 20byte인 문자열을 주면 4byte씩 끊어서 int로 변형시켜 그 5개의 합과 0x21DD09EC와 같으면 된다. 그리고 null이 중간에 있으면 안된다.

Exploit Code

col@prowl:~$ ./col `python -c 'print "\x04\x01\x01\x01"+"\x3a\x02\x37\x08"*4'`

Capture The Flag

image

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

horcruxes  (0) 2020.03.07
fd  (0) 2020.03.07
coin1  (0) 2020.03.07
cmd2  (0) 2020.03.07
cmd1  (0) 2020.03.07

+ Recent posts