攻防世界逆向第二题【果然还是最拿手的C擅长一点】

题目名称:open-source

题目地址:open-source

解题思路

首先

下载附件=-=
发现是.c文件??
陷入沉思hhh
这不就是源码吗?
DEV-C++打开

#include 
#include 

int main(int argc, char *argv[]) {
    if (argc != 4) {
    	printf("what?\n");
    	exit(1);
    }

    unsigned int first = atoi(argv[1]);
    if (first != 0xcafe) {
    	printf("you are wrong, sorry.\n");
    	exit(2);
    }

    unsigned int second = atoi(argv[2]);
    if (second % 5 == 3 || second % 17 != 8) {
    	printf("ha, you won't get it!\n");
    	exit(3);
    }

    if (strcmp("h4cky0u", argv[3])) {
    	printf("so close, dude!\n");
    	exit(4);
    }

    printf("Brr wrrr grr\n");

    unsigned int hash = first * 31337 + (second % 17) * 11 + strlen(argv[3]) - 1615810207;

    printf("Get your key: ");
    printf("%x\n", hash);
    return 0;
}

其次

分析一下
输出hash即可
尝试删除四个if发现不行
因为second没有值了
细看一次代码
更改如下

#include 
#include 

int main(int argc, char *argv[]) {
    /*if (argc != 4) {
    	printf("what?\n");
    	exit(1);
    } */
    //好像没用上 

    /*unsigned int first = atoi(argv[1]);
    if (first != 0xcafe) {
    	printf("you are wrong, sorry.\n");
    	exit(2);
    }*/ 
    //跳出语句就令first为该值 
    /*unsigned int second = atoi(argv[2]);
    if (second % 5 == 3 || second % 17 != 8) {
    	printf("ha, you won't get it!\n");
    	exit(3);
    }*/
	//让second的值等于8就跳出去了
    /*if (strcmp("h4cky0u", argv[3])) {
    	printf("so close, dude!\n");
    	exit(4);
    }
    printf("Brr wrrr grr\n");*/ 
    //让aygv[3]为 "h4cky0u"跳出 
    //unsigned int hash = first * 31337 + (second % 17) * 11 + strlen(argv[3]) - 1615810207;
      unsigned int hash = 0xcafe * 31337 + (8 % 17) * 11 + strlen("h4cky0u") - 1615810207;
    printf("Get your key: ");
    printf("%x\n", hash);
    return 0;
}

最后

运行源码,得到flag:c0ffee
攻防世界逆向第二题【果然还是最拿手的C擅长一点】_第1张图片

提交完成

攻防世界逆向第二题【果然还是最拿手的C擅长一点】_第2张图片

你可能感兴趣的:(逆向)