在 iOSGuard 侧产出可集成产物与接入文档,不修改 readoor 代码。 - defender/: anti_hook/anti_frida/anti_debug/anti_jailbreak 探针 + syscall 直发、 policy 分级层、poison 数据依赖毒化、dispatch/resolve/call_bridge 等子模块 - poison: 三副本冗余、无分支掩码;健康恒等、毒化破坏 key(替代 if-exit 处置) - policy: STRONG/MEDIUM/WEAK 分级,守误报底线,仅 DETECTED 参与、组合命中才毒化 - anti_jailbreak: IGSyscall 直发 svc 检测越狱文件(400)/沙盒逃逸(401),绕 libc hook - tools/build_defender_lib.sh: 一键交叉编译打包 libIGDefender.a(arm64) + umbrella 头 - docs/18_READOOR_DEFENDER_INTEGRATION.md: 精确到文件/bridging/替换点/代码片段 - docs/05-17 + evidence + tests + macho_guard/static_sdk_redirect 工具链 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
62 lines
2.8 KiB
C
62 lines
2.8 KiB
C
/*
|
||
* IGSyscall.h — ARM64 混淆直发系统调用(落地方案第一优先级)。
|
||
*
|
||
* 文件/进程/安全类系统调用若经 libsystem_kernel.dylib 走,libSystem 的函数入口可被 inline hook、
|
||
* __got 槽可被 fishhook 重绑定。本模块用内联汇编 `svc #0x80` 直接进内核,绕过 C 库封装层——
|
||
* 那条可被 hook 的 libSystem 入口在这条路径上根本不存在。
|
||
*
|
||
* 反静态特征:IDA 等常搜索 `svc #0x80` 并读 x16 的立即数识别调用号。本模块不把真实调用号写成
|
||
* `movz x16,#n` 立即数,而是调用方传入 XOR 编码值(IG_SC 宏),运行期与 ig_sc_key 异或还原后
|
||
* 由寄存器载入 x16,使静态扫描读不到真实号。
|
||
*
|
||
* 边界(如实声明,与 docs/05 §2 一致):
|
||
* - 仅 arm64。直发系统调用绕过 libSystem,跨 iOS 版本的调用号/ABI 稳定性由调用方负责;
|
||
* Apple 审核对直发 svc 可能关注,非 App Store 主线,用于确需防 hook 的关键路径。
|
||
* - 错误语义:返回值 <0 不自动转 errno;错误时内核置 carry、x0=errno,本封装统一返回 -errno。
|
||
* - 变参/取消点/EINTR 等 libc 语义不代为处理,调用方按需补。
|
||
*/
|
||
#ifndef IG_SYSCALL_H
|
||
#define IG_SYSCALL_H
|
||
|
||
#include <stdint.h>
|
||
#include <stddef.h>
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
/* 编译期 XOR 编码掩码:调用方用 IG_SC(真实号) 传参,真实号不以明文/立即数进入二进制。 */
|
||
#define IG_SC_CMASK 0x5Al
|
||
#define IG_SC(n) ((long)((long)(n) ^ IG_SC_CMASK))
|
||
|
||
/* 运行期密钥(构造函数置为 IG_SC_CMASK,经 volatile 存取避免被常量折叠回立即数)。 */
|
||
extern volatile long ig_sc_key;
|
||
|
||
/*
|
||
* 通用直发。enc_num:IG_SC(真实调用号)。a0..a5:参数(不足补 0)。
|
||
* 成功返回内核结果(x0);失败返回 -errno。
|
||
*/
|
||
long ig_syscall6(long enc_num, long a0, long a1, long a2, long a3, long a4, long a5);
|
||
|
||
/* 常用封装(均走 ig_syscall6,调用号经 IG_SC 编码)。 */
|
||
int ig_sys_getpid(void);
|
||
long ig_sys_write(int fd, const void *buf, size_t n);
|
||
long ig_sys_read(int fd, void *buf, size_t n);
|
||
int ig_sys_open(const char *path, int flags, int mode);
|
||
int ig_sys_close(int fd);
|
||
int ig_sys_access(const char *path, int amode); /* 直发 access(2);0=可访问,<0=-errno */
|
||
int ig_sys_unlink(const char *path); /* 直发 unlink(2);0=成功,<0=-errno */
|
||
void ig_sys_exit(int code) __attribute__((noreturn));
|
||
|
||
/*
|
||
* 调试器检测:直发 sysctl(KERN_PROC/KERN_PROC_PID) 读 kinfo_proc.p_flag & P_TRACED。
|
||
* 返回 1=被跟踪,0=未跟踪,-1=unavailable(sysctl 失败)。不经 libc,规避对 sysctl 的 hook。
|
||
*/
|
||
int ig_sys_is_debugged(void);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif /* IG_SYSCALL_H */
|