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:
@@ -0,0 +1,470 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify ARM64 direct BL/tail-B vs indirect BLR call-graph metrics in a linked Mach-O binary."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from array import array
|
||||
import bisect
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
MH_MAGIC_64 = 0xFEEDFACF
|
||||
FAT_MAGIC = 0xCAFEBABE
|
||||
FAT_CIGAM = 0xBEBAFECA
|
||||
LC_SEGMENT_64 = 0x19
|
||||
CPU_TYPE_ARM64 = 0x0100000C
|
||||
|
||||
KEYBOX_AND_BRIDGE_C_SYMBOLS = [
|
||||
'_rd_epub_derive_book_key',
|
||||
'_rd_epub_derive_media_key',
|
||||
'_rd_epub_legacy_url_prefix',
|
||||
'_rd_epub_derive_book_key_ns',
|
||||
'_rd_epub_derive_media_key_ns',
|
||||
'_rd_epub_legacy_tag_prefix',
|
||||
'_rd_epub_media_pwd_ns',
|
||||
'_rd_epub_db_key_ns',
|
||||
'_rd_epub_device_token_key_ns',
|
||||
'_rd_epub_course_sign_prefix_ns',
|
||||
'_rd_epub_wx_pay_secret_ns',
|
||||
'_rd_content_decrypt_file',
|
||||
'_rd_epub_key_transform',
|
||||
'_rd_epub_poison_mark',
|
||||
'_rd_sd_derive_aes256_key',
|
||||
'_rd_sd_decrypt_bundled_asset',
|
||||
'_rd_sd_keychain_slot_name',
|
||||
'_rd_sd_bundle_asset_stem',
|
||||
'_rd_iap_keychain_account_name',
|
||||
'_rd_sd_media_decrypt_pwd',
|
||||
'_rd_sd_db_secret_key',
|
||||
'_rd_sd_device_token_key',
|
||||
'_rd_sd_course_sign_prefix',
|
||||
'_rd_sd_wx_pay_secret',
|
||||
'_rd_sd_derive_v31_seed',
|
||||
'_rd_sd_derive_v31_dt_pwd',
|
||||
'_rd_sd_seckey_create_with_data',
|
||||
'_rd_sd_seckey_create_signature',
|
||||
'_rd_sd_cc_crypt',
|
||||
'_rd_sd_cc_hmac',
|
||||
'_rd_sd_is_traced',
|
||||
'_rd_sd_sha256_init',
|
||||
'_rd_sd_sha256_update',
|
||||
'_rd_sd_sha256_final',
|
||||
'_rd_sd_sha256_raw',
|
||||
'_rd_sd_sha256_hex',
|
||||
'_rd_sd_md5_hex',
|
||||
'_rd_sec_bootstrap_launch',
|
||||
'_rd_sd_probe_env_artifacts',
|
||||
]
|
||||
|
||||
TRACKED_CORE_TYPES = [
|
||||
'RDEncryptedEpubResourceProvider',
|
||||
'EpubParser',
|
||||
'LoadEpub',
|
||||
'STSEpubWebResourceLoader',
|
||||
'RBCoreEpubLoadController',
|
||||
'STSRDFileManagerStorage',
|
||||
'RDPDFStsSimpleCryptBridge',
|
||||
'RDSDPrivateKeyManager',
|
||||
'RDSDAuthV32Signer',
|
||||
'RDBaseNetworkService',
|
||||
'RDKeyGenerator',
|
||||
'RDIAPHandler',
|
||||
'STSIAPVerifyHandler',
|
||||
]
|
||||
|
||||
|
||||
def _select_arm64_slice(data: bytes) -> memoryview:
|
||||
magic = struct.unpack_from('<I', data, 0)[0]
|
||||
if magic == MH_MAGIC_64:
|
||||
return memoryview(data)
|
||||
be_magic = struct.unpack_from('>I', data, 0)[0]
|
||||
if be_magic == FAT_MAGIC:
|
||||
nfat = struct.unpack_from('>I', data, 4)[0]
|
||||
for idx in range(nfat):
|
||||
cputype, _, offset, size, _ = struct.unpack_from('>IIIII', data, 8 + idx * 20)
|
||||
if cputype == CPU_TYPE_ARM64:
|
||||
return memoryview(data)[offset:offset + size]
|
||||
raise ValueError(f'Unsupported Mach-O magic: 0x{magic:08x}')
|
||||
|
||||
|
||||
def parse_macho_sections(binary_path: Path) -> dict[str, dict[str, int]]:
|
||||
"""Return mapping of 'SEGNAME,sectname' -> {'addr', 'size', 'offset'} for arm64 slice."""
|
||||
raw = binary_path.read_bytes()
|
||||
mv = _select_arm64_slice(raw)
|
||||
magic, _, _, _, ncmds, _, _, _ = struct.unpack_from('<IIIIIIII', mv, 0)
|
||||
if magic != MH_MAGIC_64:
|
||||
raise ValueError(f'Expected MH_MAGIC_64, got 0x{magic:08x}')
|
||||
sections: dict[str, dict[str, int]] = {}
|
||||
cmd_off = 32
|
||||
for _ in range(ncmds):
|
||||
cmd, cmdsize = struct.unpack_from('<II', mv, cmd_off)
|
||||
if cmd == LC_SEGMENT_64:
|
||||
segname_raw, vmaddr, vmsize, fileoff, filesize, _, _, nsects, _ = struct.unpack_from(
|
||||
'<16sQQQQIIII', mv, cmd_off + 8
|
||||
)
|
||||
segname = segname_raw.split(b'\x00', 1)[0].decode('latin1')
|
||||
sections[f'{segname},*'] = {
|
||||
'addr': vmaddr,
|
||||
'size': vmsize,
|
||||
'offset': fileoff,
|
||||
'filesize': filesize,
|
||||
}
|
||||
sect_off = cmd_off + 72
|
||||
for _ in range(nsects):
|
||||
sect_raw, seg_raw, addr, size, offset = struct.unpack_from(
|
||||
'<16s16sQQI', mv, sect_off
|
||||
)
|
||||
sname = sect_raw.split(b'\x00', 1)[0].decode('latin1')
|
||||
gname = seg_raw.split(b'\x00', 1)[0].decode('latin1')
|
||||
sections[f'{gname},{sname}'] = {
|
||||
'addr': addr,
|
||||
'size': size,
|
||||
'offset': offset,
|
||||
}
|
||||
sect_off += 80
|
||||
cmd_off += cmdsize
|
||||
return sections
|
||||
|
||||
|
||||
def parse_dwarf_symbols(dwarf_bin: Path) -> tuple[list[int], list[int], list[list[str]], dict[str, list[tuple[int, int]]]]:
|
||||
"""Return sorted unique text symbol ranges and name -> [(start, end)] lookup."""
|
||||
out = subprocess.check_output(['xcrun', 'nm', '-n', str(dwarf_bin)], text=True)
|
||||
addr_to_names: dict[int, list[str]] = {}
|
||||
for line in out.splitlines():
|
||||
parts = line.strip().split(maxsplit=2)
|
||||
if len(parts) == 3 and parts[1].lower() == 't':
|
||||
try:
|
||||
addr = int(parts[0], 16)
|
||||
except ValueError:
|
||||
continue
|
||||
addr_to_names.setdefault(addr, []).append(parts[2])
|
||||
|
||||
starts = sorted(addr_to_names.keys())
|
||||
ends: list[int] = []
|
||||
names_at_idx: list[list[str]] = []
|
||||
by_name: dict[str, list[tuple[int, int]]] = {}
|
||||
for idx, addr in enumerate(starts):
|
||||
end = starts[idx + 1] if idx + 1 < len(starts) else addr + 0x400
|
||||
ends.append(end)
|
||||
nlist = addr_to_names[addr]
|
||||
names_at_idx.append(nlist)
|
||||
for nm in nlist:
|
||||
by_name.setdefault(nm, []).append((addr, end))
|
||||
return starts, ends, names_at_idx, by_name
|
||||
|
||||
|
||||
def load_l1_type_map(symbol_map_path: Path | None) -> dict[str, str]:
|
||||
if not symbol_map_path or not symbol_map_path.is_file():
|
||||
return {}
|
||||
raw = json.loads(symbol_map_path.read_text(encoding='utf-8'))
|
||||
mappings = raw.get('mappings') if isinstance(raw.get('mappings'), dict) else raw
|
||||
out: dict[str, str] = {}
|
||||
if isinstance(mappings, dict):
|
||||
for orig, val in mappings.items():
|
||||
if isinstance(val, str):
|
||||
out[orig] = val
|
||||
elif isinstance(val, dict) and isinstance(val.get('obfuscated'), str):
|
||||
out[orig] = val['obfuscated']
|
||||
return out
|
||||
|
||||
|
||||
def analyze_macho_calls(
|
||||
binary_path: Path,
|
||||
dwarf_bin: Path,
|
||||
symbol_map_path: Path | None = None,
|
||||
require_zero_keybox_direct_bl: bool = False,
|
||||
) -> dict:
|
||||
raw = binary_path.read_bytes()
|
||||
mv = _select_arm64_slice(raw)
|
||||
sections = parse_macho_sections(binary_path)
|
||||
if '__TEXT,__text' not in sections:
|
||||
raise ValueError(f'Missing __TEXT,__text in {binary_path}')
|
||||
|
||||
text_sec = sections['__TEXT,__text']
|
||||
text_va = text_sec['addr']
|
||||
text_size = text_sec['size']
|
||||
text_off = text_sec['offset']
|
||||
text_end_va = text_va + text_size
|
||||
|
||||
stubs_va = sections.get('__TEXT,__stubs', {}).get('addr', 0)
|
||||
stubs_end_va = stubs_va + sections.get('__TEXT,__stubs', {}).get('size', 0)
|
||||
objc_stubs_va = sections.get('__TEXT,__objc_stubs', {}).get('addr', 0)
|
||||
objc_stubs_end_va = objc_stubs_va + sections.get('__TEXT,__objc_stubs', {}).get('size', 0)
|
||||
|
||||
starts, ends, names_at_idx, by_name = parse_dwarf_symbols(dwarf_bin)
|
||||
start_to_idx = {addr: idx for idx, addr in enumerate(starts)}
|
||||
l1_types = load_l1_type_map(symbol_map_path)
|
||||
|
||||
words = array('I')
|
||||
words.frombytes(mv[text_off:text_off + (text_size & ~3)])
|
||||
if sys.byteorder != 'little':
|
||||
words.byteswap()
|
||||
|
||||
total_bl = 0
|
||||
internal_text_bl = 0
|
||||
dylib_stub_bl = 0
|
||||
objc_stub_bl = 0
|
||||
other_bl = 0
|
||||
interproc_tail_b = 0
|
||||
blr_count = 0
|
||||
|
||||
# Track direct incoming calls (BL + inter-procedural tail B) keyed by target symbol index
|
||||
direct_in_bl_by_idx: dict[int, int] = {}
|
||||
direct_in_tail_b_by_idx: dict[int, int] = {}
|
||||
# Track caller symbol index -> list of (pc, target_idx, kind) for KeyBox targets
|
||||
keybox_indices: dict[str, list[int]] = {}
|
||||
keybox_idx_set: set[int] = set()
|
||||
for sym in KEYBOX_AND_BRIDGE_C_SYMBOLS:
|
||||
idxs = []
|
||||
for s_addr, _ in by_name.get(sym, []):
|
||||
if s_addr in start_to_idx:
|
||||
idxs.append(start_to_idx[s_addr])
|
||||
keybox_idx_set.add(start_to_idx[s_addr])
|
||||
keybox_indices[sym] = idxs
|
||||
|
||||
keybox_caller_samples: dict[int, list[dict]] = {}
|
||||
|
||||
# Pre-classify symbol indices belonging to tracked core types (using both original & L1 token)
|
||||
core_type_tokens: dict[str, tuple[str, ...]] = {}
|
||||
for orig_type in TRACKED_CORE_TYPES:
|
||||
obf_type = l1_types.get(orig_type)
|
||||
toks = [orig_type]
|
||||
if obf_type and obf_type != orig_type:
|
||||
toks.append(obf_type)
|
||||
core_type_tokens[orig_type] = tuple(toks)
|
||||
|
||||
idx_to_core_types: dict[int, list[str]] = {}
|
||||
for idx, nlist in enumerate(names_at_idx):
|
||||
matched_types = []
|
||||
for orig_type, toks in core_type_tokens.items():
|
||||
if any(tok in nm for nm in nlist for tok in toks):
|
||||
matched_types.append(orig_type)
|
||||
if matched_types:
|
||||
idx_to_core_types[idx] = matched_types
|
||||
|
||||
core_outgoing_internal_bl: dict[str, int] = {t: 0 for t in TRACKED_CORE_TYPES}
|
||||
core_outgoing_blr: dict[str, int] = {t: 0 for t in TRACKED_CORE_TYPES}
|
||||
core_incoming_direct: dict[str, int] = {t: 0 for t in TRACKED_CORE_TYPES}
|
||||
|
||||
# Walk linearly while maintaining current symbol cursor `cur_sym_idx` in O(1) amortized time!
|
||||
num_syms = len(starts)
|
||||
cur_sym_idx = 0
|
||||
|
||||
for i, insn in enumerate(words):
|
||||
pc = text_va + (i << 2)
|
||||
while cur_sym_idx + 1 < num_syms and pc >= ends[cur_sym_idx]:
|
||||
cur_sym_idx += 1
|
||||
caller_idx = cur_sym_idx if (num_syms > 0 and starts[cur_sym_idx] <= pc < ends[cur_sym_idx]) else -1
|
||||
|
||||
op6 = insn & 0xFC000000
|
||||
if op6 == 0x94000000: # BL imm26
|
||||
total_bl += 1
|
||||
imm26 = insn & 0x03FFFFFF
|
||||
if imm26 & 0x02000000:
|
||||
imm26 -= 0x04000000
|
||||
tgt = pc + (imm26 << 2)
|
||||
if stubs_va <= tgt < stubs_end_va:
|
||||
dylib_stub_bl += 1
|
||||
elif objc_stubs_va <= tgt < objc_stubs_end_va:
|
||||
objc_stub_bl += 1
|
||||
elif text_va <= tgt < text_end_va:
|
||||
internal_text_bl += 1
|
||||
if caller_idx in idx_to_core_types:
|
||||
for ct in idx_to_core_types[caller_idx]:
|
||||
core_outgoing_internal_bl[ct] += 1
|
||||
t_idx = start_to_idx.get(tgt)
|
||||
if t_idx is None:
|
||||
pos = bisect.bisect_right(starts, tgt) - 1
|
||||
if 0 <= pos < num_syms and starts[pos] <= tgt < ends[pos]:
|
||||
t_idx = pos
|
||||
if t_idx is not None:
|
||||
direct_in_bl_by_idx[t_idx] = direct_in_bl_by_idx.get(t_idx, 0) + 1
|
||||
if t_idx in idx_to_core_types:
|
||||
for ct in idx_to_core_types[t_idx]:
|
||||
core_incoming_direct[ct] += 1
|
||||
if t_idx in keybox_idx_set and len(keybox_caller_samples.get(t_idx, [])) < 8:
|
||||
caller_name = names_at_idx[caller_idx][0] if caller_idx >= 0 else hex(pc)
|
||||
keybox_caller_samples.setdefault(t_idx, []).append({
|
||||
'pc': hex(pc),
|
||||
'kind': 'bl',
|
||||
'caller': caller_name,
|
||||
})
|
||||
else:
|
||||
other_bl += 1
|
||||
elif op6 == 0x14000000: # B imm26 (check inter-procedural tail-call to symbol entry)
|
||||
imm26 = insn & 0x03FFFFFF
|
||||
if imm26 & 0x02000000:
|
||||
imm26 -= 0x04000000
|
||||
tgt = pc + (imm26 << 2)
|
||||
if text_va <= tgt < text_end_va:
|
||||
t_idx = start_to_idx.get(tgt)
|
||||
if t_idx is not None and t_idx != caller_idx:
|
||||
interproc_tail_b += 1
|
||||
direct_in_tail_b_by_idx[t_idx] = direct_in_tail_b_by_idx.get(t_idx, 0) + 1
|
||||
if caller_idx in idx_to_core_types:
|
||||
for ct in idx_to_core_types[caller_idx]:
|
||||
core_outgoing_internal_bl[ct] += 1
|
||||
if t_idx in idx_to_core_types:
|
||||
for ct in idx_to_core_types[t_idx]:
|
||||
core_incoming_direct[ct] += 1
|
||||
if t_idx in keybox_idx_set and len(keybox_caller_samples.get(t_idx, [])) < 8:
|
||||
caller_name = names_at_idx[caller_idx][0] if caller_idx >= 0 else hex(pc)
|
||||
keybox_caller_samples.setdefault(t_idx, []).append({
|
||||
'pc': hex(pc),
|
||||
'kind': 'tail_b',
|
||||
'caller': caller_name,
|
||||
})
|
||||
elif (insn & 0xFFFFFC1F) == 0xD63F0000 or (insn & 0xFEFFF800) == 0xD73F0800 or (
|
||||
(insn & 0xFFFFFC1F) in (0xD63F081F, 0xD63F0C1F)
|
||||
):
|
||||
# BLR Xn or BLRAA/BLRAB/BLRAAZ/BLRABZ
|
||||
blr_count += 1
|
||||
if caller_idx in idx_to_core_types:
|
||||
for ct in idx_to_core_types[caller_idx]:
|
||||
core_outgoing_blr[ct] += 1
|
||||
|
||||
keybox_report: dict[str, dict] = {}
|
||||
keybox_total_direct_xrefs = 0
|
||||
violations = []
|
||||
for sym in KEYBOX_AND_BRIDGE_C_SYMBOLS:
|
||||
idxs = keybox_indices[sym]
|
||||
bl_cnt = sum(direct_in_bl_by_idx.get(ix, 0) for ix in idxs)
|
||||
tb_cnt = sum(direct_in_tail_b_by_idx.get(ix, 0) for ix in idxs)
|
||||
samples = []
|
||||
for ix in idxs:
|
||||
samples.extend(keybox_caller_samples.get(ix, []))
|
||||
total_sym = bl_cnt + tb_cnt
|
||||
keybox_total_direct_xrefs += total_sym
|
||||
keybox_report[sym] = {
|
||||
'present_in_dwarf': len(idxs) > 0,
|
||||
'direct_bl': bl_cnt,
|
||||
'direct_tail_b': tb_cnt,
|
||||
'total_direct_call_xrefs': total_sym,
|
||||
'caller_samples': samples[:5],
|
||||
}
|
||||
if require_zero_keybox_direct_bl and total_sym > 0:
|
||||
violations.append(f'{sym}: {total_sym} direct call xrefs ({samples[:3]})')
|
||||
|
||||
core_types_report: dict[str, dict] = {}
|
||||
for orig_type in TRACKED_CORE_TYPES:
|
||||
core_types_report[orig_type] = {
|
||||
'l1_token': l1_types.get(orig_type, orig_type),
|
||||
'outgoing_internal_direct_calls': core_outgoing_internal_bl[orig_type],
|
||||
'outgoing_indirect_blr': core_outgoing_blr[orig_type],
|
||||
'incoming_direct_calls': core_incoming_direct[orig_type],
|
||||
}
|
||||
|
||||
data_const_bytes = sections.get('__DATA_CONST,__const', {}).get('size', 0)
|
||||
text_const_bytes = sections.get('__TEXT,__const', {}).get('size', 0)
|
||||
|
||||
result = {
|
||||
'binary_path': str(binary_path),
|
||||
'binary_bytes': binary_path.stat().st_size,
|
||||
'text_bytes': text_size,
|
||||
'text_const_bytes': text_const_bytes,
|
||||
'data_const_bytes': data_const_bytes,
|
||||
'text_call_summary': {
|
||||
'total_bl': total_bl,
|
||||
'internal_text_bl': internal_text_bl,
|
||||
'interproc_tail_b': interproc_tail_b,
|
||||
'internal_direct_calls_total': internal_text_bl + interproc_tail_b,
|
||||
'dylib_stub_bl': dylib_stub_bl,
|
||||
'objc_stub_bl': objc_stub_bl,
|
||||
'other_bl': other_bl,
|
||||
'indirect_blr_total': blr_count,
|
||||
},
|
||||
'keybox_and_bridge_15_symbols': {
|
||||
'total_direct_call_xrefs': keybox_total_direct_xrefs,
|
||||
'symbols': keybox_report,
|
||||
},
|
||||
'tracked_core_types': core_types_report,
|
||||
'gate_passed': len(violations) == 0,
|
||||
'violations': violations,
|
||||
}
|
||||
return result
|
||||
|
||||
|
||||
def analyze_ipa_directory(
|
||||
ipa_dir: Path,
|
||||
scheme: str = 'readoor31OtherPay',
|
||||
require_zero_keybox_direct_bl: bool = False,
|
||||
) -> dict:
|
||||
ipa_path = ipa_dir / f'{scheme}.ipa'
|
||||
dsyms_zip = ipa_dir / 'dSYMs.zip'
|
||||
maps_dir = ipa_dir / 'obfuscation_maps'
|
||||
symbol_map = next(maps_dir.glob('*symbol_map*.json'), None) if maps_dir.is_dir() else None
|
||||
if not ipa_path.is_file() or not dsyms_zip.is_file():
|
||||
raise FileNotFoundError(f'Missing {ipa_path} or {dsyms_zip}')
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix='ig-icall-verify-') as tmp:
|
||||
tmp_path = Path(tmp)
|
||||
app_extract = tmp_path / 'ipa'
|
||||
dsym_extract = tmp_path / 'dsyms'
|
||||
subprocess.run(['ditto', '-x', '-k', str(ipa_path), str(app_extract)], check=True)
|
||||
subprocess.run(['ditto', '-x', '-k', str(dsyms_zip), str(dsym_extract)], check=True)
|
||||
main_bin = app_extract / 'Payload' / f'{scheme}.app' / scheme
|
||||
dwarf_bin = dsym_extract / f'{scheme}.app.dSYM' / 'Contents' / 'Resources' / 'DWARF' / scheme
|
||||
res = analyze_macho_calls(
|
||||
main_bin,
|
||||
dwarf_bin,
|
||||
symbol_map_path=symbol_map,
|
||||
require_zero_keybox_direct_bl=require_zero_keybox_direct_bl,
|
||||
)
|
||||
res['ipa_dir'] = str(ipa_dir)
|
||||
res['ipa_bytes'] = ipa_path.stat().st_size
|
||||
return res
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--ipa-dir', type=Path, help='Directory containing <scheme>.ipa and dSYMs.zip')
|
||||
parser.add_argument('--scheme', default='readoor31OtherPay')
|
||||
parser.add_argument('--binary', type=Path, help='Path to linked Mach-O binary')
|
||||
parser.add_argument('--dwarf', type=Path, help='Path to DWARF binary inside .dSYM')
|
||||
parser.add_argument('--symbol-map', type=Path, help='Optional L1 symbol_map.json')
|
||||
parser.add_argument('--require-zero-keybox-bl', action='store_true')
|
||||
parser.add_argument('--out', type=Path, help='Optional output JSON path')
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.ipa_dir:
|
||||
report = analyze_ipa_directory(
|
||||
args.ipa_dir,
|
||||
scheme=args.scheme,
|
||||
require_zero_keybox_direct_bl=args.require_zero_keybox_bl,
|
||||
)
|
||||
elif args.binary and args.dwarf:
|
||||
report = analyze_macho_calls(
|
||||
args.binary,
|
||||
args.dwarf,
|
||||
symbol_map_path=args.symbol_map,
|
||||
require_zero_keybox_direct_bl=args.require_zero_keybox_bl,
|
||||
)
|
||||
else:
|
||||
parser.error('Specify either --ipa-dir or both --binary and --dwarf')
|
||||
|
||||
text = json.dumps(report, ensure_ascii=False, indent=2) + '\n'
|
||||
if args.out:
|
||||
args.out.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.out.write_text(text, encoding='utf-8')
|
||||
print(
|
||||
json.dumps(
|
||||
{
|
||||
'text_call_summary': report['text_call_summary'],
|
||||
'keybox_total_direct_call_xrefs': report['keybox_and_bridge_15_symbols']['total_direct_call_xrefs'],
|
||||
'gate_passed': report['gate_passed'],
|
||||
'violations': report['violations'],
|
||||
},
|
||||
ensure_ascii=False,
|
||||
indent=2,
|
||||
)
|
||||
)
|
||||
return 0 if report['gate_passed'] else 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user