安卓Crackme

接触安卓逆向拿来练手的第一个小程序

分析程序链接: https://pan.baidu.com/s/18kWNe-IH26m5GpQnZOkiNw 密码: jy2m
分析工具:Android Killer
模拟器:夜神模拟器

安装后输入随机输入密码查看验证提示

很显然,可以搜索字符串”错误”、”OK”来定位到关键代码。不过Android Killer提供了检索列出所有字符串的功能…,很方便的得到如下信息。

双击进入,看到错误分支在异常处理中

再上java源码~

大致流程为获取输入字符串,传入check方法中,如不抛出异常,则验证成功。下面贴上check方法代码:

package ctf.bobbydylan;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import ctf.bobdylan.R;

public class M extends T {
    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";
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.main);
        startService(new Intent(this, P.class));
        ((Button) findViewById(R.id.button)).setOnClickListener(new a(this, (TextView) findViewById(R.id.et)));
    }

    protected void onPause() {
        stopService(new Intent(this, P.class));
        super.onPause();
    }
}

这里有个坑,如下图,我们一开始搜索字符串的时候就能发现有两个相似字符串,其实他们是不同类中的方法获取得到的。但是check中调用的是T类中的getkey(),其返回的字符串为”bobdylan”。

逆向获取key:

#include "stdafx.h"
#include <process.h>

int main()
{
    char nArray1[16] = { 0, 3, 13, 19, 85, 5, 15, 78, 22, 7, 7, 68, 14, 5, 15, 42 };
    char nArray2[8] = { 'b', 'o', 'b', 'd', 'y', 'l', 'a', 'n' };
    char nArray3[16] = {0};
    for (int i = 0; i < 16; i++)
    {
        nArray3[i] = (nArray1[i] ^ nArray2[(i % 8) &0xFF]);
        printf("%c", nArray3[i]);
    }
    printf("\n");
    system("pause");
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值