test(anti_tamper): IGAntiTamper 真机正反双向验证达标(D9,iPhone 16 Plus 非越狱)
poison_device.m 加 D9a–d 四条环境无关不变量 + csops_status/501 两条观察, 复用 build/run_poison_device harness。实测(verdict PASS,不变量 9/9): - 误报底线:expect_*=0 → 零 DETECTED,对应 finding UNAVAILABLE - cryptid 真读主镜像:expect=1 → reason500=1(dev 包 cryptid==0),mh=0x104390000 - 整入口贯通:ig_anti_tamper_check(1,1) → 500 + 501 - csops 真机活性:rc=0 status=0x22003305 valid=1 adhoc=0 get_task_allow=1 (坐实 csops 在 iOS arm64 活着,排除 501 假阴性) 残留缺口(只能在真 App Store/TestFlight 包验):cryptid==1 正向 CLEAR + 分发签名零误触——dev profile 无法复现 FairPlay 加密/分发签名。docs/18 §7.7、docs/19 §6。 证据 test-results/step12-device-poison/20261113-antitamper-R/(gitignore)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
cb51fdc6f0
commit
1094cc2760
Vendored
+89
@@ -27,8 +27,34 @@
|
||||
#include "poison/IGPoison.h"
|
||||
#include "policy/IGPolicy.h"
|
||||
#include "anti_jailbreak/IGAntiJailbreak.h"
|
||||
#include "anti_tamper/IGAntiTamper.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <mach-o/loader.h>
|
||||
|
||||
/* 原始 csops(与 IGAntiTamper 同,供 .m 直读状态字作真机观察,坐实 csops 活性) */
|
||||
#ifndef CS_OPS_STATUS
|
||||
#define CS_OPS_STATUS 0
|
||||
#endif
|
||||
#define IG_CS_VALID 0x00000001u
|
||||
#define IG_CS_ADHOC 0x00000002u
|
||||
#define IG_CS_GET_TASK_ALLOW 0x00000004u
|
||||
extern int csops(pid_t pid, unsigned int ops, void *useraddr, size_t usersize);
|
||||
|
||||
/* 进程主可执行镜像头(与 IGAntiTamper 内部同逻辑,便于直接喂给可测核心) */
|
||||
static const struct mach_header_64 *dev_main_image_header(void) {
|
||||
uint32_t n = _dyld_image_count();
|
||||
for (uint32_t i = 0; i < n; ++i) {
|
||||
const struct mach_header *h = _dyld_get_image_header(i);
|
||||
if (h && h->magic == MH_MAGIC_64 &&
|
||||
((const struct mach_header_64 *)h)->filetype == MH_EXECUTE) {
|
||||
return (const struct mach_header_64 *)h;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* ---------- 发现收集 ---------- */
|
||||
#define IG_MAXF 64
|
||||
@@ -167,6 +193,69 @@ int main(int argc, char **argv) {
|
||||
reset_findings();
|
||||
}
|
||||
|
||||
/* ===== D9 anti_tamper:二进制完整性探针真机验证 =====
|
||||
* dev 签名包是环境无关不变量:本地编译=无 FairPlay 加密(无 LC_ENCRYPTION_INFO
|
||||
* 或 cryptid=0)、且带 get-task-allow。据此双向验证 IGAntiTamper:
|
||||
* expect=0(dev 正确配置)→ 全 UNAVAILABLE、零 DETECTED(误报底线);
|
||||
* expect=1(假装分发)→ cryptid 命中 500、csops 读到 get-task-allow 命中 501
|
||||
* (坐实探针真读到真实镜像头/签名状态,逻辑正确)。 */
|
||||
const struct mach_header_64 *mh = dev_main_image_header();
|
||||
|
||||
/* D9a cryptid_expect0_clean:非分发构建跳过,零 DETECTED(误报底线) */
|
||||
{
|
||||
reset_findings();
|
||||
int hits = ig_tamper_scan_cryptid(mh, /*expect_encrypted=*/0, collect, NULL);
|
||||
mark_case("at_cryptid_expect0_clean", hits == 0 && g_detected == 0,
|
||||
"dev build, expect_encrypted=0 must not flag");
|
||||
reset_findings();
|
||||
}
|
||||
|
||||
/* D9b cryptid_expect1_detects:dev 包无 FairPlay 加密 → 命中 500(探针真读主镜像头) */
|
||||
{
|
||||
reset_findings();
|
||||
int hits = ig_tamper_scan_cryptid(mh, /*expect_encrypted=*/1, collect, NULL);
|
||||
int r500 = count_reason(IG_REASON_BINARY_DECRYPTED);
|
||||
char d[96]; snprintf(d, sizeof(d), "hits=%d reason500=%d mh=%p", hits, r500, (void *)mh);
|
||||
mark_case("at_cryptid_expect1_detects", hits >= 1 && r500 >= 1, d);
|
||||
reset_findings();
|
||||
}
|
||||
|
||||
/* D9c tamper_gated_off:两检查都 expect=0 → 零 DETECTED(误报底线整入口) */
|
||||
{
|
||||
reset_findings();
|
||||
int hits = ig_anti_tamper_check(/*expect_encrypted=*/0, /*expect_distribution=*/0,
|
||||
collect, NULL);
|
||||
mark_case("at_tamper_gated_off", hits == 0 && g_detected == 0,
|
||||
"dev build, expect_*=0 whole-entry must not flag");
|
||||
reset_findings();
|
||||
}
|
||||
|
||||
/* D9d tamper_on_detects:expect_*=1 → 至少 cryptid 500 命中(整入口贯通真机) */
|
||||
{
|
||||
reset_findings();
|
||||
int hits = ig_anti_tamper_check(/*expect_encrypted=*/1, /*expect_distribution=*/1,
|
||||
collect, NULL);
|
||||
int r500 = count_reason(IG_REASON_BINARY_DECRYPTED);
|
||||
int r501 = count_reason(IG_REASON_CODESIGN_INVALID);
|
||||
char d[112]; snprintf(d, sizeof(d), "hits=%d reason500=%d reason501=%d", hits, r500, r501);
|
||||
mark_case("at_tamper_on_detects", hits >= 1 && r500 >= 1, d);
|
||||
/* 501(csops 代码签名)作观察:dev 包带 get-task-allow 应命中,但 csops 语义真机坐实为准 */
|
||||
char o[64]; snprintf(o, sizeof(o), "reason501_codesign_hits=%d", r501);
|
||||
observe("at_codesign_501", o);
|
||||
reset_findings();
|
||||
}
|
||||
|
||||
/* D9e csops_status(观察):直读 csops 状态字,坐实 csops 在真机 iOS arm64 活着 */
|
||||
{
|
||||
uint32_t st = 0;
|
||||
int rc = csops(getpid(), CS_OPS_STATUS, &st, sizeof(st));
|
||||
char o[128];
|
||||
snprintf(o, sizeof(o), "rc=%d status=0x%x valid=%d adhoc=%d get_task_allow=%d",
|
||||
rc, st, (st & IG_CS_VALID) != 0, (st & IG_CS_ADHOC) != 0,
|
||||
(st & IG_CS_GET_TASK_ALLOW) != 0);
|
||||
observe("csops_status", o);
|
||||
}
|
||||
|
||||
/* ===== D2 jb_file(观察):内置越狱特征表直发 access ===== */
|
||||
reset_findings();
|
||||
ig_anti_jb_check(collect, NULL);
|
||||
|
||||
Reference in New Issue
Block a user