针对「纯客户端抗静态分析」的最高性价比项落地,守在 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>
60 lines
2.7 KiB
C
60 lines
2.7 KiB
C
/*
|
||
* IGPolicy.h — 策略层:把探针证据按强弱分级,组合判定后决定是否毒化(ig_poison_mark)。
|
||
*
|
||
* 连接 [[iosguard-disposition-strategy]]:ig_defender_scan 流式上报 IGFinding,本层做 sink,
|
||
* 累积一次扫描的全部 DETECTED 证据;扫描结束后 evaluate 按组合规则决定是否触发毒化。
|
||
*
|
||
* 误报底线(最重要):毒化隐蔽且不可逆,误伤非越狱正常用户=差评卸载难排查。故:
|
||
* - 只有 DETECTED 参与;UNAVAILABLE(架构/平台不支持)与 CLEAR 一律忽略,绝不当攻击。
|
||
* - 信号分三档:
|
||
* STRONG(单条即判定):越狱文件/沙盒逃逸、GOT 重绑、inline hook、注入镜像、调试器跟踪。
|
||
* MEDIUM(需 ≥2 个不同 MEDIUM,或与任一 STRONG 同现才判定):符号提供方、ObjC IMP 变化、
|
||
* frida 线程——其中 ObjC IMP 合法 swizzling 会误报,故不单条定罪。
|
||
* WEAK(永不触发毒化,仅观察):Bundle 外镜像、frida 端口等弱证据。
|
||
*
|
||
* 本层不自行 exit;唯一处置是数据依赖毒化。可选把 finding 转发给观察打点(observer)。
|
||
*/
|
||
#ifndef IG_POLICY_H
|
||
#define IG_POLICY_H
|
||
|
||
#include "IGDefender.h"
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
typedef struct {
|
||
int strong_count; /* STRONG 档命中条数 */
|
||
uint32_t medium_bitmap; /* MEDIUM 档已命中的不同 reason(去重用) */
|
||
int medium_distinct; /* MEDIUM 档不同 reason 数 */
|
||
uint64_t entropy; /* 命中 reason 聚合出的毒化熵(非 0) */
|
||
int detected_total; /* 累计 DETECTED 条数(观察用) */
|
||
IGFindingSink observer; /* 可选:每条 finding 透传给它做打点;NULL 跳过 */
|
||
void *observer_ctx; /* observer 的上下文 */
|
||
} IGPolicyState;
|
||
|
||
/* 重置状态;observer/observer_ctx 可传 NULL。 */
|
||
void ig_policy_reset(IGPolicyState *st, IGFindingSink observer, void *observer_ctx);
|
||
|
||
/* 作为 ig_defender_scan 的 sink:ctx 必须是 IGPolicyState*。只累积、不处置。 */
|
||
int ig_policy_sink(const IGFinding *finding, void *ctx);
|
||
|
||
/*
|
||
* 扫描结束后调用:按组合规则判定。满足即 ig_poison_mark(entropy) 并返回 1;否则返回 0。
|
||
* 规则:strong_count>=1 || medium_distinct>=2。
|
||
*/
|
||
int ig_policy_evaluate_and_mark(IGPolicyState *st);
|
||
|
||
/*
|
||
* 便捷封装:reset → ig_defender_scan → evaluate_and_mark 一次完成。
|
||
* 返回 1 表示本次触发了毒化。observer/observer_ctx 可 NULL。
|
||
*/
|
||
IG_PUBLIC int ig_policy_scan_and_mark(const char *bundle_path, int probe_port,
|
||
IGFindingSink observer, void *observer_ctx);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif /* IG_POLICY_H */
|