xpose使用教程 hook java层的代码 (一 公司取名.apk)

发布于:2023-01-24 ⋅ 阅读:(568) ⋅ 点赞:(0)

0. 使用到的apk:

链接:https://pan.baidu.com/s/1VPyRWW6TlaMYWL20La7frw?pwd=gzxv 
提取码:gzxv 
--来自百度网盘超级会员V2的分享

当选择五行时,会跳出会员界面。

 

1. 软件java层,smali分析

将软件拖到Jadx-gui, android killer。进入入口界面代码,可以看到如下代码。通过代码,可以看到基于GetVip()来判断。如果为真,就可以继续,为假就跳出付费购买的连接。

 

 2. 下面使用xpose来修改getvip的返回值。

xposed 主要由三个项目来组成的:

  • Xposed:Xposed的C++ 部分,主要是用来替换 /system/bin/app_process,并为XposedBridge 提供 JNI方法。

  • XposedBridge:Xposed 提供的jar文件,app_process 启动过程中会加载该jar包,其他的 Modules 的开发都是基于 该jar包。

  • XposedInstaller:Xposed的安装包,提供对基于Xposed框架的Modules的管理。

xposed 目前已逐步支持 ART虚拟机,兼容 android 5.0 以上版本。

Xposed使用

在Android 4.0以上Android设备安装:

XposedInstaller

http://repo.xposed.info/module/de.robv.android.xposed.installer

Step 2.1 创建xposde模块,打开android studio,新建带empty activity的module

 Step 2.2 下载xposebridgeapi模块,将下载的api拖进lib文件夹

这里如果没有按照2.3做设置,会报错 java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

GitHub - 924587628/XposedBridgeAPI可利用Xposed框架实现拦截系统方法. Contribute to 924587628/XposedBridgeAPI development by creating an account on GitHub.https://github.com/924587628/XposedBridgeAPI

 

Step 2.3  在Build.Gradle (module)文件中添加依赖包,然后sync

dependencies {

    compileOnly fileTree(dir: 'lib', include: ['*.jar'])
    implementation fileTree(dir: 'assets', include: ['*.*'])

    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'




}

 Step 2.4: 在Module下的AndroidManifest.xml文件添加xposed相关meta标签,用于框架识别

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.hookapp1">

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.HookApp1"
        tools:targetApi="31">

        <!--模块申明,true表示申明为xposed模块-->
        <meta-data
            android:name="xposedmodule"
            android:value="true" />


        <!--模块说明,一般为模块的功能描述-->
        <meta-data
            android:name="xposeddescription"
            android:value="这个模块是用来劫持登录的" />


        <!--模块兼容版本-->
        <meta-data
            android:name="xposedminversion"
            android:value="54" />



        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Step 2.5 添加hook类,继承IXposedHookLoadPackage实现hook方法。

package com.example.hookapp1;

import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;


import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class Myhook implements IXposedHookLoadPackage {
    private static final String TAG;
    private Context hookContext = null;

    static {
        TAG = "XposeHook";
    }

    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {


        Log.e(TAG, "Load app packageName:" + lpparam.packageName);

        Log.i(TAG, "开始hook com.meiyiming.gsname");

        if (lpparam.packageName.trim().equals("com.meiyiming.gsname")) {

                Log.i(TAG, "开始hook吧,先找到activity");

                XposedHelpers.findAndHookMethod("android.content.ContextWrapper", lpparam.classLoader, "getApplicationContext", new XC_MethodHook() {


                            protected void afterHookedMethod(MethodHookParam param) {
                                if (hookContext != null)
                                    return;
                                hookContext = (Context) param.getResult();
                                Log.i(TAG + "hookContext", hookContext.getPackageCodePath());
                            }
                        }
                );
                Log.i(TAG, "开始hook吧,寻找activity结束");


                Log.i(TAG, "开始hook com.meiyiming.gsname.GlobalVar");

                XposedHelpers.findAndHookMethod(
                        //填写目标方法所在的完整类名
                        "com.meiyiming.gsname.GlobalVar",
                        //默认classLoader
                        lpparam.classLoader,
                        //目标方法
                        "GetVip",
                        //方法参数,有几个写几个
                        //String.class,
                        // 注意,要做到与目标方法参数对应,这里不能用Integer.class。
                        //int.class,
                        // Hook回调
                        new XC_MethodHook() {


                            @Override
                            protected void beforeHookedMethod(MethodHookParam param) throws Exception {
                                Log.i(TAG, "劫持开始");


                            }


                            protected void afterHookedMethod(MethodHookParam param) {
                                param.setResult(true);
                                Log.i(TAG, "劫持结束");
                            }
                        }
                );
            }
        }
    }

Step 2.6 在app/main下面新建assets目录,添加xpose_init,内容是hook的类

然后在Step2.3中添加assert相关的代码,可以参考2.3.

Step 2.7 安装然后重启手机,可以看到破解效果,不会提示vip。

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到