feat(anti_tamper): IGAntiTamper——二进制完整性/防重打包探针(cryptid+csops)
补 anti_hook 只盯固定函数之外的空洞,正面反制 App Store 标准破解链 (脱壳解密→patch→重签): - FairPlay cryptid(reason=500):cryptid==0 或 LC_ENCRYPTION_INFO 被剥除=脱壳/重打包 - 代码签名 csops CS_OPS_STATUS(reason=501):CS_VALID 失效/ad-hoc 重签/分发包带 get-task-allow 误报底线:两条均按 expect_encrypted/expect_distribution 构建上下文开关, dev/诊断/TestFlight 传 0→UNAVAILABLE,绝不在非分发构建误报。作为独立探针 由 Swift 策略层/observer 带构建上下文单独调用,不并入 ig_defender_scan(不破坏现有签名)。 回归:tests/test_anti_tamper.py 合成 Mach-O 头跑 cryptid 核心五例(加密正常/脱壳/ 剥除/非分发跳过/NULL);模块接入 poison_host 与 device 链接列表。全量 73 过, iphoneos arm64 交叉编译通过。csops+真实主镜像验证待设备。docs/18 §7.7。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
2e43ff6da2
commit
cb51fdc6f0
@@ -0,0 +1,38 @@
|
||||
"""IGAntiTamper 宿主自测:cryptid 核心逻辑(合成 Mach-O 头)。
|
||||
|
||||
真机的 csops 代码签名检查与真实主镜像 cryptid 由设备测试覆盖;此处固化可复现的
|
||||
cryptid 判定基线(加密正常/脱壳/剥除/非分发跳过/NULL),退出码 0 = 全过。
|
||||
"""
|
||||
from pathlib import Path
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SOURCES = ['anti_tamper/IGAntiTamper.c']
|
||||
|
||||
|
||||
@unittest.skipUnless(sys.platform == 'darwin' and shutil.which('xcrun'), '需要 Xcode/macOS')
|
||||
class AntiTamperCryptidTests(unittest.TestCase):
|
||||
def test_cryptid_core(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
exe = Path(d) / 'anti-tamper-host'
|
||||
env = dict(os.environ)
|
||||
env.pop('DYLD_INSERT_LIBRARIES', None)
|
||||
args = ['xcrun', '--sdk', 'macosx', 'clang', '-O2',
|
||||
'-I', str(ROOT / 'defender/include'), '-I', str(ROOT / 'defender'),
|
||||
str(ROOT / 'tests/fixtures/anti_tamper_host.c'),
|
||||
*(str(ROOT / 'defender' / p) for p in SOURCES),
|
||||
'-o', str(exe)]
|
||||
build = subprocess.run(args, capture_output=True, text=True, env=env)
|
||||
self.assertEqual(build.returncode, 0, build.stdout + build.stderr)
|
||||
run = subprocess.run([str(exe)], capture_output=True, text=True, env=env)
|
||||
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
||||
self.assertIn('PASSED', run.stdout)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user