首页 > 其他 > 详细

逆向_open-source

时间:2020-04-03 14:34:11      阅读:73      评论:0      收藏:0      [点我收藏+]

函数

atio:https://baike.baidu.com/item/atoi/10931331?fr=aladdin

strcmp:https://baike.baidu.com/item/strcmp/5495571?fr=aladdin

strlen:https://baike.baidu.com/item/strlen/2737?fr=aladdin

argc argv:https://baike.baidu.com/item/argc%20argv/10826112?fr=aladdin

     https://blog.csdn.net/dgreh/article/details/80985928

源代码:

技术分享图片
#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) {
        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;
}
View Code

分析:

跳过所有if语句,便可以得到flag。

    if (argc != 4) {
        printf("what?\n");
        exit(1);
    }

输出参数为4(实际是3)。argv[0]指向程序运行的全路径名。

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

first=0xcafe便可以跳过该语句。

first=0xcafe

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

跳过该语句的特殊值可以是25

可得second的一个值为25

second=25

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

跳过该语句的条件是strcmp()=0

argv[3]="h4cky0u"

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

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

first=0xcafe

second % 17 = 8

argv[3] = 7

printf("%x\n", hash)

输出hash的16进制数

逆向_open-source

原文:https://www.cnblogs.com/TNTBomb/p/12625662.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!