CTF came(android 版)

放到模拟器上运行是一个验证框
CTF came(android 版)
用工具反编译看看 有一个检查函数
CTF came(android 版)
找在那个函数

CTF came(android 版)
大概知道算法
1.它先去获取 key
2.然创建一个数组
3.然后计算
要注意的是它有俩个 getkey()函数
CTF came(android 版)
看看反编译的源码发现读不通其中就有:
CTF came(android 版)
可能是工具的问题 换个就清析了
CTF came(android 版)
找到关键点 他是把密码一个个字符计算

if ((iArr[i] & 255) != ((str.charAt(i) ^ str2.charAt(i % str2.length())) & 255)) {
//                throw new RuntimeException();
//            }

那好办我就暴力求解(当前类中的key 是错的)

key :   bobdylan
密码:blow,in the winD

CTF came(android 版)
源码

public class allen {
    //正确 key
    public static  String getKey() {
        return "bobdylan";
    }
    public static void  main(String[] args){

        check("allen");
       // System.out.println("allenboy");
    }
    public static void check(String str) {
        int i = 0;
        if (str.length() != 16) {
            //throw new RuntimeException();
        }
        String str2 = "";
        try {
            str2 = getKey();
        } catch (Exception e) {
            System.out.println("allenboy");
            str2 = getKey();
            System.arraycopy(str2, 0, str, 5, 5);
        }
        int[] iArr = new int[16];
        iArr[0] = 0;
        iArr[12] = 14;
        iArr[10] = 7;
        iArr[14] = 15;
        iArr[15] = 42;
        try {
            iArr[1] = 3;
            iArr[5] = 5;
            System.out.println();
        } catch (Exception e2) {
            iArr[5] = 37;
            iArr[1] = 85;
        }
        iArr[6] = 15;
        iArr[2] = 13;
        iArr[3] = 19;
        iArr[11] = 68;
        iArr[4] = 85;
        iArr[13] = 5;
        iArr[9] = 7;
        iArr[7] = 78;
        iArr[8] = 22;
        System.out.println(str2);
        while (i < 16) {  //str为参数     str2为 key
            for(int j=0;j<128;j++){
                char c=(char)j;
                if ((iArr[i] & 255) == ((c^ str2.charAt(i % str2.length())) & 255)) {
                   System.out.print(c);
                }
            }
            i++;
        }
    }

}

//    public void check(String str) {
//        int i = 0;
//        if (str.length() != 16) {
//            throw new RuntimeException();
//        }
//        String str2 = "";
//        try {
//            str2 = getKey();
//        } catch (Exception e) {
//            str2 = getKey();
//            System.arraycopy(str2, 0, str, 5, 5);
//        }
//        int[] iArr = new int[16];
//        iArr[0] = 0;
//        iArr[12] = 14;
//        iArr[10] = 7;
//        iArr[14] = 15;
//        iArr[15] = 42;
//        try {
//            iArr[1] = 3;
//            iArr[5] = 5;
//            System.out.println();
//        } catch (Exception e2) {
//            iArr[5] = 37;
//            iArr[1] = 85;
//        }
//        iArr[6] = 15;
//        iArr[2] = 13;
//        iArr[3] = 19;
//        iArr[11] = 68;
//        iArr[4] = 85;
//        iArr[13] = 5;
//        iArr[9] = 7;
//        iArr[7] = 78;
//        iArr[8] = 22;
//        while (i < str.length()) {
//            if ((iArr[i] & 255) != ((str.charAt(i) ^ str2.charAt(i % str2.length())) & 255)) {
//                throw new RuntimeException();
//            }
//            i++;
//        }
//    }
//
//    public String getKey() {
//        return "bobbydylan";
//    }

转载于:https://blog.51cto.com/haidragon/2136366

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值