2019ISCC的一道安卓题
2021-12-01 本文已影响0人
静析机言
偶然间遇到一道2019 ISCC安卓题,该题难度适中,函数没有动态注册,没有加壳,也没有反调试。
分析
安装,输入注册码

如果输入错误,则会提示“注册失败”。JEB打开apk,发现如下代码

根据checkFirst,要求输入的注册码16位,且由数字1-8组成。然后调用libnative-lib.so的checkSecond函数对注册码进行验证,如果返回值为1,则注册成功。
IDA打开libnative-lib.so查看checkSecond函数,16位注册码划分为两部分:前8位、后8位。经过函数checkfirst和checkAgain的检查。

checkfirst的逻辑为:检查前8位,逐位检查后面的数字是否大于前面的?如果符合,则返回1。很显然,为了返回1,前8位必须为12345678。该函数的逻辑难以由肉眼看出来,动态调试一番就很明了了。

接下来看checkAgain()的流程。

将每个注册码字符减去0x31,转换为数字存储。假设前8位由first数组表示,后8位由second数组表示。要求
second[0]+second[7]=5
second[1]+second[6]=12
second[0]<second[7]
并且,前八位先对自身检查,确保没有重复的数字,后八位也是如此。再就是要求前八位和后八位,相同位置上的数之间的差的绝对值不能相等。
求解
清晰了算法逻辑,且知道了前8位为12345678,写python脚本try.py运行

运行结果如下:

将上述结果加上0x31,后8位即为36275184。
综合前面的结果,得出注册码为:1234567836275184
