fix(defender): ObjC 方法基线改用构建期签名清单,修复误报 110 导致的延迟闪退
- 构建期生成随包签名的 IGMethods.bin(仅主程序),运行时按镜像 UUID、 入口偏移与函数边界内指令摘要校验;导出审计复核清单与最终镜像一致 - 系统函数、调度与解包保护的代码前缀按 LC_FUNCTION_STARTS 限定在函数边界内 - 边界内识别 B / LDR+BR / ADRP+ADD+BR / MOVK+BR 蹦床并确认目标归属,避免系统尾调用误报 - 登记前 IMP 已落入匿名内存判为改写;清单读取改走 IG_dispatch_open - 函数边界长度按入口缓存;镜像未重新链接时复用基线;Debug 附加调试器时不按入口摘要判定改写 - 补充宿主测试;删除已过时的 README 与 docs 历史文档,保留 THIRD_PARTY_NOTICES
This commit is contained in:
Vendored
+26
-1
@@ -190,7 +190,7 @@ int main(int argc,char **argv) {
|
||||
assert(ig_verify_function((void *)1,"invalid",collect,NULL)==IG_UNAVAILABLE);
|
||||
assert(reasons[IG_REASON_VERIFICATION_UNAVAILABLE]==1);
|
||||
} else if (!strcmp(argv[1],"prologue")) {
|
||||
assert(ig_arm64_suspicious_prologue(0x14000001,0));
|
||||
assert(!ig_arm64_suspicious_prologue(0x14000001,0));
|
||||
assert(ig_arm64_suspicious_prologue(0x58000050,0xd61f0200));
|
||||
assert(ig_arm64_suspicious_prologue(0x58000049,0xd61f0120)); /* ldr x9; br x9 */
|
||||
assert(!ig_arm64_suspicious_prologue(0x58000050,0xd61f0220));
|
||||
@@ -216,6 +216,31 @@ int main(int argc,char **argv) {
|
||||
0xd61f0200u, 0xd503201fu, 0xd503201fu, 0xd503201fu
|
||||
};
|
||||
assert(ig_arm64_suspicious_window(mid_ldr_win, 8));
|
||||
#if defined(__arm64__) || defined(__aarch64__)
|
||||
void *sys_getpid = dlsym(RTLD_DEFAULT, "getpid");
|
||||
void *sys_ftell = dlsym(RTLD_DEFAULT, "ftell");
|
||||
assert(sys_getpid != NULL && sys_ftell != NULL);
|
||||
const uint32_t local_b[1] = {0x14000000u};
|
||||
assert(ig_arm64_trampoline_to_foreign(local_b, local_b, 1));
|
||||
assert(ig_verify_function(sys_ftell, "ftell", collect, NULL) == IG_CLEAR);
|
||||
struct { uint32_t ins[2]; uint64_t dst; } __attribute__((aligned(8))) ldr_tramp = {
|
||||
{0x58000050u, 0xd61f0200u}, (uint64_t)(uintptr_t)collect
|
||||
};
|
||||
assert(ig_arm64_trampoline_to_foreign(ldr_tramp.ins, ldr_tramp.ins, 2));
|
||||
ldr_tramp.dst = (uint64_t)(uintptr_t)sys_getpid;
|
||||
assert(!ig_arm64_trampoline_to_foreign(ldr_tramp.ins, ldr_tramp.ins, 2));
|
||||
uintptr_t foreign_dst = (uintptr_t)collect;
|
||||
uint32_t adrp_foreign[3];
|
||||
intptr_t page_delta = ((intptr_t)(foreign_dst & ~(uintptr_t)0xfffu) -
|
||||
(intptr_t)((uintptr_t)adrp_foreign & ~(uintptr_t)0xfffu)) >> 12;
|
||||
uint32_t imm21 = (uint32_t)page_delta & 0x1fffffu;
|
||||
adrp_foreign[0] = 0x90000010u | ((imm21 & 3u) << 29) | ((imm21 >> 2) << 5);
|
||||
adrp_foreign[1] = 0x91000210u | ((uint32_t)(foreign_dst & 0xfffu) << 10);
|
||||
adrp_foreign[2] = 0xd61f0200u;
|
||||
assert(ig_arm64_trampoline_to_foreign(adrp_foreign, adrp_foreign, 3));
|
||||
assert(ig_arm64_trampoline_to_foreign(movk_win, movk_win, 8));
|
||||
assert(!ig_arm64_trampoline_to_foreign(clean_win, clean_win, 8));
|
||||
#endif
|
||||
} else return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user