在 iOSGuard 侧产出可集成产物与接入文档,不修改 readoor 代码。 - defender/: anti_hook/anti_frida/anti_debug/anti_jailbreak 探针 + syscall 直发、 policy 分级层、poison 数据依赖毒化、dispatch/resolve/call_bridge 等子模块 - poison: 三副本冗余、无分支掩码;健康恒等、毒化破坏 key(替代 if-exit 处置) - policy: STRONG/MEDIUM/WEAK 分级,守误报底线,仅 DETECTED 参与、组合命中才毒化 - anti_jailbreak: IGSyscall 直发 svc 检测越狱文件(400)/沙盒逃逸(401),绕 libc hook - tools/build_defender_lib.sh: 一键交叉编译打包 libIGDefender.a(arm64) + umbrella 头 - docs/18_READOOR_DEFENDER_INTEGRATION.md: 精确到文件/bridging/替换点/代码片段 - docs/05-17 + evidence + tests + macho_guard/static_sdk_redirect 工具链 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
101 lines
5.2 KiB
Bash
Executable File
101 lines
5.2 KiB
Bash
Executable File
#!/bin/bash
|
||
# 门禁按钮级回归编排(dev 包 cn.touchv.a4YX061,iPhone 16 Plus)。
|
||
#
|
||
# v6 要点(v5d/v5e 教训):
|
||
# 1. XCUITest launchEnvironment 的 DYLD_INSERT 被 SpringBoard 剥离——注入相位必须
|
||
# devicectl `-e` 调试启动通道预先启动,测试仅 activate() attach。
|
||
# 2. devicectl `--console` 通道在连续会话后不可靠(console 零输出、进程即死、命令卡
|
||
# 超时;v5e 相位 2/4 三次重试全失败,且连无注入的干净 console 启动也卡死)——
|
||
# v6 改为无 console 启动:注入生效的证明 = 进程存活 + 测试内门禁 toast 端到端
|
||
# 命中(toast 只可能由 Defender 证据触发,链条自证)。console 仅在进程死亡时作
|
||
# 诊断回退。
|
||
# 3. 相位重排,XCUITest↔devicectl 切换从 4 次降到 2 次:
|
||
# ① 干净批 A1 勘察 + A2 确保游客态·登录页 → ② 注入批(游客)B1+B2
|
||
# ③ 干净批 C1 放行证明(真实登录尝试,断言只要求无门禁 toast)→ ④ 注入批(登录
|
||
# 态,若 C1 未登成则 D1/E1 以游客守卫跳过留证)D1+E1
|
||
#
|
||
# 用法:run_gate_regression.sh <runner目录> <输出目录>
|
||
set -uo pipefail
|
||
|
||
UDID=00008140-000960811493001C
|
||
BUNDLE=cn.touchv.a4YX061
|
||
DYLIB=/private/var/mobile/Containers/Data/Application/ED2D2D55-FBA5-4106-BEFD-87A7D40A42B9/Documents/libfrida-sim.dylib
|
||
|
||
RUNNER=${1:?用法: run_gate_regression.sh <runner目录> <输出目录>}
|
||
OUT=${2:?用法: run_gate_regression.sh <runner目录> <输出目录>}
|
||
mkdir -p "$OUT"
|
||
# 子 shell 会 cd 进 runner,全部转绝对路径避免相对路径错位(v5 首跑教训)
|
||
OUT=$(cd "$OUT" && pwd)
|
||
RUNNER=$(cd "$RUNNER" && pwd)
|
||
|
||
launch_injected() { # $1=相位名:终止现进程→devicectl 无 console 注入启动→
|
||
# 轮询进程存活确认(debug 通道坏时进程即死,v5e 教训),最多 3 次重试;
|
||
# 死亡时追加一次 --console 诊断启动留取 Defender 决策行/报错。成功后等 UI 稳定。
|
||
local phase=$1 alive=1
|
||
for attempt in 1 2 3; do
|
||
xcrun devicectl device process terminate --device "$UDID" "$BUNDLE" >/dev/null 2>&1
|
||
sleep 2
|
||
xcrun devicectl device process launch --device "$UDID" \
|
||
-e "{\"DYLD_INSERT_LIBRARIES\":\"$DYLIB\"}" "$BUNDLE" \
|
||
> "$OUT/launch-$phase-$attempt.log" 2>&1
|
||
local launched_rc=$? alive_now=0
|
||
for _ in $(seq 1 10); do # 30s 内确认进程存活
|
||
sleep 3
|
||
if [ "$(xcrun devicectl device info processes --device "$UDID" 2>/dev/null | grep -c "$BUNDLE")" -ge 1 ]; then
|
||
alive_now=1; break
|
||
fi
|
||
done
|
||
if [ "$alive_now" = 1 ]; then
|
||
echo "注入进程存活(第 $attempt 次尝试,rc=$launched_rc)——注入生效由测试内门禁 toast 端到端自证"
|
||
sleep 90 # 冷启动到首页稳定(A1 实测 ~158s 首页,90s 后 D1/E1 各自再等首页锚点)
|
||
alive=0; return 0
|
||
fi
|
||
echo "第 $attempt 次注入启动进程死亡,重试"
|
||
done
|
||
# 诊断回退:console 模式抓一次输出(若 debug 通道可用可拿到 Defender 决策行)
|
||
xcrun devicectl device process launch --device "$UDID" --console --timeout 60 \
|
||
-e "{\"DYLD_INSERT_LIBRARIES\":\"$DYLIB\"}" "$BUNDLE" \
|
||
> "$OUT/console-diag-$phase.log" 2>&1 &
|
||
echo "$!" > "$OUT/console-diag-$phase.pid"
|
||
echo "警告:$phase 三次注入启动进程均死亡;已发起 console 诊断启动(见 console-diag-$phase.log)"
|
||
return 1
|
||
}
|
||
|
||
run_tests() { # $1=结果包名, 其余=-only-testing 参数
|
||
local result=$1; shift
|
||
rm -rf "$OUT/$result" # xcodebuild 拒绝覆盖已存在结果包
|
||
(cd "$RUNNER" && xcodebuild test-without-building \
|
||
-project IGGateRegression.xcodeproj -scheme IGGateRegression \
|
||
-destination "id=$UDID" -resultBundlePath "$OUT/$result" "$@" \
|
||
> "$OUT/xcodebuild-$result.log" 2>&1)
|
||
echo "EXIT_$result=$?"
|
||
}
|
||
|
||
echo "== 相位1 干净批:A1 勘察 + A2 确保游客态(登录页)"
|
||
run_tests results-clean1.xcresult \
|
||
-only-testing:IGGateRegression/IGGateRegressionTests/testA1InspectCleanState \
|
||
-only-testing:IGGateRegression/IGGateRegressionTests/testA2LogoutIfNeeded
|
||
|
||
echo "== 相位2 注入批(游客态):B1 密码 + B2 第三方"
|
||
launch_injected b12 || true
|
||
run_tests results-inject-guest.xcresult \
|
||
-only-testing:IGGateRegression/IGGateRegressionTests/testB1BlockPasswordLogin \
|
||
-only-testing:IGGateRegression/IGGateRegressionTests/testB2BlockOtherLogins
|
||
|
||
echo "== 相位3 干净批:C1 放行证明(真实登录尝试)"
|
||
run_tests results-clean2.xcresult \
|
||
-only-testing:IGGateRegression/IGGateRegressionTests/testC1AllowPasswordLogin
|
||
|
||
echo "== 相位4 注入批(登录态):D1 VIP + E1 激活"
|
||
launch_injected de1 || true
|
||
run_tests results-inject-login.xcresult \
|
||
-only-testing:IGGateRegression/IGGateRegressionTests/testD1BlockVipPurchase \
|
||
-only-testing:IGGateRegression/IGGateRegressionTests/testE1BlockActivation
|
||
|
||
# 收尾:先终止应用(让 console 诊断会话自然收口),再清残留进程
|
||
xcrun devicectl device process terminate --device "$UDID" "$BUNDLE" >/dev/null 2>&1
|
||
for pidf in "$OUT"/console-diag-*.pid; do kill "$(cat "$pidf")" 2>/dev/null; done
|
||
|
||
echo "== 完成。诊断 console 中的 Defender 决策行(若有):"
|
||
grep -h "Defender\|证据" "$OUT"/console-diag-*.log 2>/dev/null | tail -8
|