攻防世界-wp-REVERSE-新手区-4-open-source

题目来源:

HackYou CTF

题目描述:

菜鸡学逆向学得头皮发麻,终于它拿到了一段源代码

题目附件:

8b6405c25fe447fa804c6833a0d72808.c

题目思路:

对源码分析

解题过程:

查看源码,结合注释

#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
    if (argc != 4) {
    	printf("what?\n");
    	exit(1);
    }
    unsigned int first = atoi(argv[1]);
    if (first != 0xcafe) {//得出first=0xcafe转换成10进值为51966
    	printf("you are wrong, sorry.\n");
    	exit(2);
    }
    unsigned int second = atoi(argv[2]);
    if (second % 5 == 3 || second % 17 != 8) {//second=25
    	printf("ha, you won't get it!\n");
    	exit(3);
    }
    if (strcmp("h4cky0u", argv[3])) {//argv[3]=’h4cky0u’
    	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;
}

可以看到需要添三个参数,第一个是0xcafe,第二个是满足or的一个数字,第三个是h4cky0u,最后会输出key

#include <stdio.h>
#include <string.h>
int main () {
	unsigned int first = 51966;
	unsigned int second=25;
	unsigned int hash = first * 31337 + (second % 17) * 11 + strlen("h4cky0u") - 1615810207;
	printf("Get your key: ");
	printf("%x\n", hash);
	return 0;
}

在网站运行一下 上面的c脚本,或者下面的python脚本

first=int('cafe',16)
argv3='h4cky0u'
for second in range(100):
	if((second%5!=3)and(second%17==8)):
		break
hash=int(first *31337+(second%17)*11+len(argv3)-1615810207)
print(hex(hash))

c0ffee

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Scorpio-m7

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值