立即注册,突破游客限制,与技术大牛交流切磋,畅享海量资源,让你的技术之路不再孤单!
您需要 登录 才可以下载或查看,没有账号?立即注册
×
如你所见,该直装用的是宇宙最强加固——(数字加固),并且在Java层和So层都有卡密校验,由于本人没有君子哥那么有实力可以直接手撕该辅助,故采用最近才了解的Frida动态绕过卡密验证。
那么正片开始:
【1. Java层验证】
首先我们先分析更容易的Java层,由于存在数字加固的原因,我们先脱壳拿到Java层的代码(这里推荐君子的无敌脱壳脚本,也是非常的好用,非常的哇塞,非常的very beautiful),然后转到脱好的dex里面分析,由于Java层没有加密,也是很快定位到关键类android.support.little.MainActivity$100000004的handleMessage方法,也就是验证卡密是否正确的方法,然后转Java分析
以下是handleMessage的详细代码,验证逻辑也很简单,就是解析返回的json数据做字符串比对
- package android.support.little; // 包名声明
- import android.content.Context; // 引入 Context 类
- import android.content.Intent; // 引入 Intent 类
- import android.os.Handler; // 引入 Handler 类
- import android.os.Message; // 引入 Message 类
- import android.widget.Toast; // 引入 Toast 类
- import java.text.SimpleDateFormat; // 引入 SimpleDateFormat 类
- import java.util.GregorianCalendar; // 引入 GregorianCalendar 类
- import java.util.UUID; // 引入 UUID 类
- import org.json.JSONException; // 引入 JSONException 类
- import org.json.JSONObject; // 引入 JSONObject 类
-
- // 定义 MainActivity 类的一个静态内部类,继承自 Handler
- class MainActivity$100000004 extends Handler {
-
- // 重写 handleMessage 方法
- @Override
- public void handleMessage(Message message) {
- super.handleMessage(message);
-
- // 根据 message 的类型进行处理
- switch (message.what) {
- case 1:
- try {
- // 检查并读取 imei 文件,如果不存在则创建新的 UUID 并保存
- if (fileUtil.checkFiles(new StringBuffer().append(this.this$0.path).append("imei").toString())) {
- this.this$0.uuid = fileUtil.readFile(new StringBuffer().append(this.this$0.path).append("imei").toString());
- } else {
- this.this$0.uuid = UUID.randomUUID().toString().replace("-", "");
- fileUtil.addFile(new StringBuffer().append(this.this$0.path).append("imei").toString(), this.this$0.uuid);
- }
-
- // 生成随机字符串
- this.this$0.random = new StringBuffer()
- .append(new StringBuffer()
- .append(UUID.randomUUID().toString().replace("-", ""))
- .append(this.this$0.APPKEY).toString())
- .append(this.this$0.uuid).toString();
-
- // 解析 JSON 数据
- JSONObject jSONObject = new JSONObject(this.this$0.content);
- String string = jSONObject.getString("code");
- String optString = jSONObject.optString("check");
- Long l = new Long(jSONObject.optLong("time"));
- String string2 = jSONObject.getString("msg");
-
- // 校验 MD5 值
- if (optString.equals(MainActivity.encodeMD5(
- new StringBuffer()
- .append(new StringBuffer()
- .append(l.toString())
- .append(this.this$0.APPKEY).toString())
- .append(this.this$0.random).toString()))) {
-
- // 弹出违规行为提示
- Toast.makeText((Context) this.this$0, (CharSequence) "违规行为!禁止登录", 1).show();
-
- } else if (string.equals("200")) {
-
- // 解析 VIP 到期时间并弹出成功提示
- Long l2 = new Long(new JSONObject(string2).optLong("vip"));
- GregorianCalendar gregorianCalendar = new GregorianCalendar();
- gregorianCalendar.setTimeInMillis(l2.longValue() * 1000);
- Toast.makeText((Context) this.this$0, (CharSequence)
- new StringBuffer()
- .append("登录成功\n到期时间:")
- .append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
- .format(gregorianCalendar.getTime())).toString(), 1).show();
-
- // 启动新的 Activity
- Intent intent = new Intent();
- intent.setClassName("com.tencent.qqmusic", "com.pengyou.cloneapp.SplashActivity");
- this.this$0.startActivity(intent);
- this.this$0.xhnry();
-
- } else {
- // 弹出失败信息
- Toast.makeText((Context) this.this$0, (CharSequence) string2, 1).show();
- }
-
- } catch (JSONException e) {
- // 处理 JSON 异常,弹出提示信息
- Toast.makeText((Context) this.this$0, (CharSequence) "操作成功,必要时可重新操作一次", 1).show();
- }
- return;
- default:
- return;
- }
- }
- }
复制代码 我们的目标是跳过卡密验证,因此我们只需要关注它验证成功后的逻辑,关键代码如下:
- Intent intent = new Intent();
-
- intent.setClassName("com.tencent.qqmusic", "com.pengyou.cloneapp.SplashActivity");
-
- this.this$0.startActivity(intent);
-
- this.this$0.xhnry();
复制代码 发现它验证成功后干了两件事情,首先它会执行startActivity方法跳转到一个新的界面,也就是辅助的容器界面;然后接着调用xhnry方法,也就是调用辅助的功能,于是,我们可以直接用Frida来Hook这个handleMessage方法直接调用上述的两个方法,从而跳过验证逻辑,代码如下:
- Java.perform(function () {
- // 查找 android.support.little.MainActivity$100000004 类
- var MainActivity100000004 = Java.use('android.support.little.MainActivity$100000004');
-
- // Hook handleMessage 方法
- MainActivity100000004.handleMessage.implementation = function (message) {
- console.log("handleMessage 被调用,开始执行跳转逻辑...");
-
- try {
- // 尝试获取 this$0 对象,确保其正确引用
- var mainActivityInstance = this.this$0.value; // 需要使用 .value 来获取实际对象
-
- if (mainActivityInstance) {
- console.log("path: " + mainActivityInstance.path.value); // 确保 path 存在
-
- // 模拟执行跳转到 SplashActivity
- console.log("准备跳转到 com.tencent.qqmusic 的 SplashActivity...");
- var intent = Java.use("android.content.Intent");
- var newIntent = intent.$new();
- newIntent.setClassName("com.tencent.qqmusic", "com.pengyou.cloneapp.SplashActivity");
-
- // 调用 startActivity 方法
- mainActivityInstance.startActivity(newIntent);
- console.log("跳转成功!");
-
- // 执行 xhnry 方法
- mainActivityInstance.xhnry();
- console.log("xhnry 方法调用完成。");
- } else {
- console.log("mainActivityInstance 未定义,无法执行跳转。");
- }
-
- } catch (e) {
- console.log("出现异常: " + e);
- }
- };
- });
复制代码 这样Java层的验证到这里就算是过了,如果现在用Frida执行这个脚本Hook该辅助的话,辅助跳转容器界面后就会闪退,因为这里触发了So层的卡密校验,那么有问题咱就解决问题,不怕苦不怕难,秉持着宁可累死自己也要饿死作者的精神迎难而上。
【2. So层验证】
首先我威胁作者告诉我so层验证在liblittleHack.so里,紧接着打开心爱的IAD Pro开始静态分析
一顿分析过后,我们发现卡密验证是一个叫sub_3F5F8的函数,该函数位于Java_android_support_little_GlJniView_resize方法向下偏移58
接着分析发现辅助的功能悬浮窗是这个Java_android_support_little_GlJniView_step方法调用的,大胆猜测辅助会先调用验证函数sub_3F5F8,验证成功后再调用Java_android_support_little_GlJniView_step,验证失败就退出程序。想清楚这一点,我们就可以开始编写Frida的Hook代码了,同Hook Java层的思路一样,首先通过Java_android_support_little_GlJniView_resize偏移找到验证函数sub_3F5F8,通过Hook该函数,直接调用功能函数Java_android_support_little_GlJniView_step,从而跳过验证达到破解的效果。下面是Hook So层的代码:
- // SO层:Hook liblittleHack.so 中的 Java_android_support_little_GlJniView_resize 函数
- var moduleName = "liblittleHack.so";
-
- // 定义查找模块的函数
- var findModule = function () {
- var module = Process.findModuleByName(moduleName);
- if (module) {
- console.log("找到模块: " + moduleName + " 地址: " + module.base);
- findAndHookFunction(module);
- } else {
- console.log("模块未找到,等待加载...");
- setTimeout(findModule, 1000);
- }
- };
-
- // 定义查找并 Hook 函数的函数
- var findAndHookFunction = function (module) {
- var targetFunctionName = "Java_android_support_little_GlJniView_resize";
- var exports = Module.enumerateExports(moduleName);
- for (var i = 0; i < exports.length; i++) {
- if (exports[i].name === targetFunctionName) {
- console.log("找到函数: " + targetFunctionName + " 地址: " + exports[i].address);
-
- // 偏移 0x58 处的 sub_3F5F8 函数地址
- var subFunctionAddress = exports[i].address.add(0x58);
- console.log("sub_3F5F8 地址: " + subFunctionAddress);
-
- // 使用 Interceptor.replace 替换 sub_3F5F8 函数
- Interceptor.replace(subFunctionAddress, new NativeCallback(function () {
- console.log("sub_3F5F8 被调用,准备调用 Java 方法");
-
- // 调用 Java 方法
- try {
- var clazz = Java.use('android.support.little.GlJniView');
- clazz.step(); // 替换为实际的 Java 方法
- console.log("成功调用 Java 方法");
- } catch (err) {
- console.log("调用 Java 方法时出错: " + err);
- }
-
- // 根据实际返回类型调整
- return 0;
- }, 'int', []));
-
- console.log("成功替换 sub_3F5F8 函数");
- return;
- }
- }
- console.log("未找到函数: " + targetFunctionName);
- };
-
- // 开始查找模块
- findModule();
复制代码
最后把Java层跟So层的脚本代码合并成一个js文件后启动Frida,注意调用顺序,先等Java层执行完xhnry方法后再调用So层的Hook函数。总结一下,卡密随便输入后点击登录,执行Java层的验证函数,这里被我们Hook后直接执行登录成功后的逻辑,并调用So层验证的函数,这里同样被我们提前布局,直接调用辅助的功能面板,至此完美闭环,正义战胜邪恶!
最终效果图
本帖在逆想原创首发,欢迎大家评论交流,祝逆想大家族越来越庞大
|