feat: 集成 LLVM IR 混淆体系、Route 2 全量合规与系统调用调度加固
- defender: 扩展 IGDispatch/IGArchiveGuard/IGAntiHook/IGObjCBaseline/IGResolve,支持 Route 2 静态库桥接 (IGThreadID.c) 与防重签名检测 - llvm_passes: 新增 IGObfuscator LLVM IR 插件源码(控制流平坦化、字符串加密、间接跳转/调用、不透明常量/字段、MBA、函数外提、基本块拆分、反 Hook 序言) - tools & config: 新增 Xcode 归档编译/链接包装器、LLVM 自愈工具链 (ig_toolchain_resolver)、IPA 审计门禁、崩溃符号还原及最新 ig_llvm_policy.json(文件级匹配 + 3.0 全业务 Handler 平坦化) - tests & docs: 补齐 M0~M3、Pass 单测及系统调用调度/Route 2/LLVM 方案文档;.gitignore 忽略 *.bc 与 .obfuscate_extraction_cache.json
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
|
||||
需 Xcode + iphoneos SDK;缺则跳过。
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -138,6 +140,73 @@ class StaticHardeningTests(unittest.TestCase):
|
||||
and ('__ig' in ln or '__poison' in ln or '__ig_p' in ln)]
|
||||
self.assertEqual(leak, [], f'泄漏性命名 section(strip 抹不掉,会挂牌毒化副本位置):{leak}')
|
||||
|
||||
def test_no_diagnostic_strings_in_release(self):
|
||||
"""Release 构建(无 DEBUG/IG_OBSERVATION)不得残留探针 subject/evidence 明文诊断串。"""
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
ar_dir = Path(td)
|
||||
subprocess.run(['xcrun', '--sdk', 'iphoneos', 'ar', 'x', str(self.lib)],
|
||||
cwd=ar_dir, check=True)
|
||||
cstrings = bytearray()
|
||||
for obj in sorted(ar_dir.glob('*.o')):
|
||||
out = subprocess.run(
|
||||
['xcrun', '--sdk', 'iphoneos', 'otool', '-s', '__TEXT', '__cstring', str(obj)],
|
||||
capture_output=True, text=True, check=True,
|
||||
).stdout
|
||||
for line in out.splitlines():
|
||||
parts = line.split('\t')
|
||||
if len(parts) == 2:
|
||||
for hx in parts[1].strip().split():
|
||||
try:
|
||||
cstrings.append(int(hx, 16))
|
||||
except ValueError:
|
||||
pass
|
||||
raw = bytes(cstrings)
|
||||
diag_needles = [
|
||||
b'cryptid==0',
|
||||
b'CS_VALID',
|
||||
b'get-task-allow',
|
||||
b'P_TRACED',
|
||||
b'DYLD_INSERT_LIBRARIES',
|
||||
b'dispatch-write',
|
||||
b'dispatch-target',
|
||||
b'archive-target',
|
||||
b'task_threads',
|
||||
'蹦床'.encode('utf-8'),
|
||||
'基线'.encode('utf-8'),
|
||||
'重签'.encode('utf-8'),
|
||||
'提供方'.encode('utf-8'),
|
||||
'弱信号'.encode('utf-8'),
|
||||
]
|
||||
hits = [n.decode('utf-8', errors='replace') for n in diag_needles if n in raw]
|
||||
self.assertEqual(hits, [], f'Release libIGDefender.a __cstring 残留诊断明文串:{hits}')
|
||||
|
||||
def test_m1_objc_hybrid_hardening_coverage(self):
|
||||
"""M1:RDEpubCryptBridge 基线监控 >= 30 条,高敏 OC 扩展进入压平与串加密策略,核心 OC 类锁定 L1。"""
|
||||
bridge_src = (ROOT / 'readoor-test/readoor/3.0/Base/Security/RDEpubCryptBridge.m').read_text(encoding='utf-8')
|
||||
watch_count = len(re.findall(r'sel_getName\(@selector\(', bridge_src))
|
||||
self.assertGreaterEqual(watch_count, 30, f'Expected >= 30 baseline watches, got {watch_count}')
|
||||
|
||||
policy = json.loads((ROOT / 'config/ig_llvm_policy.json').read_text(encoding='utf-8'))
|
||||
expected_paths = [
|
||||
'BookShelf/Classes/Features/IAP/Extension/',
|
||||
'BookShelf/Classes/Features/Login/Extension/',
|
||||
'BookShelf/Classes/Extension/ControllersExtension/STSBaseViewController+STSReadOrPayExtension.m',
|
||||
'BookView/EPUB/Core/Classes/STSBaseViewController+STSEpubViewLoginOrPayExtension.m',
|
||||
'BookView/PDF/Core/Classes/Stage/STSBaseViewController+STSPDFViewLoginOrPayExtension.m',
|
||||
]
|
||||
str_paths = {r.get('path_contains') for r in policy.get('string_encrypt_targets', [])}
|
||||
fla_paths = {r.get('path_contains') for r in policy.get('flatten_targets', [])}
|
||||
for p in expected_paths:
|
||||
self.assertIn(p, str_paths, f'Missing from string_encrypt_targets: {p}')
|
||||
self.assertIn(p, fla_paths, f'Missing from flatten_targets: {p}')
|
||||
|
||||
build_py = (ROOT / 'tools/llvm_obf/build_obfuscated_ipa.py').read_text(encoding='utf-8')
|
||||
for cls_name in (
|
||||
'STSIAPHandler', 'STSIAPVerifyHandler', 'STSIAPKeyChainHandler',
|
||||
'STSIAPVerifyTask', 'STSJailbreakDetectTool',
|
||||
):
|
||||
self.assertIn(f"'{cls_name}'", build_py, f'Missing from unobfuscated_watch_classes: {cls_name}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user