注入代码使用记录
程序员文章站
2022-03-15 18:22:03
...
参考
1.https://jaeger.itscoder.com/android/2016/09/20/nuva-source-code-analysis.html
2.https://blog.csdn.net/heqiangflytosky/article/details/54017311
动态加载内部apk/jar/dex/zip
private static void addDexFile(String dexFile) {
ClassLoader classLoader=Object.class.getClassLoader();
Reflect reflect= Reflect.on(classLoader).field("pathList");
Object firstArray= reflect.field("dexElements").get();
PathClassLoader pathClassLoader=new PathClassLoader(dexFile,classLoader);
Object secondArray= Reflect.on(pathClassLoader).field("pathList").field("dexElements").get();
Class<?> localClass = firstArray.getClass().getComponentType();
int firstArrayLength = Array.getLength(firstArray);
int allLength = firstArrayLength + Array.getLength(secondArray);
Object mergeElements = Array.newInstance(localClass, allLength);
for (int k = 0; k < allLength; ++k) {
if (k < firstArrayLength) {
Array.set(mergeElements, k, Array.get(firstArray, k));
} else {
Array.set(mergeElements, k, Array.get(secondArray, k - firstArrayLength));
}
}
reflect.set("dexElements", mergeElements);
}
反射工具依赖库导入:
implementation 'org.jooq:joor:0.9.5'
调用方法:
addDexFile("/system/framework/andhook.lib.jar");
动态加载外部apk/jar/dex/zip
上一篇: 国产显卡芯动“风华1号”背后的故事:回片后 两晚调通信号
下一篇: Crowd Control