Compare commits
3 Commits
addJavaInj
...
multiblock
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d5a626750 | ||
|
|
be5208409d | ||
|
|
fd5799cc95 |
@@ -5,6 +5,6 @@
|
|||||||
#ifndef ZYGISK_IL2CPPDUMPER_GAME_H
|
#ifndef ZYGISK_IL2CPPDUMPER_GAME_H
|
||||||
#define ZYGISK_IL2CPPDUMPER_GAME_H
|
#define ZYGISK_IL2CPPDUMPER_GAME_H
|
||||||
|
|
||||||
#define AimPackageName "com.example.testdlopen"
|
#define AimPackageName "com.tencent.mobileqq"
|
||||||
|
|
||||||
#endif //ZYGISK_IL2CPPDUMPER_GAME_H
|
#endif //ZYGISK_IL2CPPDUMPER_GAME_H
|
||||||
|
|||||||
@@ -18,28 +18,33 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
//#include <asm-generic/fcntl.h>
|
//#include <asm-generic/fcntl.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
void load_so(const char *game_data_dir, JavaVM *vm, const char *soname) {
|
||||||
void hack_start(const char *game_data_dir,JavaVM *vm) {
|
|
||||||
bool load = false;
|
bool load = false;
|
||||||
LOGI("hack_start %s", game_data_dir);
|
LOGI("hack_start %s", game_data_dir);
|
||||||
// 构建新文件路径
|
|
||||||
char new_so_path[256];
|
|
||||||
snprintf(new_so_path, sizeof(new_so_path), "%s/files/%s.so", game_data_dir, "test");
|
|
||||||
|
|
||||||
// 复制 /sdcard/test.so 到 game_data_dir 并重命名
|
// 构建新文件路径,使用传入的 soname 参数
|
||||||
const char *src_path = "/data/local/tmp/test.so";
|
char new_so_path[256];
|
||||||
|
snprintf(new_so_path, sizeof(new_so_path), "%s/files/%s.so", game_data_dir, soname);
|
||||||
|
|
||||||
|
// 构建源文件路径
|
||||||
|
char src_path[256];
|
||||||
|
snprintf(src_path, sizeof(src_path), "/data/local/tmp/%s.so", soname);
|
||||||
|
|
||||||
|
// 打开源文件
|
||||||
int src_fd = open(src_path, O_RDONLY);
|
int src_fd = open(src_path, O_RDONLY);
|
||||||
if (src_fd < 0) {
|
if (src_fd < 0) {
|
||||||
LOGE("Failed to open %s: %s (errno: %d)", src_path, strerror(errno), errno);
|
LOGE("Failed to open %s: %s (errno: %d)", src_path, strerror(errno), errno);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 打开目标文件
|
||||||
int dest_fd = open(new_so_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
int dest_fd = open(new_so_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||||
if (dest_fd < 0) {
|
if (dest_fd < 0) {
|
||||||
LOGE("Failed to open %s", new_so_path);
|
LOGE("Failed to open %s", new_so_path);
|
||||||
close(src_fd);
|
close(src_fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 复制文件内容
|
// 复制文件内容
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
ssize_t bytes;
|
ssize_t bytes;
|
||||||
@@ -52,18 +57,21 @@ void hack_start(const char *game_data_dir,JavaVM *vm) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 关闭文件描述符
|
||||||
close(src_fd);
|
close(src_fd);
|
||||||
close(dest_fd);
|
close(dest_fd);
|
||||||
|
|
||||||
|
// 修改文件权限
|
||||||
if (chmod(new_so_path, 0755) != 0) {
|
if (chmod(new_so_path, 0755) != 0) {
|
||||||
LOGE("Failed to change permissions on %s: %s (errno: %d)", new_so_path, strerror(errno), errno);
|
LOGE("Failed to change permissions on %s: %s (errno: %d)", new_so_path, strerror(errno), errno);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
LOGI("Successfully changed permissions to 755 on %s", new_so_path);
|
LOGI("Successfully changed permissions to 755 on %s", new_so_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加载 .so 文件
|
||||||
void *handle;
|
void *handle;
|
||||||
// 使用 xdl_open 打开新复制的 so 文件
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
// void *handle = xdl_open(new_so_path, 0);
|
|
||||||
handle = dlopen(new_so_path, RTLD_NOW | RTLD_LOCAL);
|
handle = dlopen(new_so_path, RTLD_NOW | RTLD_LOCAL);
|
||||||
if (handle) {
|
if (handle) {
|
||||||
LOGI("Successfully loaded %s", new_so_path);
|
LOGI("Successfully loaded %s", new_so_path);
|
||||||
@@ -74,18 +82,26 @@ void hack_start(const char *game_data_dir,JavaVM *vm) {
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果加载失败
|
||||||
if (!load) {
|
if (!load) {
|
||||||
LOGI("test.so not found in thread %d", gettid());
|
LOGI("%s.so not found in thread %d", soname, gettid());
|
||||||
}
|
|
||||||
void (*JNI_OnLoad)(JavaVM *, void *);
|
|
||||||
*(void **) (&JNI_OnLoad) = dlsym(handle, "JNI_OnLoad");
|
|
||||||
if (JNI_OnLoad) {
|
|
||||||
LOGI("JNI_OnLoad symbol found, calling JNI_OnLoad.");
|
|
||||||
JNI_OnLoad(vm, NULL);
|
|
||||||
} else {
|
|
||||||
LOGE("JNI_OnLoad symbol not found in %s", new_so_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查找 JNI_OnLoad 并调用
|
||||||
|
// void (*setupSignalHandler)();
|
||||||
|
// *(void **) (&setupSignalHandler) = dlsym(handle, "setupSignalHandler");
|
||||||
|
//
|
||||||
|
// if (setupSignalHandler) {
|
||||||
|
// LOGI("setupSignalHandler symbol found, calling setupSignalHandler.");
|
||||||
|
// setupSignalHandler(); // 调用找到的函数
|
||||||
|
// } else {
|
||||||
|
// LOGE("setupSignalHandler symbol not found in %s", new_so_path);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
void hack_start(const char *game_data_dir,JavaVM *vm) {
|
||||||
|
load_so(game_data_dir,vm,"test");
|
||||||
|
//如果要注入多个so,那么就在这里不断的添加load_so函数即可
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetLibDir(JavaVM *vms) {
|
std::string GetLibDir(JavaVM *vms) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
|
||||||
#define LOG_TAG "Perfare"
|
#define LOG_TAG "myinjector"
|
||||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
||||||
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
|
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
|
||||||
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
|
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
|
||||||
|
|||||||
@@ -25,7 +25,11 @@ public:
|
|||||||
void preAppSpecialize(AppSpecializeArgs *args) override {
|
void preAppSpecialize(AppSpecializeArgs *args) override {
|
||||||
auto package_name = env->GetStringUTFChars(args->nice_name, nullptr);
|
auto package_name = env->GetStringUTFChars(args->nice_name, nullptr);
|
||||||
auto app_data_dir = env->GetStringUTFChars(args->app_data_dir, nullptr);
|
auto app_data_dir = env->GetStringUTFChars(args->app_data_dir, nullptr);
|
||||||
LOGI("preAppSpecialize %s %s", package_name, app_data_dir);
|
// if (strcmp(package_name, AimPackageName) == 0){
|
||||||
|
// args->runtime_flags=8451;
|
||||||
|
// }
|
||||||
|
LOGI("preAppSpecialize %s %s %d", package_name, app_data_dir,args->runtime_flags);
|
||||||
|
|
||||||
preSpecialize(package_name, app_data_dir);
|
preSpecialize(package_name, app_data_dir);
|
||||||
env->ReleaseStringUTFChars(args->nice_name, package_name);
|
env->ReleaseStringUTFChars(args->nice_name, package_name);
|
||||||
env->ReleaseStringUTFChars(args->app_data_dir, app_data_dir);
|
env->ReleaseStringUTFChars(args->app_data_dir, app_data_dir);
|
||||||
|
|||||||
Reference in New Issue
Block a user