feat(llvm): 加固 SD 签名与内购交易关键分支
This commit is contained in:
@@ -964,7 +964,8 @@ def build_ipa(scheme: str, output_dir: Path, seed: str, expected_binaries: int,
|
||||
)
|
||||
assert icall_gate['gate_passed'], f"IndirectCallGate failed: {icall_gate['violations']}"
|
||||
ibr_gate = verify_macho_indirect_branches.verify_binary_indirect_branches(
|
||||
main_bin, dwarf_bin, obf_audit
|
||||
main_bin, dwarf_bin, obf_audit,
|
||||
required_sources=policy.get('required_indirect_branch_sources') or (),
|
||||
)
|
||||
print(
|
||||
f"[IndirectBranchGate] verified={ibr_gate['verified_ibr_count']}/{ibr_gate['linked_checked_count']} "
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify that every indirect-branch obfuscated function emits ARM64 `br xN` instructions in Mach-O."""
|
||||
import argparse
|
||||
from collections import Counter
|
||||
from collections.abc import Iterable
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import json
|
||||
from pathlib import Path
|
||||
@@ -37,6 +39,7 @@ def verify_binary_indirect_branches(
|
||||
obf_audit: dict,
|
||||
*,
|
||||
fail_on_missing: bool = False,
|
||||
required_sources: Iterable[str] = (),
|
||||
) -> dict:
|
||||
"""Disassemble every audited IBR function in main_bin and require >=1 `br xN`."""
|
||||
ranges_map = parse_dwarf_text_ranges(dwarf_bin)
|
||||
@@ -86,7 +89,10 @@ def verify_binary_indirect_branches(
|
||||
**range_results[0],
|
||||
})
|
||||
|
||||
verified_per_source = Counter(item['source'] for item in verified)
|
||||
required_source_counts = {source: verified_per_source[source] for source in required_sources}
|
||||
summary = {
|
||||
'required_sources_verified': required_source_counts,
|
||||
'total_audited': len(verified) + len(failed) + (0 if fail_on_missing else len(dead_stripped)),
|
||||
'linked_checked_count': len(verified) + len(failed),
|
||||
'verified_ibr_count': len(verified),
|
||||
@@ -100,6 +106,9 @@ def verify_binary_indirect_branches(
|
||||
raise AssertionError(
|
||||
f'[IndirectBranchGate] {len(failed)} function(s) failed br xN check:\n{preview}'
|
||||
)
|
||||
missing_sources = [source for source, count in required_source_counts.items() if not count]
|
||||
if missing_sources:
|
||||
raise AssertionError('[IndirectBranchGate] 缺少已链接的间接分支保护: ' + ', '.join(missing_sources))
|
||||
return summary
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user