Files
iOSGuard/defender/anti_hook/IGAntiHook.h
shenlei 704ee66834 feat: 集成 LLVM IR 混淆体系、Route 2 全量合规与系统调用调度加固
- defender: 扩展 IGDispatch/IGArchiveGuard/IGAntiHook/IGObjCBaseline/IGResolve,支持 Route 2 静态库桥接 (IGThreadID.c) 与防重签名检测
- llvm_passes: 新增 IGObfuscator LLVM IR 插件源码(控制流平坦化、字符串加密、间接跳转/调用、不透明常量/字段、MBA、函数外提、基本块拆分、反 Hook 序言)
- tools & config: 新增 Xcode 归档编译/链接包装器、LLVM 自愈工具链 (ig_toolchain_resolver)、IPA 审计门禁、崩溃符号还原及最新 ig_llvm_policy.json(文件级匹配 + 3.0 全业务 Handler 平坦化)
- tests & docs: 补齐 M0~M3、Pass 单测及系统调用调度/Route 2/LLVM 方案文档;.gitignore 忽略 *.bc 与 .obfuscate_extraction_cache.json
2026-11-24 15:00:07 +09:00

50 lines
2.1 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* IGAntiHook.h — 关键函数 HOOK 完整性探针。
*
* 覆盖三类 HOOK 形态(docs/05 §5.C「GOT/符号地址」「关键自有代码完整性」):
* 1. 符号提供方异常:dlsym 解析到非系统镜像(dyld interpose / 注入 dylib 抢占定义)。
* 2. inline hook:关键函数序言首指令被改写为无条件跳转或 LDR+BR x16 蹦床。
* 3. GOT 重绑定:本进程镜像的 __got/__la_symbol_ptr 槽被 fishhook 类手法改指到非系统地址。
*
* 只采集证据,不处置。PAC/chained-fixups/arm64e 的边界见 .c 注释。
*/
#ifndef IG_ANTI_HOOK_H
#define IG_ANTI_HOOK_H
#include "IGDefender.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* 校验一批关键 libc/系统函数的运行时完整性。
* names: 函数名数组(不带前导下划线,如 "write"/"read"/"dlsym")。
* count: 数组长度。
* 对每个符号依次做 provenance / inline-hook / GOT-rebind 检查,命中即经 sink 上报。
* 返回 DETECTED 条数(0 表示本轮全部 clear 或仅 unavailable)。
*/
int ig_anti_hook_check(const char *const *names, size_t count,
IGFindingSink sink, void *ctx);
/* 便捷入口:用内置关键符号集(底层 I/O + 密码学/Keychain + ObjC runtime)执行校验。 */
int ig_anti_hook_check_default(IGFindingSink sink, void *ctx);
/*
* 单点「调用前校验」:对一个**已解析**的函数地址做 provenance(dladdr 提供方须系统路径)
* + inline-hook 序言/前 32 字节基线检查。供 IGResolve 在放行解析结果前复用。
* 命中经 sink 上报(可传 NULL 只取返回值)。
* 返回 IG_CLEAR=干净可用 / IG_DETECTED=疑被挟持应拒用 / IG_UNAVAILABLE=addr 为空无法判定。
*/
IGStatus ig_verify_function(void *addr, const char *name, IGFindingSink sink, void *ctx);
/* ARM64 序言与 32 字节指令窗形态分类,可独立测试;命中只是一条证据,不覆盖所有 Hook。 */
int ig_arm64_suspicious_prologue(uint32_t first, uint32_t second);
int ig_arm64_suspicious_window(const uint32_t *ins, size_t count);
#ifdef __cplusplus
}
#endif
#endif /* IG_ANTI_HOOK_H */