ctf攻防世界open-source

题目链接:
https://adworld.xctf.org.cn/task/answer?type=reverse&number=4&grade=0&id=5076&page=1ctf攻防世界open-source_第1张图片打开附件可得到下面这段代码:ctf攻防世界open-source_第2张图片分析:
1.必须满足输入四个参数;
2. 第二个参数等于 0xcafe;
3. 第三个参数对5取余不能等于3,或者是对17取余等于8;
4. 第四个参数是:h4cky0u
根据以上条件,我们可以得出:

first = 0xcafe second%17)= 8 strlen(argv[3]) = strlen(“h4cky0u”)

最后输出的参数hash可改写为:

   unsigned int hash = 0xcafe * 31337 + 8 * 11 + strlen("h4cky0u") - 1615810207;

我们可以将代码改写成:

 #include 
   #include 
   int main() {    
   unsigned int hash = 0xcafe * 31337 + 8 * 11 + strlen("h4cky0u") - 1615810207;
   	printf("Get your key: ");	
   	printf("%x\n", hash);	return 0;
   	}

用codeblocks运行得到结果:ctf攻防世界open-source_第3张图片所以最后的flag是c0ffee

你可能感兴趣的:(ctf)