19 Commits

Author SHA1 Message Date
Yuuki
ad2b785f1e Merge branch 'feature/add_inject_hide' of https://github.com/jiqiu2022/Zygisk-MyInjector into feature/add_inject_hide 2025-10-25 21:10:58 +08:00
Yuuki
29a678c6dd Update injectHide.kpm 2025-10-25 21:10:55 +08:00
jiqiu2021
6a79189290 feat:修改kpm config的路径 2025-10-25 20:16:44 +08:00
Yuuki
7e23ed7281 Update injectHide.kpm 2025-10-25 18:21:11 +08:00
Yuuki
aba55bfa57 Create injectHide.kpm 2025-10-25 17:43:04 +08:00
jiqiu2021
ab46a223f1 feat:增加kpm注入功能 2025-10-25 17:28:47 +08:00
jiqiu2021
3e5453ecf8 feat:移除旧版无用代码 2025-10-25 16:50:51 +08:00
Ji qiu
ec89b7bf2c Merge pull request #29 from vwww-droid/fix/improve-meta-inf-handling
feat: Fix META-INF handling in build script
2025-10-15 15:57:50 +08:00
vwvw
cc47334970 feat: Fix META-INF handling in build script
1. 修复因 META-INF 文件在 pixel 4 android 13 狐妖magisk 27001 无法识别为 magisk module 的问题
2025-10-15 11:16:13 +08:00
Ji qiu
8a23161e0f Merge pull request #22 from jiqiu2022/fix_bug
Fix bug
2025-06-28 21:21:49 +08:00
jiqiu2021
964c975cdd feat:bugfix 2025-06-28 21:18:43 +08:00
jiqiu2021
6110216556 feat:bugfix 2025-06-28 20:25:17 +08:00
jiqiu2021
e02a3df7fc feat:bugfix 2025-06-27 21:52:51 +08:00
Ji qiu
cb64bc7d48 Merge pull request #20 from jiqiu2022/fix_bug
紧急bug修复
2025-06-27 18:26:17 +08:00
jiqiu2021
fc24ab3455 feat:自定义linker静态编译,解决报错 2025-06-27 17:47:26 +08:00
jiqiu2021
7e7b38caf6 feat:gadget全局配置 2025-06-27 17:31:01 +08:00
Ji qiu
b8b8dafed0 Update README.md 2025-06-27 17:02:08 +08:00
Ji qiu
7b7389c0a0 Update README.md 2025-06-27 16:59:57 +08:00
Ji qiu
122878f8fa Update README.md 2025-06-27 16:59:13 +08:00
24 changed files with 1378 additions and 395 deletions

View File

@@ -12,13 +12,15 @@
项目已完全开源包含面具模块、管理APP以及所有打包脚本并配置了GitHub CI自动构建。欢迎各位开发者贡献代码提交PR。
### 版本规划
### 版本规划&更新记录
版本规划:
- **v1.x**:专注功能添加,暂不考虑反检测
- **v2.x**实现各种检测绕过达到100%无痕注入
更新记录:
- **v1.2**: 增加gadget配置的自动生成支持脚本和server模式解决了若干bug增加了全局注入延迟设置
## 致谢
**项目地址**[https://github.com/jiqiu2022/Zygisk-MyInjector](https://github.com/jiqiu2022/Zygisk-MyInjector)
特别感谢以下项目和开发者(按时间顺序):

View File

@@ -105,10 +105,14 @@ else
exit 1
fi
# 创建 META-INF 目录Magisk 需要)
mkdir -p $TEMP_DIR/META-INF/com/google/android
touch $TEMP_DIR/META-INF/com/google/android/update-binary
touch $TEMP_DIR/META-INF/com/google/android/updater-script
# 复制 META-INF 目录Magisk 需要)
if [ -d "template/magisk_module/META-INF" ]; then
cp -r template/magisk_module/META-INF $TEMP_DIR/
echo -e " ${GREEN}✓ 复制 META-INF${NC}"
else
echo -e " ${RED}✗ 未找到 META-INF 模板${NC}"
exit 1
fi
# 打包
echo -e "\n${YELLOW}[5/5] 打包模块...${NC}"

View File

@@ -140,7 +140,11 @@ public class AppListFragment extends Fragment implements AppListAdapter.OnAppTog
RadioButton radioStandardInjection = dialogView.findViewById(R.id.radioStandardInjection);
RadioButton radioRiruInjection = dialogView.findViewById(R.id.radioRiruInjection);
RadioButton radioCustomLinkerInjection = dialogView.findViewById(R.id.radioCustomLinkerInjection);
CheckBox checkboxEnableGadget = dialogView.findViewById(R.id.checkboxEnableGadget);
RadioGroup gadgetConfigGroup = dialogView.findViewById(R.id.gadgetConfigGroup);
RadioButton radioNoGadget = dialogView.findViewById(R.id.radioNoGadget);
RadioButton radioUseGlobalGadget = dialogView.findViewById(R.id.radioUseGlobalGadget);
RadioButton radioUseCustomGadget = dialogView.findViewById(R.id.radioUseCustomGadget);
TextView tvGlobalGadgetInfo = dialogView.findViewById(R.id.tvGlobalGadgetInfo);
com.google.android.material.button.MaterialButton btnConfigureGadget = dialogView.findViewById(R.id.btnConfigureGadget);
appIcon.setImageDrawable(appInfo.getAppIcon());
@@ -158,30 +162,71 @@ public class AppListFragment extends Fragment implements AppListAdapter.OnAppTog
}
// Load gadget config
ConfigManager.GadgetConfig gadgetConfig = configManager.getAppGadgetConfig(appInfo.getPackageName());
checkboxEnableGadget.setChecked(gadgetConfig != null);
btnConfigureGadget.setEnabled(gadgetConfig != null);
boolean useGlobalGadget = configManager.getAppUseGlobalGadget(appInfo.getPackageName());
ConfigManager.GadgetConfig appSpecificGadget = configManager.getAppGadgetConfig(appInfo.getPackageName());
ConfigManager.GadgetConfig globalGadget = configManager.getGlobalGadgetConfig();
// Setup gadget listeners
checkboxEnableGadget.setOnCheckedChangeListener((buttonView, isChecked) -> {
btnConfigureGadget.setEnabled(isChecked);
if (!isChecked) {
// Remove gadget config when unchecked
// Update global gadget info
if (globalGadget != null) {
String info = "全局: " + globalGadget.gadgetName;
if (globalGadget.mode.equals("server")) {
info += " (端口: " + globalGadget.port + ")";
}
tvGlobalGadgetInfo.setText(info);
} else {
tvGlobalGadgetInfo.setText("未配置全局Gadget");
}
// Set initial radio selection
if (!useGlobalGadget && appSpecificGadget != null) {
radioUseCustomGadget.setChecked(true);
btnConfigureGadget.setVisibility(View.VISIBLE);
btnConfigureGadget.setEnabled(true);
} else if (useGlobalGadget && globalGadget != null) {
radioUseGlobalGadget.setChecked(true);
btnConfigureGadget.setVisibility(View.GONE);
} else {
radioNoGadget.setChecked(true);
btnConfigureGadget.setVisibility(View.GONE);
}
// Setup gadget radio group listener
gadgetConfigGroup.setOnCheckedChangeListener((group, checkedId) -> {
if (checkedId == R.id.radioNoGadget) {
btnConfigureGadget.setVisibility(View.GONE);
configManager.setAppUseGlobalGadget(appInfo.getPackageName(), false);
configManager.setAppGadgetConfig(appInfo.getPackageName(), null);
} else if (checkedId == R.id.radioUseGlobalGadget) {
btnConfigureGadget.setVisibility(View.GONE);
configManager.setAppUseGlobalGadget(appInfo.getPackageName(), true);
configManager.setAppGadgetConfig(appInfo.getPackageName(), null);
} else if (checkedId == R.id.radioUseCustomGadget) {
btnConfigureGadget.setVisibility(View.VISIBLE);
btnConfigureGadget.setEnabled(true);
configManager.setAppUseGlobalGadget(appInfo.getPackageName(), false);
}
});
// Configure button listener
btnConfigureGadget.setOnClickListener(v -> {
ConfigManager.GadgetConfig currentConfig = configManager.getAppGadgetConfig(appInfo.getPackageName());
ConfigManager.GadgetConfig currentConfig = null;
if (!useGlobalGadget) {
currentConfig = configManager.getAppGadgetConfig(appInfo.getPackageName());
}
if (currentConfig == null) {
currentConfig = new ConfigManager.GadgetConfig();
}
GadgetConfigDialog gadgetDialog = GadgetConfigDialog.newInstance(currentConfig);
gadgetDialog.setOnGadgetConfigListener(config -> {
configManager.setAppGadgetConfig(appInfo.getPackageName(), config);
});
gadgetDialog.show(getParentFragmentManager(), "gadget_config");
GadgetConfigDialog dialog = new GadgetConfigDialog(
getContext(),
"配置" + appInfo.getAppName() + "的Gadget",
currentConfig,
config -> {
configManager.setAppUseGlobalGadget(appInfo.getPackageName(), false);
configManager.setAppGadgetConfig(appInfo.getPackageName(), config);
}
);
dialog.show();
});
// Setup SO list
@@ -216,16 +261,6 @@ public class AppListFragment extends Fragment implements AppListAdapter.OnAppTog
}
configManager.setAppInjectionMethod(appInfo.getPackageName(), selectedMethod);
// Save gadget config if enabled
if (checkboxEnableGadget.isChecked()) {
ConfigManager.GadgetConfig currentGadgetConfig = configManager.getAppGadgetConfig(appInfo.getPackageName());
if (currentGadgetConfig == null) {
// Create default config if not already configured
currentGadgetConfig = new ConfigManager.GadgetConfig();
configManager.setAppGadgetConfig(appInfo.getPackageName(), currentGadgetConfig);
}
}
// Save SO selection
if (soListRecyclerView.getAdapter() != null) {
SoSelectionAdapter adapter = (SoSelectionAdapter) soListRecyclerView.getAdapter();

View File

@@ -18,10 +18,14 @@ public class ConfigManager {
public static final String MODULE_PATH = "/data/adb/modules/zygisk-myinjector";
public static final String CONFIG_FILE = MODULE_PATH + "/config.json";
public static final String SO_STORAGE_DIR = MODULE_PATH + "/so_files";
public static final String KPM_MODULE_PATH = MODULE_PATH + "/injectHide.kpm";
public static final String KPM_HIDE_CONFIG = "/data/local/tmp/kpm_hide_config.txt";
private static final String KPM_MODULE_NAME = "hideInject";
private final Context context;
private final Gson gson;
private ModuleConfig config;
private final Object kpmLock = new Object(); // 用于同步 KPM 操作
static {
// Configure Shell to use root
@@ -163,20 +167,44 @@ public class ConfigManager {
}
}
// Ensure SO storage directory exists
Shell.cmd("mkdir -p " + SO_STORAGE_DIR).exec();
Shell.cmd("chmod 755 " + SO_STORAGE_DIR).exec();
// Copy SO file to our storage
Log.i(TAG, "Copying SO file from: " + originalPath + " to: " + storedPath);
Shell.Result result = Shell.cmd("cp \"" + originalPath + "\" \"" + storedPath + "\"").exec();
if (result.isSuccess()) {
// Verify the file was actually copied
Shell.Result verifyResult = Shell.cmd("test -f \"" + storedPath + "\" && echo 'exists'").exec();
if (!verifyResult.isSuccess() || verifyResult.getOut().isEmpty()) {
Log.e(TAG, "File copy appeared successful but file not found at: " + storedPath);
return;
}
// Set proper permissions for SO file (readable and executable)
Shell.Result chmodResult = Shell.cmd("chmod 755 \"" + storedPath + "\"").exec();
if (!chmodResult.isSuccess()) {
Log.e(TAG, "Failed to set permissions on SO file: " + String.join("\n", chmodResult.getErr()));
}
SoFile soFile = new SoFile();
soFile.name = fileName;
soFile.storedPath = storedPath;
soFile.originalPath = originalPath;
config.globalSoFiles.add(soFile);
Log.i(TAG, "Successfully added SO file: " + fileName + " to storage");
if (deleteOriginal) {
Shell.cmd("rm \"" + originalPath + "\"").exec();
Log.i(TAG, "Deleted original file: " + originalPath);
}
saveConfig();
} else {
Log.e(TAG, "Failed to copy SO file: " + String.join("\n", result.getErr()));
}
}
@@ -265,11 +293,46 @@ public class ConfigManager {
public GadgetConfig getAppGadgetConfig(String packageName) {
AppConfig appConfig = config.perAppConfig.get(packageName);
if (appConfig == null) {
return null;
// If no app config, return global gadget config
return config.globalGadgetConfig;
}
// If app is set to use global gadget, return global config
if (appConfig.useGlobalGadget) {
return config.globalGadgetConfig;
}
// Otherwise return app-specific gadget config
return appConfig.gadgetConfig;
}
public GadgetConfig getGlobalGadgetConfig() {
return config.globalGadgetConfig;
}
public void setGlobalGadgetConfig(GadgetConfig gadgetConfig) {
config.globalGadgetConfig = gadgetConfig;
saveConfig();
}
public boolean getAppUseGlobalGadget(String packageName) {
AppConfig appConfig = config.perAppConfig.get(packageName);
if (appConfig == null) {
return true; // Default to use global
}
return appConfig.useGlobalGadget;
}
public void setAppUseGlobalGadget(String packageName, boolean useGlobal) {
AppConfig appConfig = config.perAppConfig.get(packageName);
if (appConfig == null) {
appConfig = new AppConfig();
config.perAppConfig.put(packageName, appConfig);
}
appConfig.useGlobalGadget = useGlobal;
saveConfig();
}
public void setAppGadgetConfig(String packageName, GadgetConfig gadgetConfig) {
AppConfig appConfig = config.perAppConfig.get(packageName);
if (appConfig == null) {
@@ -405,28 +468,36 @@ public class ConfigManager {
// Create files directory in app's data dir
String filesDir = "/data/data/" + packageName + "/files";
// Use su -c for better compatibility
Shell.Result mkdirResult = Shell.cmd("su -c 'mkdir -p " + filesDir + "'").exec();
Log.i(TAG, "Deploying SO files to: " + filesDir);
// Create directory without su -c for better compatibility
Shell.Result mkdirResult = Shell.cmd("mkdir -p " + filesDir).exec();
if (!mkdirResult.isSuccess()) {
Log.e(TAG, "Failed to create directory: " + filesDir);
Log.e(TAG, "Error: " + String.join("\n", mkdirResult.getErr()));
// Try without su -c
mkdirResult = Shell.cmd("mkdir -p " + filesDir).exec();
if (!mkdirResult.isSuccess()) {
Log.e(TAG, "Also failed without su -c");
return;
}
return;
}
// Set proper permissions and ownership
Shell.cmd("chmod 755 " + filesDir).exec();
// Set proper permissions and ownership for the files directory
Shell.cmd("chmod 771 " + filesDir).exec();
// Get UID for the package
// Get UID and GID for the package
Shell.Result uidResult = Shell.cmd("stat -c %u /data/data/" + packageName).exec();
String uid = "";
if (uidResult.isSuccess() && !uidResult.getOut().isEmpty()) {
uid = uidResult.getOut().get(0).trim();
Log.i(TAG, "Package UID: " + uid);
// Set ownership of files directory to match app
Shell.Result chownDirResult = Shell.cmd("chown " + uid + ":" + uid + " \"" + filesDir + "\"").exec();
if (!chownDirResult.isSuccess()) {
Log.e(TAG, "Failed to set directory ownership: " + String.join("\n", chownDirResult.getErr()));
}
// Set SELinux context for the directory
Shell.cmd("chcon u:object_r:app_data_file:s0 \"" + filesDir + "\"").exec();
} else {
Log.e(TAG, "Failed to get package UID");
}
// Copy each SO file configured for this app
@@ -438,39 +509,66 @@ public class ConfigManager {
Shell.Result checkResult = Shell.cmd("test -f \"" + soFile.storedPath + "\" && echo 'exists'").exec();
if (!checkResult.isSuccess() || checkResult.getOut().isEmpty()) {
Log.e(TAG, "Source SO file not found: " + soFile.storedPath);
// Log more details about the missing file
Shell.Result lsResult = Shell.cmd("ls -la \"" + SO_STORAGE_DIR + "\"").exec();
Log.e(TAG, "Contents of SO storage dir: " + String.join("\n", lsResult.getOut()));
continue;
}
Log.i(TAG, "Copying: " + soFile.storedPath + " to " + destPath);
// Copy file using cat to avoid permission issues
String copyCmd = "cat \"" + soFile.storedPath + "\" > \"" + destPath + "\"";
Shell.Result result = Shell.cmd(copyCmd).exec();
// First, ensure the destination directory exists and has proper permissions
Shell.cmd("mkdir -p \"" + filesDir + "\"").exec();
Shell.cmd("chmod 755 \"" + filesDir + "\"").exec();
// Copy file using cp with force flag
Shell.Result result = Shell.cmd("cp -f \"" + soFile.storedPath + "\" \"" + destPath + "\"").exec();
if (!result.isSuccess()) {
Log.e(TAG, "Failed with cat, trying cp");
// Fallback to cp
result = Shell.cmd("cp -f \"" + soFile.storedPath + "\" \"" + destPath + "\"").exec();
Log.e(TAG, "Failed with cp, trying cat method");
Log.e(TAG, "cp error: " + String.join("\n", result.getErr()));
// Fallback to cat method
result = Shell.cmd("cat \"" + soFile.storedPath + "\" > \"" + destPath + "\"").exec();
if (!result.isSuccess()) {
Log.e(TAG, "Also failed with cat method");
Log.e(TAG, "cat error: " + String.join("\n", result.getErr()));
}
}
// Set permissions
Shell.cmd("chmod 755 \"" + destPath + "\"").exec();
// Set permissions - SO files need to be readable and executable
Shell.Result chmodResult = Shell.cmd("chmod 755 \"" + destPath + "\"").exec();
if (!chmodResult.isSuccess()) {
Log.e(TAG, "Failed to set permissions: " + String.join("\n", chmodResult.getErr()));
}
// Set ownership if we have the UID
// Set ownership to match the app's UID
if (!uid.isEmpty()) {
Shell.cmd("chown " + uid + ":" + uid + " \"" + destPath + "\"").exec();
Shell.Result chownResult = Shell.cmd("chown " + uid + ":" + uid + " \"" + destPath + "\"").exec();
if (!chownResult.isSuccess()) {
Log.e(TAG, "Failed to set ownership: " + String.join("\n", chownResult.getErr()));
// Try alternative method
Shell.cmd("chown " + uid + ".app_" + uid + " \"" + destPath + "\"").exec();
}
}
// Verify the file was copied
Shell.Result verifyResult = Shell.cmd("ls -la \"" + destPath + "\" 2>/dev/null").exec();
// Set SELinux context to match app's data files
Shell.Result contextResult = Shell.cmd("chcon u:object_r:app_data_file:s0 \"" + destPath + "\"").exec();
if (!contextResult.isSuccess()) {
Log.w(TAG, "Failed to set SELinux context (this may be normal on some devices)");
}
// Verify the file was copied with correct permissions
Shell.Result verifyResult = Shell.cmd("ls -laZ \"" + destPath + "\" 2>/dev/null").exec();
if (verifyResult.isSuccess() && !verifyResult.getOut().isEmpty()) {
Log.i(TAG, "Successfully deployed: " + String.join(" ", verifyResult.getOut()));
} else {
Log.e(TAG, "Failed to verify SO file copy: " + destPath);
// Try another verification method
Shell.Result sizeResult = Shell.cmd("stat -c %s \"" + destPath + "\" 2>/dev/null").exec();
if (sizeResult.isSuccess() && !sizeResult.getOut().isEmpty()) {
Log.i(TAG, "File exists with size: " + sizeResult.getOut().get(0) + " bytes");
// Fallback verification without SELinux context
verifyResult = Shell.cmd("ls -la \"" + destPath + "\" 2>/dev/null").exec();
if (verifyResult.isSuccess() && !verifyResult.getOut().isEmpty()) {
Log.i(TAG, "Successfully deployed: " + String.join(" ", verifyResult.getOut()));
} else {
Log.e(TAG, "Failed to verify SO file copy: " + destPath);
}
}
}
@@ -478,8 +576,9 @@ public class ConfigManager {
Log.i(TAG, "Deployment complete for: " + packageName);
// Deploy gadget config if configured
if (appConfig.gadgetConfig != null) {
deployGadgetConfigFile(packageName, appConfig.gadgetConfig);
ConfigManager.GadgetConfig gadgetToUse = getAppGadgetConfig(packageName);
if (gadgetToUse != null) {
deployGadgetConfigFile(packageName, gadgetToUse);
}
}
@@ -527,8 +626,9 @@ public class ConfigManager {
}
// Clean up gadget config file if exists
if (appConfig.gadgetConfig != null) {
String gadgetConfigName = appConfig.gadgetConfig.gadgetName.replace(".so", ".config.so");
ConfigManager.GadgetConfig gadgetToUse = getAppGadgetConfig(packageName);
if (gadgetToUse != null) {
String gadgetConfigName = gadgetToUse.gadgetName.replace(".so", ".config.so");
String configPath = filesDir + "/" + gadgetConfigName;
Shell.Result checkConfigResult = Shell.cmd("test -f \"" + configPath + "\" && echo 'exists'").exec();
@@ -555,6 +655,258 @@ public class ConfigManager {
}
}
// ==================== KPM Module Management ====================
/**
* 检查 KPM 模块是否已加载
*/
public boolean isKpmModuleLoaded() {
Shell.Result result = Shell.cmd("lsmod | grep " + KPM_MODULE_NAME).exec();
return result.isSuccess() && !result.getOut().isEmpty();
}
/**
* 加载 KPM 模块
*/
public boolean loadKpmModule() {
if (!isRootAvailable()) {
Log.e(TAG, "Root access not available!");
return false;
}
// Check if module file exists
Shell.Result checkResult = Shell.cmd("test -f \"" + KPM_MODULE_PATH + "\" && echo 'exists'").exec();
if (!checkResult.isSuccess() || checkResult.getOut().isEmpty()) {
Log.e(TAG, "KPM module file not found: " + KPM_MODULE_PATH);
return false;
}
// Check if already loaded
if (isKpmModuleLoaded()) {
Log.i(TAG, "KPM module already loaded");
return true;
}
// Load module
Shell.Result result = Shell.cmd("insmod \"" + KPM_MODULE_PATH + "\"").exec();
if (result.isSuccess()) {
Log.i(TAG, "KPM module loaded successfully");
return true;
} else {
Log.e(TAG, "Failed to load KPM module: " + String.join("\n", result.getErr()));
return false;
}
}
/**
* 卸载 KPM 模块
*/
public boolean unloadKpmModule() {
if (!isRootAvailable()) {
Log.e(TAG, "Root access not available!");
return false;
}
if (!isKpmModuleLoaded()) {
Log.i(TAG, "KPM module not loaded");
return true;
}
Shell.Result result = Shell.cmd("rmmod " + KPM_MODULE_NAME).exec();
if (result.isSuccess()) {
Log.i(TAG, "KPM module unloaded successfully");
return true;
} else {
Log.e(TAG, "Failed to unload KPM module: " + String.join("\n", result.getErr()));
return false;
}
}
/**
* 重新加载 KPM 模块
*/
public boolean reloadKpmModule() {
// 使用锁防止并发重载
synchronized (kpmLock) {
Log.i(TAG, "Reloading KPM module...");
// Unload first
if (isKpmModuleLoaded()) {
if (!unloadKpmModule()) {
Log.e(TAG, "Failed to unload module before reload");
return false;
}
// Give kernel more time to cleanup (1 second for safety)
// 等待时间足够让内核完全清理资源
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Log.w(TAG, "Sleep interrupted during module reload", e);
Thread.currentThread().interrupt();
return false;
}
// Verify unload was successful
int retries = 5;
for (int i = 0; i < retries; i++) {
if (!isKpmModuleLoaded()) {
break;
}
Log.w(TAG, "Module still loaded, waiting... (" + (i+1) + "/" + retries + ")");
try {
Thread.sleep(200);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return false;
}
}
if (isKpmModuleLoaded()) {
Log.e(TAG, "Module still loaded after unload attempts, aborting reload");
return false;
}
}
// Load again
boolean success = loadKpmModule();
if (success) {
Log.i(TAG, "Module reloaded successfully");
} else {
Log.e(TAG, "Failed to load module after unload");
}
return success;
} // synchronized
}
/**
* 更新 KPM 隐藏配置并重载模块
*/
public boolean updateKpmHideConfig(List<String> soNames) {
if (!isRootAvailable()) {
Log.e(TAG, "Root access not available!");
return false;
}
// Build config content
StringBuilder configContent = new StringBuilder();
for (String soName : soNames) {
configContent.append(soName).append("\n");
}
// Write to temp file
String tempFile = context.getCacheDir() + "/kpm_hide_config.txt";
try {
java.io.FileWriter writer = new java.io.FileWriter(tempFile);
writer.write(configContent.toString());
writer.close();
// Ensure module directory exists
Shell.cmd("mkdir -p \"" + MODULE_PATH + "\"").exec();
// Ensure /data/local/tmp exists and is writable
Shell.cmd("mkdir -p /data/local/tmp && chmod 777 /data/local/tmp").exec();
// Copy to /data/local/tmp with root
Shell.Result copyResult = Shell.cmd("cp \"" + tempFile + "\" \"" + KPM_HIDE_CONFIG + "\"").exec();
if (!copyResult.isSuccess()) {
Log.e(TAG, "Failed to copy KPM config: " + String.join("\n", copyResult.getErr()));
return false;
}
Shell.cmd("chmod 666 \"" + KPM_HIDE_CONFIG + "\"").exec();
// Clean up temp file
new File(tempFile).delete();
Log.i(TAG, "KPM hide config updated with " + soNames.size() + " entries");
// Reload module to apply changes
return reloadKpmModule();
} catch (Exception e) {
Log.e(TAG, "Failed to update KPM config", e);
return false;
}
}
/**
* 获取当前隐藏的 SO 列表
*/
public List<String> getHiddenSoList() {
List<String> hiddenList = new ArrayList<>();
Shell.Result result = Shell.cmd("cat \"" + KPM_HIDE_CONFIG + "\"").exec();
if (result.isSuccess()) {
for (String line : result.getOut()) {
String trimmed = line.trim();
if (!trimmed.isEmpty()) {
hiddenList.add(trimmed);
}
}
}
return hiddenList;
}
/**
* 添加 SO 到隐藏列表
*/
public boolean addSoToHideList(String soName) {
List<String> hiddenList = getHiddenSoList();
if (!hiddenList.contains(soName)) {
hiddenList.add(soName);
return updateKpmHideConfig(hiddenList);
}
return true;
}
/**
* 从隐藏列表移除 SO
*/
public boolean removeSoFromHideList(String soName) {
List<String> hiddenList = getHiddenSoList();
if (hiddenList.remove(soName)) {
return updateKpmHideConfig(hiddenList);
}
return true;
}
/**
* 获取所有可隐藏的 SO 文件列表(从已启用应用中提取)
*/
public List<String> getAvailableSoList() {
List<String> availableSos = new ArrayList<>();
// Always include our injector library
availableSos.add("libmyinjector.so");
// Add SOs from all enabled apps
for (Map.Entry<String, AppConfig> entry : config.perAppConfig.entrySet()) {
AppConfig appConfig = entry.getValue();
if (appConfig.enabled && appConfig.soFiles != null) {
for (SoFile soFile : appConfig.soFiles) {
if (!availableSos.contains(soFile.name)) {
availableSos.add(soFile.name);
}
}
}
}
// Add global SO files
if (config.globalSoFiles != null) {
for (SoFile soFile : config.globalSoFiles) {
if (!availableSos.contains(soFile.name)) {
availableSos.add(soFile.name);
}
}
}
return availableSos;
}
// Data classes
public static class ModuleConfig {
public boolean enabled = true;
@@ -562,6 +914,7 @@ public class ConfigManager {
public int injectionDelay = 2; // Default 2 seconds
public List<SoFile> globalSoFiles = new ArrayList<>();
public Map<String, AppConfig> perAppConfig = new HashMap<>();
public GadgetConfig globalGadgetConfig = null; // Global gadget configuration
}
public static class AppConfig {
@@ -569,6 +922,7 @@ public class ConfigManager {
public List<SoFile> soFiles = new ArrayList<>();
public String injectionMethod = "standard"; // "standard", "riru" or "custom_linker"
public GadgetConfig gadgetConfig = null;
public boolean useGlobalGadget = true; // Whether to use global gadget settings
}
public static class SoFile {

View File

@@ -115,18 +115,19 @@ public class FileUtils {
// Make file readable
tempFile.setReadable(true, false);
// Use root to copy to a more permanent location
String targetPath = "/data/local/tmp/" + fileName;
// First copy to /data/local/tmp as a temporary location
String tempTargetPath = "/data/local/tmp/" + fileName;
Shell.Result result = Shell.cmd(
"cp \"" + tempFile.getAbsolutePath() + "\" \"" + targetPath + "\"",
"chmod 644 \"" + targetPath + "\""
"cp \"" + tempFile.getAbsolutePath() + "\" \"" + tempTargetPath + "\"",
"chmod 644 \"" + tempTargetPath + "\""
).exec();
// Clean up temp file
tempFile.delete();
if (result.isSuccess()) {
return targetPath;
// Return the temporary path - it will be moved to the proper location by addGlobalSoFile
return tempTargetPath;
} else {
Log.e(TAG, "Failed to copy file to /data/local/tmp/");
return null;

View File

@@ -57,6 +57,7 @@ public class GadgetConfigDialog extends DialogFragment {
// Configuration data
private ConfigManager.GadgetConfig config;
private OnGadgetConfigListener listener;
private String customTitle;
// Flag to prevent recursive updates
private boolean isUpdatingUI = false;
@@ -75,6 +76,21 @@ public class GadgetConfigDialog extends DialogFragment {
return dialog;
}
// Constructor for non-fragment usage
public GadgetConfigDialog(Context context, String title, ConfigManager.GadgetConfig config, OnGadgetConfigListener listener) {
// This constructor is for compatibility with direct dialog creation
// The actual dialog will be created in show() method
this.savedContext = context;
this.customTitle = title;
this.config = config != null ? config : new ConfigManager.GadgetConfig();
this.listener = listener;
}
// Default constructor required for DialogFragment
public GadgetConfigDialog() {
// Empty constructor required
}
public void setOnGadgetConfigListener(OnGadgetConfigListener listener) {
this.listener = listener;
}
@@ -129,8 +145,10 @@ public class GadgetConfigDialog extends DialogFragment {
setupListeners();
updateJsonPreview();
String title = customTitle != null ? customTitle : "Gadget 配置";
return new MaterialAlertDialogBuilder(getContext())
.setTitle("Gadget 配置")
.setTitle(title)
.setView(view)
.setPositiveButton("保存", (dialog, which) -> saveConfig())
.setNegativeButton("取消", null)
@@ -567,6 +585,50 @@ public class GadgetConfigDialog extends DialogFragment {
.show();
}
// Show method for non-fragment usage
public void show() {
if (getContext() == null) {
throw new IllegalStateException("Context is required for non-fragment usage");
}
View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_gadget_config, null);
initViews(view);
// Initialize config if null
if (config == null) {
config = new ConfigManager.GadgetConfig();
}
loadConfig();
setupListeners();
updateJsonPreview();
String title = customTitle != null ? customTitle : "Gadget 配置";
new MaterialAlertDialogBuilder(getContext())
.setTitle(title)
.setView(view)
.setPositiveButton("保存", (dialog, which) -> saveConfig())
.setNegativeButton("取消", null)
.show();
}
private Context savedContext;
@Override
public Context getContext() {
Context context = super.getContext();
if (context == null) {
return savedContext;
}
return context;
}
// Constructor for non-fragment usage needs to save context
public void setContext(Context context) {
this.savedContext = context;
}
private String getPathFromUri(Uri uri) {
String path = null;

View File

@@ -0,0 +1,105 @@
package com.jiqiu.configapp;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
/**
* SO 文件隐藏列表适配器
*/
public class HideSoAdapter extends RecyclerView.Adapter<HideSoAdapter.ViewHolder> {
private final List<KpmHideFragment.HideSoItem> items;
private final OnItemCheckedChangeListener listener;
public interface OnItemCheckedChangeListener {
void onItemCheckedChanged(KpmHideFragment.HideSoItem item, boolean isChecked);
}
public HideSoAdapter(List<KpmHideFragment.HideSoItem> items,
OnItemCheckedChangeListener listener) {
this.items = items;
this.listener = listener;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_hide_so, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
KpmHideFragment.HideSoItem item = items.get(position);
holder.bind(item);
}
@Override
public int getItemCount() {
return items.size();
}
class ViewHolder extends RecyclerView.ViewHolder {
private final CheckBox cbHide;
private final TextView tvSoName;
private final TextView tvSoStatus;
private final TextView tvFixedBadge;
public ViewHolder(@NonNull View itemView) {
super(itemView);
cbHide = itemView.findViewById(R.id.cbHide);
tvSoName = itemView.findViewById(R.id.tvSoName);
tvSoStatus = itemView.findViewById(R.id.tvSoStatus);
tvFixedBadge = itemView.findViewById(R.id.tvFixedBadge);
}
public void bind(KpmHideFragment.HideSoItem item) {
tvSoName.setText(item.soName);
// 设置勾选状态
cbHide.setOnCheckedChangeListener(null); // 先移除监听器避免触发
cbHide.setChecked(item.isHidden);
// 显示状态
if (item.isFixed) {
tvSoStatus.setText("必需项 - 始终隐藏");
tvSoStatus.setTextColor(itemView.getContext().getResources()
.getColor(android.R.color.holo_green_dark, null));
tvFixedBadge.setVisibility(View.VISIBLE);
cbHide.setEnabled(false);
cbHide.setChecked(true); // 固定项始终勾选
} else {
tvSoStatus.setText(item.isHidden ? "已隐藏" : "未隐藏");
tvSoStatus.setTextColor(itemView.getContext().getResources()
.getColor(android.R.color.darker_gray, null));
tvFixedBadge.setVisibility(View.GONE);
cbHide.setEnabled(true);
}
// 设置点击监听器
cbHide.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (listener != null && !item.isFixed) {
listener.onItemCheckedChanged(item, isChecked);
}
});
// 整行点击也触发勾选
itemView.setOnClickListener(v -> {
if (!item.isFixed) {
cbHide.setChecked(!cbHide.isChecked());
}
});
}
}
}

View File

@@ -0,0 +1,249 @@
package com.jiqiu.configapp;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.card.MaterialCardView;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* KPM 隐藏功能 Fragment
* 管理 KPM 内核模块和 SO 文件隐藏配置
*/
public class KpmHideFragment extends Fragment {
private static final String TAG = "KpmHideFragment";
private TextView tvModuleStatus;
private TextView tvModuleInfo;
private TextView tvConfigPath;
private Button btnReloadModule;
private RecyclerView rvSoList;
private ConfigManager configManager;
private HideSoAdapter adapter;
private ExecutorService executor;
private Handler mainHandler;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_kpm_hide, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initViews(view);
initExecutor();
initConfigManager();
setupListeners();
loadData();
}
private void initViews(View view) {
tvModuleStatus = view.findViewById(R.id.tvModuleStatus);
tvModuleInfo = view.findViewById(R.id.tvModuleInfo);
tvConfigPath = view.findViewById(R.id.tvConfigPath);
btnReloadModule = view.findViewById(R.id.btnReloadModule);
rvSoList = view.findViewById(R.id.rvSoList);
rvSoList.setLayoutManager(new LinearLayoutManager(getContext()));
}
private void initExecutor() {
executor = Executors.newSingleThreadExecutor();
mainHandler = new Handler(Looper.getMainLooper());
}
private void initConfigManager() {
configManager = new ConfigManager(getContext());
}
private void setupListeners() {
btnReloadModule.setOnClickListener(v -> reloadModule());
}
private void loadData() {
// 显示配置路径
tvConfigPath.setText("配置文件: " + ConfigManager.KPM_HIDE_CONFIG);
// 异步加载模块状态和 SO 列表
executor.execute(() -> {
try {
final boolean isLoaded = configManager.isKpmModuleLoaded();
final List<String> availableSos = configManager.getAvailableSoList();
final List<String> hiddenSos = configManager.getHiddenSoList();
mainHandler.post(() -> {
updateModuleStatus(isLoaded);
setupSoList(availableSos, hiddenSos);
});
} catch (Exception e) {
Log.e(TAG, "Error loading data", e);
mainHandler.post(() -> {
Toast.makeText(getContext(), "加载数据失败: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
});
}
});
}
private void updateModuleStatus(boolean isLoaded) {
if (isLoaded) {
tvModuleStatus.setText("● 已加载");
tvModuleStatus.setTextColor(getResources().getColor(android.R.color.holo_green_dark, null));
tvModuleInfo.setText("KPM 内核模块运行中\n模块名称: hideInject\n版本: 0.0.1");
} else {
tvModuleStatus.setText("● 未加载");
tvModuleStatus.setTextColor(getResources().getColor(android.R.color.holo_red_dark, null));
tvModuleInfo.setText("KPM 内核模块未运行\n请检查模块文件是否存在或手动重载");
}
}
private void setupSoList(List<String> availableSos, List<String> hiddenSos) {
List<HideSoItem> items = new ArrayList<>();
for (String soName : availableSos) {
HideSoItem item = new HideSoItem();
item.soName = soName;
item.isHidden = hiddenSos.contains(soName);
// libmyinjector.so 是固定隐藏的
item.isFixed = soName.equals("libmyinjector.so");
items.add(item);
}
adapter = new HideSoAdapter(items, this::onSoItemCheckedChanged);
rvSoList.setAdapter(adapter);
}
private void onSoItemCheckedChanged(HideSoItem item, boolean isChecked) {
if (item.isFixed) {
// 固定项不允许取消勾选
Toast.makeText(getContext(), "libmyinjector.so 是必需的,不能取消隐藏",
Toast.LENGTH_SHORT).show();
return;
}
// 异步更新配置
executor.execute(() -> {
try {
boolean success;
if (isChecked) {
success = configManager.addSoToHideList(item.soName);
} else {
success = configManager.removeSoFromHideList(item.soName);
}
final boolean finalSuccess = success;
mainHandler.post(() -> {
if (finalSuccess) {
item.isHidden = isChecked;
Toast.makeText(getContext(),
isChecked ? "已添加到隐藏列表" : "已从隐藏列表移除",
Toast.LENGTH_SHORT).show();
// 更新模块状态
refreshModuleStatus();
} else {
Toast.makeText(getContext(), "更新失败,请检查日志",
Toast.LENGTH_SHORT).show();
// 恢复原来的状态
if (adapter != null) {
adapter.notifyDataSetChanged();
}
}
});
} catch (Exception e) {
Log.e(TAG, "Error updating SO hide status", e);
mainHandler.post(() -> {
Toast.makeText(getContext(), "更新失败: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
if (adapter != null) {
adapter.notifyDataSetChanged();
}
});
}
});
}
private void reloadModule() {
btnReloadModule.setEnabled(false);
btnReloadModule.setText("重载中...");
executor.execute(() -> {
try {
final boolean success = configManager.reloadKpmModule();
mainHandler.post(() -> {
btnReloadModule.setEnabled(true);
btnReloadModule.setText("重载模块");
if (success) {
Toast.makeText(getContext(), "模块重载成功", Toast.LENGTH_SHORT).show();
refreshModuleStatus();
} else {
Toast.makeText(getContext(), "模块重载失败,请查看日志",
Toast.LENGTH_SHORT).show();
}
});
} catch (Exception e) {
Log.e(TAG, "Error reloading module", e);
mainHandler.post(() -> {
btnReloadModule.setEnabled(true);
btnReloadModule.setText("重载模块");
Toast.makeText(getContext(), "重载失败: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
});
}
});
}
private void refreshModuleStatus() {
executor.execute(() -> {
try {
final boolean isLoaded = configManager.isKpmModuleLoaded();
mainHandler.post(() -> updateModuleStatus(isLoaded));
} catch (Exception e) {
Log.e(TAG, "Error refreshing module status", e);
}
});
}
@Override
public void onDestroyView() {
super.onDestroyView();
if (executor != null && !executor.isShutdown()) {
executor.shutdown();
}
}
/**
* SO 隐藏项数据类
*/
public static class HideSoItem {
public String soName;
public boolean isHidden;
public boolean isFixed; // 是否是固定隐藏项(不可取消)
}
}

View File

@@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity implements SettingsFragment.
private AppListFragment appListFragment;
private SettingsFragment settingsFragment;
private SoManagerFragment soManagerFragment;
private KpmHideFragment kpmHideFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -53,6 +54,9 @@ public class MainActivity extends AppCompatActivity implements SettingsFragment.
} else if (itemId == R.id.navigation_so_manager) {
showSoManagerFragment();
return true;
} else if (itemId == R.id.navigation_kpm_hide) {
showKpmHideFragment();
return true;
} else if (itemId == R.id.navigation_settings) {
showSettingsFragment();
return true;
@@ -75,6 +79,13 @@ public class MainActivity extends AppCompatActivity implements SettingsFragment.
showFragment(soManagerFragment);
}
private void showKpmHideFragment() {
if (kpmHideFragment == null) {
kpmHideFragment = new KpmHideFragment();
}
showFragment(kpmHideFragment);
}
private void showSettingsFragment() {
if (settingsFragment == null) {
settingsFragment = new SettingsFragment();

View File

@@ -11,6 +11,8 @@ import android.widget.RadioGroup;
import android.widget.EditText;
import android.text.TextWatcher;
import android.text.Editable;
import android.widget.TextView;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -28,6 +30,8 @@ public class SettingsFragment extends Fragment {
private RadioButton radioShowAll;
private RadioButton radioHideSystem;
private EditText editInjectionDelay;
private TextView tvGlobalGadgetStatus;
private Button btnConfigureGlobalGadget;
private ConfigManager configManager;
private SharedPreferences sharedPreferences;
@@ -59,6 +63,8 @@ public class SettingsFragment extends Fragment {
radioShowAll = view.findViewById(R.id.radio_show_all);
radioHideSystem = view.findViewById(R.id.radio_hide_system);
editInjectionDelay = view.findViewById(R.id.editInjectionDelay);
tvGlobalGadgetStatus = view.findViewById(R.id.tvGlobalGadgetStatus);
btnConfigureGlobalGadget = view.findViewById(R.id.btnConfigureGlobalGadget);
configManager = new ConfigManager(getContext());
}
@@ -79,6 +85,9 @@ public class SettingsFragment extends Fragment {
// Load injection delay
int injectionDelay = configManager.getInjectionDelay();
editInjectionDelay.setText(String.valueOf(injectionDelay));
// Load global gadget status
updateGlobalGadgetStatus();
}
private void setupListeners() {
@@ -124,6 +133,11 @@ public class SettingsFragment extends Fragment {
}
}
});
// Global gadget configuration button
btnConfigureGlobalGadget.setOnClickListener(v -> {
showGlobalGadgetConfigDialog();
});
}
public void setOnSettingsChangeListener(OnSettingsChangeListener listener) {
@@ -133,4 +147,34 @@ public class SettingsFragment extends Fragment {
public boolean isHideSystemApps() {
return sharedPreferences.getBoolean(KEY_HIDE_SYSTEM_APPS, false);
}
private void updateGlobalGadgetStatus() {
ConfigManager.GadgetConfig globalGadget = configManager.getGlobalGadgetConfig();
if (globalGadget != null) {
String status = "已配置: " + globalGadget.gadgetName;
if (globalGadget.mode.equals("server")) {
status += " (Server模式, 端口: " + globalGadget.port + ")";
} else {
status += " (Script模式)";
}
tvGlobalGadgetStatus.setText(status);
} else {
tvGlobalGadgetStatus.setText("未配置");
}
}
private void showGlobalGadgetConfigDialog() {
// Use existing GadgetConfigDialog
GadgetConfigDialog dialog = new GadgetConfigDialog(
getContext(),
"全局Gadget配置",
configManager.getGlobalGadgetConfig(),
gadgetConfig -> {
// Save global gadget configuration
configManager.setGlobalGadgetConfig(gadgetConfig);
updateGlobalGadgetStatus();
}
);
dialog.show();
}
}

View File

@@ -88,35 +88,67 @@
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp" />
<LinearLayout
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gadget 配置"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:layout_marginBottom="8dp" />
<RadioGroup
android:id="@+id/gadgetConfigGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:orientation="vertical"
android:layout_marginBottom="8dp">
<CheckBox
android:id="@+id/checkboxEnableGadget"
<RadioButton
android:id="@+id/radioNoGadget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="不使用Gadget"
android:checked="true" />
<RadioButton
android:id="@+id/radioUseGlobalGadget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="使用全局Gadget配置" />
<TextView
android:id="@+id/tvGlobalGadgetInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="启用 Gadget 配置"
android:layout_marginEnd="8dp" />
android:layout_marginStart="32dp"
android:layout_marginBottom="4dp"
android:text="未配置全局Gadget"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnConfigureGadget"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:text="配置"
android:textSize="12sp"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:enabled="false" />
<RadioButton
android:id="@+id/radioUseCustomGadget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="自定义Gadget配置" />
</LinearLayout>
</RadioGroup>
<com.google.android.material.button.MaterialButton
android:id="@+id/btnConfigureGadget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="配置Gadget"
android:textSize="14sp"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:enabled="false"
android:visibility="gone"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Gadget可用于Frida调试勾选后可配置监听地址和端口"
android:text="Gadget可用于Frida调试可配置监听地址和端口"
android:textSize="12sp"
android:textColor="?android:attr/textColorSecondary"
android:layout_marginBottom="16dp" />

View File

@@ -0,0 +1,202 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".KpmHideFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- 标题 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="KPM 注入隐藏"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginBottom="16dp" />
<!-- KPM 模块状态卡片 -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="模块状态"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<TextView
android:id="@+id/tvModuleStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="● 检查中..."
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<TextView
android:id="@+id/tvModuleInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="正在检查模块状态..."
android:textSize="12sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="12dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnReloadModule"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="重载模块"
style="@style/Widget.MaterialComponents.Button.OutlinedButton" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- 配置说明卡片 -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
app:cardElevation="2dp"
app:cardBackgroundColor="#FFF3E0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" 使用说明"
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="• KPM 内核模块可以隐藏进程的内存映射信息\n• libmyinjector.so 将自动隐藏(不可取消)\n• 勾选其他 SO 文件可隐藏其在 /proc/[pid]/maps 中的显示\n• 每次更改都会自动重载内核模块以应用配置"
android:textSize="12sp"
android:lineSpacingExtra="4dp"
android:textColor="#E65100"
android:layout_marginBottom="8dp" />
<TextView
android:id="@+id/tvConfigPath"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="配置文件: /data/local/tmp/kpm_hide_config.txt"
android:textSize="10sp"
android:textColor="@android:color/darker_gray"
android:fontFamily="monospace" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- 固定隐藏项说明 -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="🔒 固定隐藏项"
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="以下库文件将始终被隐藏:"
android:textSize="12sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="4dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="• libmyinjector.so (Zygisk 注入器)"
android:textSize="12sp"
android:fontFamily="monospace"
android:textColor="@android:color/holo_green_dark" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- SO 隐藏列表 -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="可选隐藏 SO 列表"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="从已配置的应用中选择需要隐藏的 SO 文件"
android:textSize="12sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="12dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvSoList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="100dp"
tools:listitem="@layout/item_hide_so" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</ScrollView>

View File

@@ -143,6 +143,53 @@
</com.google.android.material.card.MaterialCardView>
<!-- 全局Gadget配置 -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="全局Gadget配置"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="配置全局默认的Gadget设置应用可以选择使用或覆盖"
android:textSize="14sp"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="12dp" />
<TextView
android:id="@+id/tvGlobalGadgetStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="未配置"
android:textSize="14sp"
android:layout_marginBottom="8dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnConfigureGlobalGadget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="配置全局Gadget"
style="@style/Widget.MaterialComponents.Button.OutlinedButton" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- 其他设置可以在这里添加 -->
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="12dp"
android:gravity="center_vertical"
android:background="?attr/selectableItemBackground">
<CheckBox
android:id="@+id/cbHide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tvSoName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="libexample.so"
android:textSize="14sp"
android:textStyle="bold"
android:fontFamily="monospace" />
<TextView
android:id="@+id/tvSoStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="未隐藏"
android:textSize="12sp"
android:textColor="@android:color/darker_gray"
android:layout_marginTop="2dp" />
</LinearLayout>
<TextView
android:id="@+id/tvFixedBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="固定"
android:textSize="10sp"
android:textColor="@android:color/white"
android:background="@android:color/holo_green_dark"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:layout_marginStart="8dp"
android:visibility="gone" />
</LinearLayout>

View File

@@ -9,6 +9,11 @@
android:id="@+id/navigation_so_manager"
android:icon="@android:drawable/ic_menu_save"
android:title="@string/title_so_manager" />
<item
android:id="@+id/navigation_kpm_hide"
android:icon="@android:drawable/ic_secure"
android:title="@string/title_kpm_hide" />
<item
android:id="@+id/navigation_settings"

View File

@@ -4,6 +4,7 @@
<!-- 底部导航 -->
<string name="title_apps">应用列表</string>
<string name="title_so_manager">SO库管理</string>
<string name="title_kpm_hide">KPM隐藏</string>
<string name="title_settings">全局设置</string>
<!-- 应用列表 -->
@@ -21,4 +22,25 @@
<!-- 关于 -->
<string name="about">关于</string>
<string name="app_description">MyInjector 配置应用,用于管理注入设置</string>
<!-- KPM 隐藏 -->
<string name="kpm_hide_title">KPM 注入隐藏</string>
<string name="kpm_module_status">模块状态</string>
<string name="kpm_module_loaded">已加载</string>
<string name="kpm_module_not_loaded">未加载</string>
<string name="kpm_module_info">KPM 内核模块信息</string>
<string name="kpm_reload_module">重载模块</string>
<string name="kpm_reload_success">模块重载成功</string>
<string name="kpm_reload_failed">模块重载失败</string>
<string name="kpm_config_path">配置文件路径</string>
<string name="kpm_fixed_items">固定隐藏项</string>
<string name="kpm_optional_items">可选隐藏 SO 列表</string>
<string name="kpm_usage_info">使用说明</string>
<string name="kpm_fixed_badge">固定</string>
<string name="kpm_hidden">已隐藏</string>
<string name="kpm_not_hidden">未隐藏</string>
<string name="kpm_add_success">已添加到隐藏列表</string>
<string name="kpm_remove_success">已从隐藏列表移除</string>
<string name="kpm_update_failed">更新失败</string>
<string name="kpm_fixed_cannot_uncheck">libmyinjector.so 是必需的,不能取消隐藏</string>
</resources>

View File

@@ -70,6 +70,10 @@ afterEvaluate {
from("$projectDir") {
include 'service.sh'
}
// Copy KPM module
from("$projectDir/kpm") {
include 'injectHide.kpm'
}
// Copy ConfigApp APK if it exists
def apkFile = file("$rootDir/configapp/build/outputs/apk/debug/configapp-debug.apk")
if (apkFile.exists()) {

BIN
module/kpm/injectHide.kpm Normal file

Binary file not shown.

View File

@@ -94,5 +94,46 @@ chown -R root:root /data/adb/modules/zygisk-myinjector
log "ConfigApp 安装脚本执行完成"
# ==================== KPM 模块加载 ====================
# KPM 模块路径
KPM_MODULE="$MODDIR/injectHide.kpm"
KPM_CONFIG="/data/local/tmp/kpm_hide_config.txt"
log "开始加载 KPM 内核模块"
# 检查 KPM 模块文件是否存在
if [ ! -f "$KPM_MODULE" ]; then
log "KPM 模块文件不存在: $KPM_MODULE"
else
log "找到 KPM 模块文件: $KPM_MODULE"
# 创建初始配置文件(如果不存在)
if [ ! -f "$KPM_CONFIG" ]; then
log "创建初始 KPM 配置文件"
# 确保 /data/local/tmp 目录存在且权限正确
mkdir -p /data/local/tmp
chmod 777 /data/local/tmp
echo "libmyinjector.so" > "$KPM_CONFIG"
chmod 666 "$KPM_CONFIG"
fi
# 等待一段时间确保系统稳定
sleep 3
# 加载 KPM 模块
log "正在加载 KPM 模块..."
insmod "$KPM_MODULE" 2>&1 | while read line; do
log "insmod: $line"
done
# 检查模块是否加载成功
if lsmod | grep -q "hideInject"; then
log "KPM 模块加载成功!"
else
log "KPM 模块加载失败,请检查日志"
fi
fi
# 脚本完成
exit 0

View File

@@ -1,10 +0,0 @@
//
// Created by Perfare on 2020/7/4.
//
#ifndef ZYGISK_IL2CPPDUMPER_GAME_H
#define ZYGISK_IL2CPPDUMPER_GAME_H
#define AimPackageName "com.tencent.mobileqq"
#endif //ZYGISK_IL2CPPDUMPER_GAME_H

View File

@@ -1,284 +0,0 @@
//
// Created by Perfare on 2020/7/4.
//
#include "hack.h"
#include "log.h"
#include "xdl.h"
#include <cstring>
#include <cstdio>
#include <unistd.h>
#include <sys/system_properties.h>
#include <dlfcn.h>
#include <jni.h>
#include <thread>
#include <sys/mman.h>
#include <linux/unistd.h>
#include <array>
#include <sys/stat.h>
//#include <asm-generic/fcntl.h>
#include <fcntl.h>
#include "newriruhide.h"
void load_so(const char *game_data_dir, JavaVM *vm, const char *soname) {
bool load = false;
LOGI("hack_start %s", game_data_dir);
// 构建新文件路径,使用传入的 soname 参数
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);
if (src_fd < 0) {
LOGE("Failed to open %s: %s (errno: %d)", src_path, strerror(errno), errno);
return;
}
// 打开目标文件
int dest_fd = open(new_so_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (dest_fd < 0) {
LOGE("Failed to open %s", new_so_path);
close(src_fd);
return;
}
// 复制文件内容
char buffer[4096];
ssize_t bytes;
while ((bytes = read(src_fd, buffer, sizeof(buffer))) > 0) {
if (write(dest_fd, buffer, bytes) != bytes) {
LOGE("Failed to write to %s", new_so_path);
close(src_fd);
close(dest_fd);
return;
}
}
// 关闭文件描述符
close(src_fd);
close(dest_fd);
// 修改文件权限
if (chmod(new_so_path, 0755) != 0) {
LOGE("Failed to change permissions on %s: %s (errno: %d)", new_so_path, strerror(errno), errno);
return;
} else {
LOGI("Successfully changed permissions to 755 on %s", new_so_path);
}
// 加载 .so 文件
void *handle;
for (int i = 0; i < 10; i++) {
handle = dlopen(new_so_path, RTLD_NOW | RTLD_LOCAL);
if (handle) {
LOGI("Successfully loaded %s", new_so_path);
load = true;
char new_soname[256];
sprintf(new_soname, "%s.so", soname);
riru_hide(new_soname);
break;
} else {
LOGE("Failed to load %s: %s", new_so_path, dlerror());
sleep(1);
}
}
// 如果加载失败
if (!load) {
LOGI("%s.so not found in thread %d", soname, gettid());
}
// 查找 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) {
JNIEnv *env = nullptr;
vms->AttachCurrentThread(&env, nullptr);
jclass activity_thread_clz = env->FindClass("android/app/ActivityThread");
if (activity_thread_clz != nullptr) {
jmethodID currentApplicationId = env->GetStaticMethodID(activity_thread_clz,
"currentApplication",
"()Landroid/app/Application;");
if (currentApplicationId) {
jobject application = env->CallStaticObjectMethod(activity_thread_clz,
currentApplicationId);
jclass application_clazz = env->GetObjectClass(application);
if (application_clazz) {
jmethodID get_application_info = env->GetMethodID(application_clazz,
"getApplicationInfo",
"()Landroid/content/pm/ApplicationInfo;");
if (get_application_info) {
jobject application_info = env->CallObjectMethod(application,
get_application_info);
jfieldID native_library_dir_id = env->GetFieldID(
env->GetObjectClass(application_info), "nativeLibraryDir",
"Ljava/lang/String;");
if (native_library_dir_id) {
auto native_library_dir_jstring = (jstring) env->GetObjectField(
application_info, native_library_dir_id);
auto path = env->GetStringUTFChars(native_library_dir_jstring, nullptr);
LOGI("lib dir %s", path);
std::string lib_dir(path);
env->ReleaseStringUTFChars(native_library_dir_jstring, path);
return lib_dir;
} else {
LOGE("nativeLibraryDir not found");
}
} else {
LOGE("getApplicationInfo not found");
}
} else {
LOGE("application class not found");
}
} else {
LOGE("currentApplication not found");
}
} else {
LOGE("ActivityThread not found");
}
return {};
}
static std::string GetNativeBridgeLibrary() {
auto value = std::array<char, PROP_VALUE_MAX>();
__system_property_get("ro.dalvik.vm.native.bridge", value.data());
return {value.data()};
}
struct NativeBridgeCallbacks {
uint32_t version;
void *initialize;
void *(*loadLibrary)(const char *libpath, int flag);
void *(*getTrampoline)(void *handle, const char *name, const char *shorty, uint32_t len);
void *isSupported;
void *getAppEnv;
void *isCompatibleWith;
void *getSignalHandler;
void *unloadLibrary;
void *getError;
void *isPathSupported;
void *initAnonymousNamespace;
void *createNamespace;
void *linkNamespaces;
void *(*loadLibraryExt)(const char *libpath, int flag, void *ns);
};
bool NativeBridgeLoad(const char *game_data_dir, int api_level, void *data, size_t length) {
//TODO 等待houdini初始化
sleep(5);
auto libart = dlopen("libart.so", RTLD_NOW);
auto JNI_GetCreatedJavaVMs = (jint (*)(JavaVM **, jsize, jsize *)) dlsym(libart,
"JNI_GetCreatedJavaVMs");
LOGI("JNI_GetCreatedJavaVMs %p", JNI_GetCreatedJavaVMs);
JavaVM *vms_buf[1];
JavaVM *vms;
jsize num_vms;
jint status = JNI_GetCreatedJavaVMs(vms_buf, 1, &num_vms);
if (status == JNI_OK && num_vms > 0) {
vms = vms_buf[0];
} else {
LOGE("GetCreatedJavaVMs error");
return false;
}
auto lib_dir = GetLibDir(vms);
if (lib_dir.empty()) {
LOGE("GetLibDir error");
return false;
}
if (lib_dir.find("/lib/x86") != std::string::npos) {
LOGI("no need NativeBridge");
munmap(data, length);
return false;
}
auto nb = dlopen("libhoudini.so", RTLD_NOW);
if (!nb) {
auto native_bridge = GetNativeBridgeLibrary();
LOGI("native bridge: %s", native_bridge.data());
nb = dlopen(native_bridge.data(), RTLD_NOW);
}
if (nb) {
LOGI("nb %p", nb);
auto callbacks = (NativeBridgeCallbacks *) dlsym(nb, "NativeBridgeItf");
if (callbacks) {
LOGI("NativeBridgeLoadLibrary %p", callbacks->loadLibrary);
LOGI("NativeBridgeLoadLibraryExt %p", callbacks->loadLibraryExt);
LOGI("NativeBridgeGetTrampoline %p", callbacks->getTrampoline);
int fd = syscall(__NR_memfd_create, "anon", MFD_CLOEXEC);
ftruncate(fd, (off_t) length);
void *mem = mmap(nullptr, length, PROT_WRITE, MAP_SHARED, fd, 0);
memcpy(mem, data, length);
munmap(mem, length);
munmap(data, length);
char path[PATH_MAX];
snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd);
LOGI("arm path %s", path);
void *arm_handle;
if (api_level >= 26) {
arm_handle = callbacks->loadLibraryExt(path, RTLD_NOW, (void *) 3);
} else {
arm_handle = callbacks->loadLibrary(path, RTLD_NOW);
}
if (arm_handle) {
LOGI("arm handle %p", arm_handle);
auto init = (void (*)(JavaVM *, void *)) callbacks->getTrampoline(arm_handle,
"JNI_OnLoad",
nullptr, 0);
LOGI("JNI_OnLoad %p", init);
init(vms, (void *) game_data_dir);
return true;
}
close(fd);
}
}
return false;
}
void hack_prepare(const char *_data_dir, void *data, size_t length) {
LOGI("hack thread: %d", gettid());
int api_level = android_get_device_api_level();
LOGI("api level: %d", api_level);
#if defined(__i386__) || defined(__x86_64__)
if (!NativeBridgeLoad(_data_dir, api_level, data, length)) {
#endif
hack_start(_data_dir, nullptr);
#if defined(__i386__) || defined(__x86_64__)
}
#endif
}
#if defined(__arm__) || defined(__aarch64__)
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
auto game_data_dir = (const char *) reserved;
std::thread hack_thread(hack_start, game_data_dir,vm);
hack_thread.detach();
return JNI_VERSION_1_6;
}
#endif

View File

@@ -88,12 +88,8 @@ void load_so_file_custom_linker(const char *game_data_dir, const Config::SoFile
void hack_thread_func(const char *game_data_dir, const char *package_name, JavaVM *vm) {
LOGI("Hack thread started for package: %s", package_name);
// Get injection delay from config
int delay = Config::getInjectionDelay();
LOGI("Waiting %d seconds before injection", delay);
// Wait for app to initialize and files to be copied
sleep(delay);
// Note: Delay is now handled in main thread before this thread is created
LOGI("Starting injection immediately (delay already applied in main thread)");
// Get injection method for this app
Config::InjectionMethod method = Config::getAppInjectionMethod(package_name);
@@ -135,5 +131,5 @@ void hack_prepare(const char *game_data_dir, const char *package_name, void *dat
LOGI("hack_prepare called for package: %s, dir: %s", package_name, game_data_dir);
std::thread hack_thread(hack_thread_func, game_data_dir, package_name, vm);
hack_thread.detach();
hack_thread.join();
}

View File

@@ -11,7 +11,6 @@
#include <time.h>
#include "hack.h"
#include "zygisk.hpp"
#include "game.h"
#include "log.h"
#include "dlfcn.h"
#include "config.h"
@@ -30,9 +29,6 @@ public:
void preAppSpecialize(AppSpecializeArgs *args) override {
auto package_name = env->GetStringUTFChars(args->nice_name, nullptr);
auto app_data_dir = env->GetStringUTFChars(args->app_data_dir, nullptr);
// 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);
@@ -45,6 +41,13 @@ public:
// Get JavaVM
JavaVM *vm = nullptr;
if (env->GetJavaVM(&vm) == JNI_OK) {
// Get injection delay from config
int delay = Config::getInjectionDelay();
LOGI("Main thread blocking for %d seconds before injection", delay);
// Block main thread for the delay period
sleep(delay);
// Then start hack thread with JavaVM
std::thread hack_thread(hack_prepare, _data_dir, _package_name, data, length, vm);
hack_thread.detach();

View File

@@ -17,8 +17,8 @@ set(SOURCES
find_library(log-lib log)
# Build as shared library
add_library(mylinker SHARED ${SOURCES})
# Build as static library to be linked into main module
add_library(mylinker STATIC ${SOURCES})
target_link_libraries(mylinker ${log-lib})