Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Tighten launchdhook opt-in behavior

xiahouzhen7c3fdf17c5d6
diff --git a/research/0_binary_patch_comparison.md b/research/0_binary_patch_comparison.md
index 63e5f22d..9304ad19 100644
--- a/research/0_binary_patch_comparison.md
+++ b/research/0_binary_patch_comparison.md
@@ -169,7 +169,7 @@ do NOT execute these).
| 3 | `mov x0,#1; ret` | `mobileactivationd` | Activation bypass | Y | Y | Y |
| 4 | Plist injection | `launchd.plist` | bash/dropbear/trollvnc/vphoned daemons | Y | Y | Y |
| 5 | `b` (skip jetsam guard) | `launchd` | Prevent jetsam panic on boot | - | Y | Y |
-| 6 | `LC_LOAD_DYLIB` injection | `launchd` | Optional: load short alias `/b` (copy of `launchdhook.dylib`) at launch when `VPHONE_JB_ENABLE_LAUNCHD_HOOK=1`; default off because the current BaseBin launchd hook exits pid 1 with `launchd cannot be run directly` | - | - | opt-in |
+| 6 | Weak dylib load injection | `launchd` | Optional: load short alias `/b` (copy of `launchdhook.dylib`) at launch when `VPHONE_JB_ENABLE_LAUNCHD_HOOK=1`; default off because this pid-1 hook path is boot-critical and has produced boot-analysis failures | - | - | opt-in |
| 7 | cstring byte 5 mangle `'h' → 'X'` (`"kern.hv_vmm_present"` → `"kern.Xv_vmm_present"`) + per-page slot-hash re-attestation, BLACKLIST semantics — **EXP only** | DSC dylibs | Companion to EXP kernel rename (`KernelEXPPatcher.patchHvVmmRename`). The mangle is applied to every DSC dylib EXCEPT those in `DONT_PATCH_INSTALL_NAMES` (sign-in / device-likeness consumers, ~15 entries). Patched dylibs query `kern.Xv_vmm_present` and get the truthful 1 (graphics / accel passthrough). Blacklisted dylibs keep the original cstring, hit ENOENT on the renamed kernel, cache 0, lie about VM presence. On `codeSigningMonitor == 2` hardware the byte-mangle alone causes `CODESIGNING/Invalid Page` SIGKILL because TXM enforces per-page hashes; the re-attestation pass recomputes the SHA-256 slot in the chunk's `CS_CodeDirectory` for every modified 16 KiB page. See `scripts/patchers/cfw_dsc_codesign.py` and `cfw_patch_hv_vmm_dsc.py`. | - | - | - |
| 8 | (removed — was: standalone-binary mangle in 6 rootfs Mach-Os via SSH) | n/a | Removed in the blacklist-flip redesign. With the EXP kernel rename in place, the 6 rootfs binaries (MobileActivationMigrator, CheckerBoard, StoreKitUISceneService, storekitd, appstored, CorePrescriptionService) get the desired "cache 0 / not in a VM" behavior for free: they keep their original cstring, hit ENOENT on the renamed kernel sysctl, defensive `cbnz w0, skip` leaves the cached byte at BSS-zero. No SSH-time standalone patch needed. | - | - | - |
diff --git a/scripts/cfw_install_exp.sh b/scripts/cfw_install_exp.sh
index 59e2ec5f..ba1f12dc 100755
--- a/scripts/cfw_install_exp.sh
+++ b/scripts/cfw_install_exp.sh
@@ -404,14 +404,18 @@ else
echo " [!] No entitlements found on original launchd"
fi
-# Injecting launchdhook into pid 1 is opt-in. On current vPhone builds the
-# BaseBin launchd hook exits early with "launchd cannot be run directly",
-# which panics the kernel because pid 1 exits.
-if [[ "$VPHONE_JB_ENABLE_LAUNCHD_HOOK" == "1" && -d "$JB_INPUT_DIR/basebin" ]]; then
- echo " Injecting LC_LOAD_DYLIB for /b (short launchdhook alias)..."
- "$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" inject-dylib "$TEMP_DIR/launchd" "/b"
+# Injecting launchdhook into pid 1 is opt-in. This boot-critical hook path has
+# produced boot-analysis failures; keep BaseBin deployed, but do not load /b
+# from launchd unless explicitly requested.
+if [[ "$VPHONE_JB_ENABLE_LAUNCHD_HOOK" == "1" ]]; then
+ if [[ -d "$JB_INPUT_DIR/basebin" ]]; then
+ echo " Injecting weak dylib load for /b (short launchdhook alias)..."
+ "$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" inject-dylib "$TEMP_DIR/launchd" "/b"
+ else
+ echo " [!] VPHONE_JB_ENABLE_LAUNCHD_HOOK=1 but BaseBin is missing; skipping launchdhook injection"
+ fi
else
- echo " [*] Skipping launchdhook LC_LOAD_DYLIB injection (set VPHONE_JB_ENABLE_LAUNCHD_HOOK=1 to enable)"
+ echo " [*] Skipping launchdhook dylib injection (set VPHONE_JB_ENABLE_LAUNCHD_HOOK=1 to enable)"
fi
"$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" patch-launchd-jetsam "$TEMP_DIR/launchd"
@@ -523,7 +527,7 @@ ssh_cmd "/bin/rm -rf /mnt5/$BOOT_HASH/$JB_DIR_NAME/procursus/jb"
ssh_cmd "/bin/rm -f /mnt5/$BOOT_HASH/bootstrap-iphoneos-arm64.tar"
rm -f "$BOOTSTRAP_TAR"
-# NOTE: /var/jb symlink is created at runtime by launchdhook.dylib
+# NOTE: /var/jb symlink is created on first normal boot by vphone_jb_setup.sh
# (Data volume is encrypted and not mountable from ramdisk).
echo " [+] procursus bootstrap installed"
diff --git a/scripts/cfw_install_jb.sh b/scripts/cfw_install_jb.sh
index b8736a8a..bb2e5092 100755
--- a/scripts/cfw_install_jb.sh
+++ b/scripts/cfw_install_jb.sh
@@ -235,14 +235,18 @@ else
echo " [!] No entitlements found on original launchd"
fi
-# Injecting launchdhook into pid 1 is opt-in. On current vPhone builds the
-# BaseBin launchd hook exits early with "launchd cannot be run directly",
-# which panics the kernel because pid 1 exits.
-if [[ "$VPHONE_JB_ENABLE_LAUNCHD_HOOK" == "1" && -d "$JB_INPUT_DIR/basebin" ]]; then
- echo " Injecting LC_LOAD_DYLIB for /b (short launchdhook alias)..."
- "$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" inject-dylib "$TEMP_DIR/launchd" "/b"
+# Injecting launchdhook into pid 1 is opt-in. This boot-critical hook path has
+# produced boot-analysis failures; keep BaseBin deployed, but do not load /b
+# from launchd unless explicitly requested.
+if [[ "$VPHONE_JB_ENABLE_LAUNCHD_HOOK" == "1" ]]; then
+ if [[ -d "$JB_INPUT_DIR/basebin" ]]; then
+ echo " Injecting weak dylib load for /b (short launchdhook alias)..."
+ "$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" inject-dylib "$TEMP_DIR/launchd" "/b"
+ else
+ echo " [!] VPHONE_JB_ENABLE_LAUNCHD_HOOK=1 but BaseBin is missing; skipping launchdhook injection"
+ fi
else
- echo " [*] Skipping launchdhook LC_LOAD_DYLIB injection (set VPHONE_JB_ENABLE_LAUNCHD_HOOK=1 to enable)"
+ echo " [*] Skipping launchdhook dylib injection (set VPHONE_JB_ENABLE_LAUNCHD_HOOK=1 to enable)"
fi
"$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" patch-launchd-jetsam "$TEMP_DIR/launchd"
@@ -320,7 +324,7 @@ ssh_cmd "/bin/rm -rf /mnt5/$BOOT_HASH/$JB_DIR_NAME/procursus/jb"
ssh_cmd "/bin/rm -f /mnt5/$BOOT_HASH/bootstrap-iphoneos-arm64.tar"
rm -f "$BOOTSTRAP_TAR"
-# NOTE: /var/jb symlink is created at runtime by launchdhook.dylib
+# NOTE: /var/jb symlink is created on first normal boot by vphone_jb_setup.sh
# (Data volume is encrypted and not mountable from ramdisk).
echo " [+] procursus bootstrap installed"