Created
April 19, 2019 05:48
-
-
Save tbhaxor/bb57b6cc64d47118214b0cfadf87d189 to your computer and use it in GitHub Desktop.
pwnable.kr ctf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment