题目信息
解题步骤
题目附件是个源码
打开它
逐步分析
if (first != 0xcafe) {
printf("you are wrong, sorry.\n");
exit(2);
}
//不等于0xcafe就退出,那first=0xcafe
if (second % 5 == 3 || second % 17 != 8) {
printf("ha, you won't get it!\n");
exit(3);
}
//满足if条件就退出那就令second = 25
if (strcmp("h4cky0u", argv[3])) {
printf("so close, dude!\n");
exit(4);
}
//相等strcmp返回0,退出if条件,那argv[3]=“h4cky0u”
写出解题代码
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[])
{
int first = 0xcafe;
int second = 25;
argv[3] = "h4cky0u";
unsigned int hash = first * 31337 + (second % 17) * 11 + strlen(argv[3]) - 1615810207;
printf("The key: ");
printf("%x\n", hash);
//system("pause");
return 0;
}