前两篇文章分析该APP的抓包、的逆向:
启xin宝app的token算法破解——抓包分析篇(一)
启xin宝app的token算法破解——逆向篇(二)
本篇就将对token静态分析,其实很简单就可以搞定那种。通过idea的全局搜索,直接搜索"token"直接找到token在哪里,上图。


找到了,进去看看,这是MessageUtil类里面,可以看下MessageUtil的具体方法:

具体代码就不贴了,分析到这里发现使用ndk,也就是c编译之后的so文件,这就有点难办了,先不管这个,继续分析下。static {    System.loadLibrary("encrypt-lib");    }

在该类里面有这个return b.a(str);方法,该方法是具体的算法分析。

    /* renamed from: a reason: collision with root package name */    public static String f1288a = "CryptoTool_KEY";    public static String b = "CryptoTool_IV";    public static String c = MessageUtil.getKey();    public static String d = MessageUtil.getIV();    private static final String e = "AES/CBC/PKCS5Padding";    private static byte[] f = a.a(c);    private static SecretKeySpec g = new SecretKeySpec({}, "AES");    private static Cipher h;        public static String a(String str) {        try {            if (h == null) {                f = a.a(c);                g = new SecretKeySpec(f, "AES");                h = Cipher.getInstance(e);                h.init(1, g, new IvParameterSpec(a.a(d)));            }            byte[] bytes = str.getBytes("UTF-8");            byte[] bArr = new byte[h.getOutputSize(bytes.length)];            h.doFinal(bArr, h.update(bytes, 0, bytes.length, bArr, 0));            return Base64.encodeToString(bArr, 2);        } catch (Exception e2) {            e2.printStackTrace();            return null;        }    }

看到该token使用的是AES进行加密,具体的秘钥和偏移则在encrypt-lib里面。
如何能拿到秘钥和偏移呢?这里可以借助frida和xposed的hook进行提取,下一篇进行frida的hook提取。