zoukankan      html  css  js  c++  java
  • Pwnable-collision

    一样的连接ssh,输入密码,查看文件

    看看col.c的源码

    #include <stdio.h>
    #include <string.h>
    unsigned long hashcode = 0x21DD09EC;
    unsigned long check_password(const char* p){
        int* ip = (int*)p;
        int i;
        int res=0;
        for(i=0; i<5; i++){
            res += ip[i];
        }
        return res;
    }
    
    int main(int argc, char* argv[]){
        if(argc<2){
            printf("usage : %s [passcode]
    ", argv[0]);
            return 0;
        }
        if(strlen(argv[1]) != 20){
            printf("passcode length should be 20 bytes
    ");
            return 0;
        }
    
        if(hashcode == check_password( argv[1] )){
            system("/bin/cat flag");
            return 0;
        }
        else
            printf("wrong passcode.
    ");
        return 0;
    }

    要使hashcode等于check_password函数的返回值res才能有flag,即hashcode==0x21DD09EC==res,看看check_password函数,强转成int,且分五次输出累加到res,同时下面的main函数的第二个if限制长度为20,一个int为4个字节,分五组刚好20个字节

    我们将0x21DD09EC转成十进制568134124,为了方便计算就加一再除以5,获得113626825‬‬,扣除之前的加一,就是1136268254,即(113,626,825‬‬*4+113,626,8254=568134124)

    再将他们转成十六进制0x6c5cec9*4+0x6c5cec8=0x21dd09ec

    知道了要输入的值就可以进行输入了  这里用python进行小端输入

    $是unix的命令行的提示符,-c 是命令执行

    ./col $(python -c 'print "xc9xcexc5x06"*4+"xc8xcexc5x06"')

     daddy! I just managed to create a hash collision :)

  • 相关阅读:
    Informatica_(6)性能调优
    Informatica_(5)高级应用
    Informatica_(4)工作流
    Informatica_(3)组件
    Informatica_(2)第一个例子
    Informatica_(1)安装
    Linux_(4)Shell编程(下)
    Linux_(3)Shell编程(上)
    Linux_(2)基本命令(下)
    B
  • 原文地址:https://www.cnblogs.com/gaonuoqi/p/11745438.html
Copyright © 2011-2022 走看看