Files
iOSGuard/defender/include/IGVisibility.h
T
shenleiandClaude Opus 4.8 b76d7cdc21 harden(defender): docs/18 §7 抗静态分析硬化(符号隐藏/串混淆/副本分散/基线派生)
针对「纯客户端抗静态分析」的最高性价比项落地,守在 tests/test_static_hardening.py(6 条,gate 于 iphoneos SDK):

- 符号隐藏 + strip(§7.0 新增):IGVisibility.h 定 IG_INTERNAL=hidden,全库
  -fvisibility=hidden;仅四入口 ig_defender_scan/ig_poison_init/ig_poison_apply/
  ig_policy_scan_and_mark 标 IG_PUBLIC 保持导出,其余 ig_* 变 private external,
  链接后 strip -x 彻底消失——攻击者 nm 不再能按名定位 ig_poison_mark/mask 去 NOP。
- §7.1 串混淆:gen_jb_paths.py(唯一真源)生成 IGJailbreakPaths.inc /
  IGInjectSignatures.inc(XOR keystream,两表不共享 key),运行期解码进栈、用完擦除;
  decode 内 volatile key 屏障阻止 -O2 把常量折叠回 __const 明文。strings 已捞不到
  /var/jb、Cydia、substrate、gum-js-loop 等。--check 守 .inc 与清单同步。
- §7.2 副本分散:g_h0/h1/h2 置于不相邻命名段 __DATA,__ig_p0/p1/p2,加 __ig_pd 诱饵
  (mask 不读);刻意不用 TLS(会破坏跨线程毒化一致性)。
- §7.4 基线派生:删硬编码 0xA5C3F10E7B2D4968,改 ig_poison_baseline() 由拆分种子经
  volatile 屏障派生;otool -tV 已无旧魔数立即数。
- §7.3 OLLVM/VMP:仅留 build 的 IG_OBFUSCATOR hook,stock clang 无能力,需另备工具链(未完成)。
- §7.5 越狱设备正向验证仍阻塞(无设备)。

构建/快照同步:build_defender_lib.sh 加 -fvisibility=hidden + gen --check + IG_OBFUSCATOR
hook;build_poison_device.py 快照纳入 *.inc。全量 69 测试通过;poison_device.m 全模块
iphoneos 交叉编译通过(arm64)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-13 10:47:35 +09:00

34 lines
1.7 KiB
C
Raw 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.
/*
* IGVisibility.h — 符号可见性控制(抗静态调用关系分析,§7 硬化)。
*
* 背景:静态库 .a 里所有全局函数默认都是导出符号(nm 显示 T),接入方链进 App 后,
* 若不 strip,_ig_poison_mark / _ig_poison_mask / _ig_policy_* 等**内部**符号名
* 会留在符号表,成为「nm 一把定位 → 找调用点 → NOP」的锚点。
*
* 策略:
* - 整个 defender 库用 -fvisibility=hidden 编译:默认所有符号隐藏(private extern)。
* - 只有接入方跨 bridging header 真正引用的入口用 IG_PUBLIC 显式导出:
* ig_defender_scan / ig_policy_scan_and_mark / ig_poison_init / ig_poison_apply。
* - 其余(mark/mask/sink/reset/evaluate/anti_jb_* 及各探针内部)保持 hidden,
* 最终 App 链接 + strip 后从符号表消失,nm 再也捞不到名字。
*
* 边界(如实声明):
* - 这不消除调用图的「边」(bl 仍在),只抹掉「节点的名字」——把定位成本从
* 「nm 一把」抬到「靠交叉引用 + 语义猜」。真正删边要靠内联(apply 揉进解密)
* 与间接化调用点,见 docs/18 §7。
* - 在 .a 阶段 hidden 符号仍可能以 private-extern 出现在**静态**符号表(nm 无 -g);
* 决定性的一步是最终镜像 strip。故接入方必须保持 Release 的 strip(见 docs/18 §7.0)。
*/
#ifndef IG_VISIBILITY_H
#define IG_VISIBILITY_H
#if defined(__GNUC__) || defined(__clang__)
#define IG_PUBLIC __attribute__((visibility("default")))
#define IG_INTERNAL __attribute__((visibility("hidden")))
#else
#define IG_PUBLIC
#define IG_INTERNAL
#endif
#endif /* IG_VISIBILITY_H */