所需要环境 : jdk sdk xposed激活安装 xposed激活安装 :https://blog.csdn.net/weixin_38927522/article/details/119832717
1.Android Studio 项目AndroidManifest.xml添加xml标识:
<meta-data
android:name="xposedmodule"
android:value="true"/>
<meta-data
android:name="xposeddescription"
android:value="Xposed Proxy For HOOK"/>
<meta-data
android:name="xposedminversion"
android:value="54"/>
2. 引入jar包并添加依赖:
两个jar包,Bridge是实现,api-82是调用,调用无法查看源代码实现逻辑,故而会小一些,这两个用哪个都可以。
build.gradle下dependencies中引入:
compileOnly files('lib/api-82.jar')
全build.gradle文件如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.sun.xposed"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compileOnly files('lib/api-82.jar')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
3.创建hook类:
package com.sun.xposed;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
public class XposedHook implements IXposedHookLoadPackage{
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
if(loadPackageParam.packageName.equals("cn.com.cvsource")){
XposedBridge.log("编写Xposed插件模板,开启HOOK之路!");
XposedHelpers.findAndHookMethod("cn.com.cvsource.utils.EncryptUtils",
loadPackageParam.classLoader,
"getApiSalt",
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
}
@Override
protected void afterHookedMethod(MethodHookParam param)
throws Throwable {
super.afterHookedMethod(param);
XposedBridge.log("result:"+param.getResult());
param.setResult(true);
}
});
}
}
}
4.在main下创建xposed入口:
? 创建assets文件夹 并创建 xposed_init,写清入口类:com.sun.xposed.XposedHook。
5.运行及打包:
可通过build编译成apk,提供其他人使用。
?
指定目录下创建秘钥,并选择release完成编译。
6.总体结构
|