|
|
本帖最后由 hehua 于 2026-2-8 17:36 编辑
1. Java代码分析:
- com.hardening.stub.SoLoader$Config - 负责SO库加载配置
- com.hardening.stub.RuntimeProtector - 运行时保护
- com.hardening.stub.SecurityChecker - 安全检查器
1) SO文件被加密存储在其他位置
2) 使用了自定义的SO加载机制
3) 运行时动态解密SO文件
2. 针对SO加密的Java实现分析:
```java
// SoLoader$Config 类的可能实现
public class SoLoader {
public static class Config {
private String encryptedSoPath; // 加密SO存放路径
private String decryptedSoDir; // 解密后存放目录
private String key; // 解密密钥
public Config(String encryptedPath, String decryptedDir, String key) {
this.encryptedSoPath = encryptedPath;
this.decryptedSoDir = decryptedDir;
this.key = key;
}
public String getDecryptedSoPath(String soName) {
return decryptedSoDir + File.separator + soName;
}
}
public static void loadLibrary(Context context, String libName, Config config) {
// 1. 检查解密目录是否存在
File decryptedDir = new File(config.decryptedSoDir);
if (!decryptedDir.exists()) {
decryptedDir.mkdirs();
}
// 2. 检查是否已解密
String decryptedPath = config.getDecryptedSoPath(libName);
File decryptedFile = new File(decryptedPath);
if (!decryptedFile.exists()) {
// 3. 从assets或指定路径读取加密SO
byte[] encryptedData = readEncryptedSo(context, libName, config);
// 4. 解密SO数据
byte[] decryptedData = decryptSo(encryptedData, config.key);
// 5. 写入解密文件
writeDecryptedSo(decryptedPath, decryptedData);
}
// 6. 加载解密后的SO
System.load(decryptedPath);
}
private static byte[] readEncryptedSo(Context context, String libName, Config config) {
// 实现从assets或指定路径读取加密SO的逻辑
}
private static byte[] decryptSo(byte[] encryptedData, String key) {
// 实现解密逻辑,可能是AES等对称加密
}
private static void writeDecryptedSo(String path, byte[] data) {
// 实现写入解密文件逻辑
}
}
```
3. 针对选中类的特定分析:
- RuntimeProtector 类可能负责:
- 反调试检测
- 完整性校验
- 环境安全检查
典型实现可能包含:
```java
public class RuntimeProtector {
public static void checkEnvironment() {
// 检查root、调试状态等
if (isRooted() || isDebugging()) {
exitProcess();
}
}
private static boolean isRooted() {
// 检查root标志
}
private static boolean isDebugging() {
// 检查调试状态
}
private static void exitProcess() {
System.exit(1);
}
}
```
3) 使用示例:
```java
// 初始化配置
SoLoader.Config config = new SoLoader.Config(
"encrypted_libs",
context.getFilesDir() + "/decrypted_libs",
"dynamic_key_part1" + getKeyPart2()
);
// 加载加密的SO库
SoLoader.loadLibrary(context, "native-lib", config);
```
5. 补充说明:
如果找不到llb目录或so文件,可能是因为:
1) SO文件被加密存储在assets或自定义位置
2) 使用了动态加载技术,运行时才解密释放
3) 路径被混淆或动态生成
可能分析
- assets目录下的加密文件
- 应用的data目录下的临时文件
- 运行时动态生成 |
|