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:
shenlei
2026-11-24 15:00:07 +09:00
parent 1094cc2760
commit 704ee66834
106 changed files with 27487 additions and 286 deletions
+75
View File
@@ -0,0 +1,75 @@
"""Exercise legacy lazy binding on the reviewed AliyunPlayer arm64 SDK."""
import hashlib
from pathlib import Path
import struct
import sys
import unittest
import zipfile
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'tools/macho_guard'))
from batch import arm64_slices, Slice
from redirect_legacy_fopen import rewrite
from machox import Macho
IPA = ROOT / 'appstore.ipa'
@unittest.skipUnless(IPA.exists(), '需要归档 IPA 中的 AliyunPlayer')
class LegacyFopenTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
with zipfile.ZipFile(IPA) as archive:
names = [n for n in archive.namelist() if n.endswith('/AliyunPlayer.framework/AliyunPlayer')]
if len(names) != 1:
raise ValueError('需要唯一 AliyunPlayer')
data = archive.read(names[0])
offset, size = arm64_slices(data)[0]
cls.data = data[offset:offset + size]
def apply(self, data):
return rewrite(data, hashlib.sha256(data).hexdigest())
def test_real_lazy_binding(self):
result, report = self.apply(self.data)
self.assertTrue(report['lazy_offsets_preserved'])
self.assertTrue(report['section_bytes_unchanged'])
self.assertEqual(Slice(self.data, 0).scan()['_fopen'], 28)
self.assertEqual(Slice(result, 0).scan()['_fopen'], 0)
self.assertEqual(len(result), len(self.data))
before = Macho(self.data)
after = Macho(result)
old = next(o for c, _, o in before.cmds if c == 0x80000022)
new = next(o for c, _, o in after.cmds if c == 0x80000022)
self.assertEqual(self.data[old + 8:old + 48], result[new + 8:new + 48])
self.assertEqual(report['new_ordinal'], 33)
def test_hash_mismatch(self):
with self.assertRaises(ValueError):
rewrite(self.data, '0' * 64)
def test_repeat_rejected(self):
result, _ = self.apply(self.data)
with self.assertRaises(ValueError):
self.apply(result)
def test_no_header_space(self):
data = bytearray(self.data)
data[32 + Macho(data).sizeofcmds] = 1
with self.assertRaises(ValueError):
self.apply(bytes(data))
def test_wrong_lazy_provider(self):
data = bytearray(self.data)
m = Macho(data)
off = next(o for c, _, o in m.cmds if c == 0x80000022)
lazy, size = struct.unpack_from('<II', data, off + 32)
symbol = data.index(b'_fopen\0', lazy, lazy + size)
self.assertEqual(data[symbol - 3:symbol], b'\x20\x20\x40')
data[symbol - 2] = 1
with self.assertRaises(ValueError):
self.apply(bytes(data))
if __name__ == '__main__':
unittest.main()