前言
若有任何侵权等行为,可私信作者。
参考文章:www.freebuf.com/articles/se…
这篇参考文章目前是暂停在了最后的一个检测的so,我续着把后边的检测给过掉了。
参考讲解
一般so检测的手段都会开一个或多个的额外线程,所以过检测的第一步就可以看下是谁创建了额外线程使 frida 进程崩溃掉的。
确认之后将这个线程给阻止掉。
js代码参考文章链接当中都有给出,这里不再附重复的部分。
libsotweak.so检测
在过掉exec的检测后,发现最后是停在了libsotweak.so这里。
讲解下思路,这个so是不存在于app包里边的,所以大概率是动态加载的,直接hook所有so的pthread_create线程创建调用,看下它是否有创建检测线程:
function setupPthreadHook() {
const pthread_create_addr = Module.findExportByName(null, 'pthread_create');
Interceptor.replace(pthread_create_addr, new NativeCallback(
function(parg0, parg1, parg2, parg3) {
// parg2 是线程函数指针
const module = Process.findModuleByAddress(parg2) || {name: "unknown", base: 0};
const offset = ptr(parg2).sub(module.base);
console.log("pthread_create:", module.name, "offset:", offset);
// 调用原始 pthread_create
return pthread_create(parg0, parg1, parg2, parg3);
}, "int", ["pointer", "pointer", "pointer", "pointer"]));
}
注入后输出信息:
pthread_create: libexec.so offset: 0x45f44 ← 可疑!libsotweak.so加载后立即创建
pthread_create: libexec.so offset: 0x469e8 ← 可疑!
pthread_create: libexec.so offset: 0x497c4 ← 可疑!
pthread_create: libexec.so offset: 0x49e8c ← 可疑!
Process terminated ← 进程被杀
接下来阻断这几个线程即可成功attach住,详细代码可加星球获取,链接在最下方。
dump出dex文件
成功attach住之后,将此段代码注入,随后调用dumpDex方法,操作下app
function dumpDex() {
console.log("\n[+] Starting DEX dump...");
const dexMagic = "6465780a30333500";
const outputDir = "/data/data/com.***.***/"; // 改为应用自己的目录
Process.enumerateRanges('r--').forEach(function(range) {
try {
Memory.scan(range.base, range.size, dexMagic, {
onMatch: function(address, size) {
console.log("[*] Found DEX magic at:", address);
try {
const dexSize = address.add(0x20).readU32();
console.log("[*] DEX size:", dexSize, "bytes");
if (dexSize > 0 && dexSize < 100 * 1024 * 1024) {
const dexData = address.readByteArray(dexSize);
const fileName = "classes_" + address.toString().replace("0x", "") + ".dex";
// 使用应用目录
const file = new File(outputDir + fileName, "wb");
file.write(dexData);
file.close();
console.log("[+] Dumped:", fileName);
}
} catch (e) {
console.log("[-] Error dumping DEX:", e);
}
},
onComplete: function() {}
});
} catch (e) {}
});
console.log("[+] DEX dump completed!");
console.log("[*] Pull files: adb pull /data/data/com.***.***/classes_*.dex");
}
看到此类信息即dump成功,到app目录里边(/data/data/com.** **. ***)可以看到最后的dex文件。
[MI 8::com.***.*** ]-> [*] Found DEX magic at: 0x90000
[*] DEX size: 1991792 bytes
[+] Dumped: classes_76f2.dex
[*] Found DEX magic at: 0x729800
[*] DEX size: 13664 bytes
[+] Dumped: classes_76f1.dex
[*] Found DEX magic at: 0x76f0
[*] DEX size: 5263392 bytes
[+] Dumped: classes_7600.dex
[*] Found DEX magic at: 0x76d000
[*] DEX size: 4124928 bytes
[+] Dumped: classes_760.dex
[*] Found DEX magic at: 0x76f000
[*] DEX size: 4007572 bytes
[+] Dumped: classes_76f00.dex
[*] Found DEX magic at: 0x700
[*] DEX size: 4454040 bytes
[+] Dumped: classes_76f30.dex
[*] Found DEX magic at: 0x7600
[*] DEX size: 10898288 bytes
[+] Dumped: classes_76f00.dex
流程梳理
graph TD
A[发现问题:Frida注入后进程被杀] --> B[Hook dlopen监控库加载]
B --> C[发现 libexec.so + libsotweak.so]
C --> D[Hook pthread_create监控线程创建]
D --> E[发现4个可疑线程: 0x45f44等]
E --> F[IDA分析失败:显示为数据段]
F --> G[运行时内存dump:确认是代码]
G --> H[逐个测试阻止线程创建]
H --> I[成功:阻止4个线程后绕过检测]
此外
进阶内容可加入我的知识星球查看
适合有一定逆向 / 爬虫经验的 coder。 小白也可,但需要耐心以及肯下功夫。
所有文章内容以「可复刻」为标准: 跟着走,能自己跑通; 跑通后,能总结成自己的方法论。
涵盖: 某里 v2 验证流程、v2拼图轨迹,pay拼图 sign 纯算、轨迹转化 AST 插件、训练数据集 某里 231递归字符串解密、东航 req / res 加解密 某音评论ab纯算等等
未来会加入app逆向资源,从如何以及为何root一部手机说起,到如何分析汇编…